Search Unity

Bug DownloadDependenciesAsync error handling is broken

Discussion in 'Addressables' started by phobos2077, Jun 4, 2020.

  1. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    I'm working on a piece of code that needs to pre-download some bundles before they are needed. Naturally I wanted to handle case when download has failed to inform the user.

    Code (CSharp):
    1.  
    2.                 _contentDownloadHandle = Addressables.DownloadDependenciesAsync(locations, true);
    3.                 // Work around Addressables bug with Task property.
    4.                 while (!_contentDownloadHandle.IsDone) await Task.Yield();
    5.                 var isSuccess = _contentDownloadHandle.Status == AsyncOperationStatus.Succeeded;
    6.  
    In order to test this, I've just stopped the HTTP server hosting the remote catalog and bundles.

    Expected behavior:
    • AsyncOperationHandle.Status == AsyncOperationStatus.Failed.
    • OperationException is a valid exception with error message.
    Actual behavior:
    • AsyncOperationHandle.IsValid() suddenly becomes false.
    • Trying to access either Status or OperationException properties results in following exception:

      System.Exception: Attempting to use an invalid operation handle
      at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.get_InternalOp () [0x00026] in ...\Library\PackageCache\com.unity.addressables@1.9.2\Runtime\ResourceManager\AsyncOperations\AsyncOperationHandle.cs:306
      at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.get_Status () [0x00001] in ...\Library\PackageCache\com.unity.addressables@1.9.2\Runtime\ResourceManager\AsyncOperations\AsyncOperationHandle.cs:374

    PS: this method seems to be broken in multiple ways:

    @unity_bill please, this method desperately needs some more love! :)
     
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    False alarm. This issue is avoided if I don't pass "autoReleaseHandle = true" to DownloadDependenciesAsync and instead release handle manually. For some reason I thought Addressables.Release only makes the loaded asset unavailable. But apparently it also makes the internal operation invalid and Handle unusable.

    This code works:
    Code (CSharp):
    1.  
    2.                 _contentDownloadHandle = Addressables.DownloadDependenciesAsync(locations);
    3.                 // Work around Addressables bug with Task property.
    4.                 while (!_contentDownloadHandle.IsDone) await Task.Yield();
    5.                 var isSuccess = _contentDownloadHandle.Status == AsyncOperationStatus.Succeeded;
    6.                 Addressables.Release(_contentDownloadHandle);
    Other 2 issues are still relevant though.
     
    chrismarch likes this.