Hi,
I tried to update content with the ‘update a previous build’ workflow, there are 2 issues pops up. Tested on both 1.18.16 and 1.19.6, the results are same.
The issues are related with static content.
- Even 1 prefab is slightly changed, like change the scale, change the color of Image component, the size of catalog.json grows from ~3MB to ~60MB.
- after loading updated catalog.json, there is exception says
Invalid path in AssetBundleProvider ''from AssetBundleResource.BeginOperation()
The issues are caused by RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates()
Take my case for example:
- one of UIs in game, say Prefab1, who references many Sprites, is included in AssetBundle A
- the referenced Sprites, Sprite1,2,…10, are included in AssetBundle B
- build content and player, get catalog.json1
- modify Prefab1, and build content with ‘update a previous build’, get catalog.json2
The issues:
- catalog.json2 is much more larger than catalog.json1. By deserializing and comparing them, the key list of AssetBundle B is much longer.
in catalog.json1, AssetBundle B has only 1 or 2 keys, which is easy to understand, its InternalId is file path, its key is its lowercase group name:
InternalId: {UnityEngine.AddressableAssets.Addressables.RuntimePath}/AssetBundleB_all_assets_hash.bundle
Keys: assetbundleb
And in catalog.json2, the key list could be very long, there are extra keys like AssetBundle B’s InternalId + some asset’s hashcode:
Keys:
{UnityEngine.AddressableAssets.Addressables.RuntimePath}/AssetBundleB_all_assets_hash.bundle-15210046
{UnityEngine.AddressableAssets.Addressables.RuntimePath}/AssetBundleB_all_assets_hash.bundle7521648523
…
the actual situation would be more complicated, in the above 60MB catalog.json I mentioned, many asset bundle entries have 10000+ keys after updated.
- right after the client downloaded the catalog.json2, errors pop up immediately when it tries to load something. The error is
Invalid path in AssetBundleProvider''from AssetBundleResource.BeginOperation() ln 430. The reason of this error is because it is trying to load a scene, the scene’s asset bundle has several dependencies, which are also asset bundles, but these AB’s field “Data” is empty, which is supposed to beAssetBundleRequestOptions. It cause the loadType returns None in AssetBundleProvider.GetLoadInfo().
What it looks like is:
at the end of “update a previous build”, the build script runs RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(), it dose something like this:
It detects Prefab1 has dependency assets Sprite1…100, for each sprite, it find the asset bundle which contains the sprite, then add a location, whose internal id is the assetbundle file name, and the key is assetbundle’s file name + Prefab1’s hash code.
In this case, all sprites are packed in asset bundle B, so asset bundle B has 100 new locations.
In RevertUnchangedAssetsToPreviousAssetState.cs ln 187, you can see these locations have no Data, which means they have no AssetBundleRequestOptions. In most time these locations will be merged into the “real” asset bundle entries in ContentCatalogData.SetData(). But in my case, one of these locations becomes the “real” entry of asset bundle B, so operation chains finally fail due to the above runtime error when “load scene”->“load scene’s asset bundle”->“load dependencies”->“load asset bundle B”(it’s loadType is None)
So what confused me is:
- what RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates() does? why add so many weird locations?
there is comment says “If the entry has dependencies, we need to update those to point to their respective cached versions as well.”, but I don’t quite understand what it means. - It’s 100% reproducible at my side here. If it’s a bug, many users would met the same error, however actually they don’t. Is there any settings/steps I did wrong during the whole workflow? How to fix it?
