Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to PGS failed because all packs are unavailable. #18

Closed
Oldes opened this issue Jan 16, 2024 · 8 comments
Closed

Request to PGS failed because all packs are unavailable. #18

Oldes opened this issue Jan 16, 2024 · 8 comments

Comments

@Oldes
Copy link

Oldes commented Jan 16, 2024

I am trying the version 1.2.0 of this ANE. I have these assets in the manifest:

	<assetPacks>
		<assetPack id="asset_pack1" delivery="install-time" folder="assetpack1"/>
		<assetPack id="asset_pack2" delivery="fast-follow" folder="assetpack2"/>
		<assetPack id="asset_pack3" delivery="on-demand" folder="assetpack3"/>
	</assetPacks>

Including all 3 folders when making the AAB package.
The install-time delivery works as expected, but when I use code like this to fetch the other packs:

var assets:PlayAssetDelivery = new PlayAssetDelivery();
assets.debugMode = true;
if (assets.initAssetDelivery()) {
	assets.addEventListener( PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler );
	assets.fetchAssetPack("Start.lvl");
}

I can see this error in the log:

2024-01-17 00:08:22.902  2484-2484  FetchAsset              pid-2484                             I  FetchAsset
2024-01-17 00:08:22.902  2484-2484  FetchAsset              pid-2484                             I  Input value is [Start.lvl]
2024-01-17 00:08:22.902  2484-2484  PlayAssetA...ionContext pid-2484                             I  setPlayAssetDeliveryManagerObj get
2024-01-17 00:08:22.902  2484-2484  PlayAssetD...eryManager pid-2484                             D  fetch()
2024-01-17 00:08:22.902  2484-2620  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : Initiate binding to the service.
2024-01-17 00:08:22.902  2484-2484  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : startDownload([Start.lvl])
2024-01-17 00:08:22.902  2484-2484  PlayAssetD...eryManager pid-2484                             D  fetch() end: status 0
2024-01-17 00:08:22.902  2484-2484  FetchAsset              pid-2484                             I  FetchAsset end
2024-01-17 00:08:22.904  2484-2620  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : Waiting to bind to the service.
2024-01-17 00:08:22.927  2484-2484  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.assetmoduleservice.AssetModuleService})
2024-01-17 00:08:22.927  2484-2620  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : linkToDeath
2024-01-17 00:08:22.931  2484-2540  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : Leaving the connection open for other ongoing calls.
2024-01-17 00:08:22.931  2484-2540  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : onGetSessionStates
2024-01-17 00:08:22.941 31930-1598  Finsky                  com.android.vending                  E  [266] kvh.a(845): Request execution failed with error code: -2
                                                                                                    com.google.android.finsky.assetmoduleserviceutils.AssetModuleException: Request to PGS failed because all packs are unavailable.
                                                                                                    	at jlg.ads(PG:533)
                                                                                                    	at jqv.k(PG:75)
                                                                                                    	at ism.run(PG:70)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                    	at android.os.Looper.loop(Looper.java:319)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8893)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
2024-01-17 00:08:22.942  2484-2540  PlayCore                pid-2484                             E  UID: [10456]  PID: [2484] AssetPackServiceImpl : onError(-2)
2024-01-17 00:08:22.942  2484-2620  PlayCore                pid-2484                             I  UID: [10456]  PID: [2484] AssetPackServiceImpl : Unbind from service.
2024-01-17 00:08:22.942  2484-2484  PlayAssetD...eryManager pid-2484                             W  Exception in fetch asset pack completion handler: com.google.android.play.core.assetpacks.AssetPackException: Asset Pack Download Error(-2): The requested pack is not available. (https://developer.android.com/reference/com/google/android/play/core/assetpacks/model/AssetPackErrorCode.html#PACK_UNAVAILABLE)
2024-01-17 00:09:23.729  2793-3068  system_server           system_server                        W  ApkAssets: Deleting an ApkAssets object '<empty> and /data/app/~~eDpKdDiLqppYrmwnxhj7Zg==/com.sec.android.app.launcher--z6UznvbefN5XpkjxHBz1A==/base.apk' with 1 weak references

Tested with AIR 50.2.4 and android:targetSdkVersion="33"

@marchbold
Copy link
Contributor

Shouldn't you be passing the asset pack id to the fetchAssetPack() method? Looks like you are passing a filename?

@Oldes
Copy link
Author

Oldes commented Jan 17, 2024

You are right... when I use asset pack id, the error is gone. The documentation still needs improvements...
I don't have the error, but I don't see expected PlayAssetDeliveryEvent. This is what I have in the log now:

2024-01-17 11:16:14.780 24068-24068 FetchAsset              pid-24068                            I  FetchAsset
2024-01-17 11:16:14.780 24068-24068 FetchAsset              pid-24068                            I  Input value is [asset_pack2]
2024-01-17 11:16:14.780 24068-24126 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : syncPacks
2024-01-17 11:16:14.780 24068-24068 PlayAssetA...ionContext pid-24068                            I  setPlayAssetDeliveryManagerObj get
2024-01-17 11:16:14.780 24068-24068 PlayAssetD...eryManager pid-24068                            D  fetch()
2024-01-17 11:16:14.780 24068-24127 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : Initiate binding to the service.
2024-01-17 11:16:14.780 24068-24068 PlayAssetD...eryManager pid-24068                            D  fetch() end: status 0
2024-01-17 11:16:14.780 24068-24068 FetchAsset              pid-24068                            I  FetchAsset end
2024-01-17 11:16:14.803 24068-24068 PlayAssetD...eryManager pid-24068                            I  status: 4, name: asset_pack2, errorCode: 0, bytesDownloaded: 0, totalBytesToDownload: 0, transferProgressPercentage: 0
2024-01-17 11:16:14.803 24068-24068 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.assetmoduleservice.AssetModuleService})
2024-01-17 11:16:14.804 24068-24127 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : linkToDeath
2024-01-17 11:16:14.806 24068-24091 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : onGetSessionStates
2024-01-17 11:16:14.806 24068-24127 PlayCore                pid-24068                            I  UID: [10456]  PID: [24068] AssetPackServiceImpl : Unbind from service.

