Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[bug] assets loading after DownloadDependencies

Discussion in 'Addressables' started by nik_d, Jun 12, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    workaround: in AssetBundleProvider.cs Unload(...):

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

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    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.
     
  3. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    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.

    Code (CSharp):
    1.             {
    2.                 Debug.Log("1. start pre-download deps without usage");
    3.                 var op = Addressables.DownloadDependenciesAsync("skins/BigSkin_Rok_Ninja");
    4.                 yield return op;
    5.                 Debug.Assert(op.OperationException == null);
    6.                
    7.                 Debug.Log("2. release pre-download operation");
    8.                 Addressables.ResourceManager.Release(op);
    9.             }
    10.  
    11.             {
    12.                 Debug.Log("3. start asset usage");
    13.                 var op = Addressables.LoadAssetAsync<Texture>("skins/BigSkin_Rok_Ninja");
    14.                 yield return op;
    15.                 Debug.Assert(op.Result != null);
    16.                
    17.                 Debug.Log("finished successfully");
    18.             }
    19.  
    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.
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    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.
     
    nik_d likes this.