[bug] assets loading after DownloadDependencies

workaround: in AssetBundleProvider.cs Unload(…):

            //**addressables: fix: otherwise after DownloadDependencies().Complete += op => Addressables.Release we cannot load assets from remote bundle (via CreateWebRequest) with error:
            //    "The AssetBundle '***' can't be loaded because another AssetBundle with the same files is already loaded."
            GetAssetBundle();

Please give a little more context as to where exactly you’re suggesting this fix go, and what game code is causing a bug without the change.

Without fix - download dependencies, free download deps-operation and try to load/use bundle again:
“The AssetBundle ‘http://localhost:55555/ui_misc_assets_all.bundle’ can’t be loaded because another AssetBundle with the same files is already loaded.” will be on 3rd step.

            {
                Debug.Log("1. start pre-download deps without usage");
                var op = Addressables.DownloadDependenciesAsync("skins/BigSkin_Rok_Ninja");
                yield return op;
                Debug.Assert(op.OperationException == null);
               
                Debug.Log("2. release pre-download operation");
                Addressables.ResourceManager.Release(op);
            }

            {
                Debug.Log("3. start asset usage");
                var op = Addressables.LoadAssetAsync<Texture>("skins/BigSkin_Rok_Ninja");
                yield return op;
                Debug.Assert(op.Result != null);
               
                Debug.Log("finished successfully");
            }

Addressables.ResourceManager.Release(op) is obligatory:

  1. Otherwise you cannot try download-deps later after fail (the same handle with OperationException is returned from the cache)
  2. I don’t want to keep hundreds of bundles opened during theirs preloading.

It sounds like we have a bug in our download dependencies code. That code should not be loading a bundle at all. So if your fix is to just be sure to unload it during a release, then you’ve identified a problem, but not quite the right solution. Maybe we even have two bugs. One, we load a bundle. Two, we don’t clean up the AsyncOperation properly. We’ll look into it.

1 Like