I can see, that the status is 4 (COMPLETED) in the log, but the sizes are all zero:/ Also without a source code and missing documentation it is not clear to me, how I could access files from the pack?

@Oldes
Copy link
Author

Oldes commented Jan 17, 2024

A combination of the pack id and the asset file name is causing the error again, so it is not the right way to go :-/

@ajwfrost
Copy link

Hi

I'm not sure why you're getting the zero size for the bytes downloaded etc.. those are just the values from the Android API (AssetPackState.bytesDownloaded() etc). Is this a properly published application, or is it going through local testing? https://developer.android.com/guide/playcore/asset-delivery/test

My assumption as to why you don't get the event callback is just that it's likely the garbage collector has run, so if you just had a local object (var assets) then there would be nothing to keep that around..

To get at the assets, it depends a bit on which type of asset pack...
https://github.com/airsdk/ANE-PlayAssetDelivery/wiki#accessing-assets
asset_pack2 is fast-follow and you'd access things the same as for an on-demand pack, i.e. either find the installation location via getAssetPackLocation and then add the path to your file; or use getAssetAbsolutePath. From memory, you wouldn't need to include the asset pack folder name - i.e. from your packaging command, asset pack 2 was in a folder called assetpack2 so if you had a file in here called test.txt then just use that as the path, rather than assetpack2/test.txt.

Hope that helps! Conversations re open sourcing have reached the legal team..

@Oldes
Copy link
Author

Oldes commented Jan 17, 2024

Thanks for reply and sorry for so many questions... I am slowly getting forward... I already managed to get fast-follow pack downloaded (at least using a local testing apk).

I believe that there are some bugs in the latest ANE.. for example calling assets.getAssetPackStatus("asset_pack2") always gives me 0, even when I call it from the playAssetDelivery_statusHandler when the event is PlayAssetStatus.COMPLETED.
On the other side, calling assets.getAssetAbsolutePath("asset_pack2", "Start.lvl") from the same place now gives me full path to the file, which is OK.

@Oldes
Copy link
Author

Oldes commented Jan 17, 2024

The PlayAssetDeliveryEvent events are also somehow heretic... I wanted first fetch the fast-follow assets and then fetch the on-demand assets... it goes ok with the first pack, but when I call assets.fetchAssetPack("asset_pack3"); when I receive PlayAssetStatus.COMPLETED then I receive the COMPLETED event for the fast pack with each on-demand pack event. It looks that the closed source is maybe reporting status for all packs with every internal change. But that should be maybe as a separate issue.

My code looks like:

case PlayAssetStatus.COMPLETED:
{
	if(event.assetPackName == "asset_pack2") {
		log("status asset_pack2: "+ assets.getAssetPackStatus("asset_pack2")); // always zero!!!
		log("absolutePath: "+ assets.getAssetAbsolutePath("asset_pack2", "Start.lvl")); // OK

		// we have the fast follow assets, so let's download the rest!
		log("\non-demand assets =====================================");
		assets.fetchAssetPack("asset_pack3");
	} else {
		log("status asset_pack3: "+ assets.getAssetPackStatus("asset_pack3"));  // always zero!!!
		log(assets.getAssetAbsolutePath("asset_pack3", "Univerzal.lvl"));  // OK
		
		// stop resolving any other events as we are done!
		assets.removeEventListener( PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler );
	}
	break;
}

@ajwfrost
Copy link

We had shifted the architecture recently, to cope with people having multiple instances of the ANE AS3 class, and that may have caused issues with events being sent to multiple listeners (i.e. any listener would get all events..) - so we may need to check that, it could be a new problem... but yes, let me copy/paste this into a new issue!

@Oldes
Copy link
Author

Oldes commented Jan 17, 2024

I'm closing this issue as it looks that the error from the title is related to a non-existing package.
It would be good to better document in the wiki that the fast-follow and on-demand asset packs must be downloaded using the assetPack id used in the manifest file. In my case:

var assets:PlayAssetDelivery = new PlayAssetDelivery();
assets.debugMode = true;
if (assets.initAssetDelivery()) {
	assets.addEventListener( PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler );
	assets.fetchAssetPack("asset_pack2");
}

Maybe it would be also good to have some way how to report an error to user, when invalid or missing assetPack id is used.

@Oldes Oldes closed this as completed Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants