Search Unity

Bug Addressables.GetDownloadSizeAsync(key) Seems to be broken or Docs are outdated.

Discussion in 'Addressables' started by sskenth, Apr 21, 2021.

  1. sskenth

    sskenth

    Joined:
    Sep 23, 2016
    Posts:
    50
    I've been having some serious issues with Addressables.GetDownloadSize

    Just trying to get this code from the docs to work.



    Code (CSharp):
    1.  
    2.  
    3. public IEnumerator Start()
    4. {
    5.    string key = "assetKey";
    6.    //Clear all cached AssetBundles
    7.    Addressables.ClearDependencyCacheAsync(key);
    8.  
    9.    //Check the download size
    10.    AsyncOperationHandle<long> getDownloadSize = Addressables.GetDownloadSizeAsync(key);
    11.    yield return getDownloadSize;
    12.  
    13.    //If the download size is greater than 0, download all the dependencies.
    14.    if (getDownloadSize.Result > 0)
    15.    {
    16.        AsyncOperationHandle downloadDependencies = Addressables.DownloadDependenciesAsync(key);
    17.        yield return downloadDependencies;
    18.    }
    19.  
    20.    //...
    21. }
    22.  
    https://docs.unity3d.com/Packages/com.unity.addressables@1.16/manual/DownloadDependenciesAsync.html

    I'm using Addressables 1.16.9 and Unity version 2019.4.19f

    I replaced "assetKey" with a label I have placed on some of my objects.

    When I run that I get an error(see below). I can only assume it's an error with the docs unless the code does not work straight outside of the box? Please let me know.

    The docs also say this "AsyncOperationHandle: an async operation handle that encompasses all the operations used to download the requested dependencies. Once complete, this handle can be safely released."
    I'm not sure what they mean could someone explain the code needed to release this?

    Thank you.

    -Satwant

    Code (CSharp):
    1. Exception: Attempting to use an invalid operation handle
    2. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].get_InternalOp () (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:160)
    3. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].add_Completed (System.Action`1[T] value) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:101)
    4. UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject].Execute () (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/ChainOperation.cs:131)
    5. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:466)
    6. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].<.ctor>b__34_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle o) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:118)
    7. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1+<>c__DisplayClass55_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] s) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:309)
    8. DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/Util/DelegateList.cs:69)
    9. UnityEngine.Debug:LogException(Exception)
    10. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/Util/DelegateList.cs:73)
    11. UnityEngine.AddressableAssets.Initialization.<>c__DisplayClass16_0:<LoadContentCatalogInternal>b__0(AsyncOperationHandle`1)
    12. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/Util/DelegateList.cs:69)
    13. UnityEngine.ResourceManagement.ChainOperation`2:OnWrappedCompleted(AsyncOperationHandle`1)
    14. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/Util/DelegateList.cs:69)
    15. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    16. MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.16.19/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:26)
     
unityunity