DownloadDependenciesAsync done with exception [GenerateCompletedOperationDisplayName entry is null]

I am using the below code to download dependencies from remote server:

                AsyncOperationHandle downloadHandle = Addressables.DownloadDependenciesAsync(FilterKeys(locator.Keys), Addressables.MergeMode.Union, true);
                while (!downloadHandle.IsDone)
                {
                    updatePercentage = downloadHandle.PercentComplete;
                    await Task.Yield();
                }

The assets seems download sucessfully. But there is an exception throw at the end of the download process. Below is the error message:

NullReferenceException: Object reference not set to an instance of an object.
  at UnityEngine.AddressableAssets.Utility.ResourceManagerDiagnostics.GenerateCompletedOperationDisplayName (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle handle) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.AddressableAssets.Utility.ResourceManagerDiagnostics.OnResourceManagerDiagnosticEvent (UnityEngine.ResourceManagement.ResourceManager+DiagnosticEventContext eventContext) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.ResourceManager.PostDiagnosticEvent (UnityEngine.ResourceManagement.ResourceManager+DiagnosticEventContext context) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.ResourceManager.CreateCompletedOperationInternal[TObject] (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.ResourceManager+<>c__DisplayClass100_0`1[TObject].<ProvideResources>b__1 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle resultHandle) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject].Execute () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1+<>c__DisplayClass60_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] s) [0x00000] in <00000000000000000000000000000000>:0 
  at DelegateList`1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Complete (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.GroupOperation.CompleteIfDependenciesComplete () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1+<>c__DisplayClass60_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] s) [0x00000] in <00000000000000000000000000000000>:0 
  at DelegateList`1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Complete (TObject result, System.Boolean success, System.Exception exception, System.Boolean releaseDependenciesOnFailure) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource.WebRequestOperationCompleted (UnityEngine.AsyncOperation op) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
DelegateList`1:Invoke(T)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
UnityEngine.ResourceManagement.AsyncOperations.GroupOperation:CompleteIfDependenciesComplete()
UnityEngine.ResourceManagement.AsyncOperations.<>c__DisplayClass60_0:<add_CompletedTypeless>b__0(AsyncOperationHandle`1)
DelegateList`1:Invoke(T)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1:ProviderCompleted(T, Boolean, Exception)
UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:WebRequestOperationCompleted(AsyncOperation)
UnityEngine.AsyncOperation:InvokeCompletionEvent()

After diagnosis, I found it is the below code that the entry is null:
Library\PackageCache\com.unity.addressables@1.22.3\Runtime\Utility\ResourceManagerEventCollector.cs

Please help.

I have the same issue. Is there a workaround or a fix planned?

I managed to get around this issue, by calling

Addressables.ResourceManager.ClearDiagnosticCallbacks before calling Addressables.DownloadDependenciesAsync.

There’s also a way to override the package source code, but I didn’t want to go that route so I went with the ClearDiagnosticCallbacks workaround until there’s a fix.

1 Like

Hi,

This looks like a pretty straightforward bug. Would you mind submitting a bug report so we can track it?

How do I submit a bug report? – Unity Support Help Center

I haven’t had success using ClearDiagnosticCallbacks. After some debugging, the work around I found was setting “Send Profiler Events” to false on the Addressable Asset Settings object before building addressables.

Having it True when building Addressables results in the m_ProfileEvents being set to True in the settings.json file (found at Library/com.unity.addressables\aa<Platform>).

Setting it to false will stop the AsyncOperations from attempting to send profiler events at runtime.

3 Likes

I’m experiencing this issue too. Invoking Addressables.ResourceManager.ClearDiagnosticCallbacks() as suggested by @cabbyU stops the exception from being thrown.

@timtunity3d Has the issue been reported to the team responsible for addressables? Is there a timeline on a fix?

We looked into the problem and the solution geronimoj mentioned is the way to solve the issue. You need to turn off the Send Profiler Events flag and rebuild content.

If that doesn’t work for you for some reason, please outline your use case and we can talk it through some more.

Hey @timtunity3d, this looks more like a temporary workaround since it will disable the Event Viewer. Will Unity fix the root cause so we don’t need to do that in the future?

Thank you.

You’re correct. I think we might have a fix.

Just wanted to let you know that this bug has just been fixed in Addressable 1.27.0

1 Like