You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Addressables.LoadAsync<Object>(key).ToUniTask(ct), the asset returned is sometimes not the one specified by the key, but rather an asset whose loading was previously canceled.
To Reproduce
Steps to reproduce the behavior:
Call Addressables.LoadAsync<Object>(key).ToUniTask(ct) with a particular key.
Observe that the asset returned is not associated with the newKey but is instead related to the first key.
Expected behavior
The asset returned should be the one specified by the latest key provided.
Investigation and Possible Cause
It appears that the load handle remains alive, even if the UniTask waiting on the load is canceled. Addressables seem to retain a reference until the operation completes.
When a UniTask is canceled, the AsyncOperationHandleConfiguredSource is returned to the pool, and the same instance is reused for the next load operation.
When the previous load eventually completes, it invokes the handle's completion callback, which mistakenly triggers the AsyncOperationHandleConfiguredSource.Complete for an unrelated wait operation.
Proposed Solution
Insert handle.Completed -= completedCallback within the following if statement:
Describe the bug
When using
Addressables.LoadAsync<Object>(key).ToUniTask(ct)
, the asset returned is sometimes not the one specified by the key, but rather an asset whose loading was previously canceled.To Reproduce
Steps to reproduce the behavior:
Addressables.LoadAsync<Object>(key).ToUniTask(ct)
with a particular key.Addressables.LoadAsync<Object>(newKey).ToUniTask(newCt)
.newKey
but is instead related to the first key.Expected behavior
The asset returned should be the one specified by the latest key provided.
Investigation and Possible Cause
AsyncOperationHandleConfiguredSource
is returned to the pool, and the same instance is reused for the next load operation.AsyncOperationHandleConfiguredSource.Complete
for an unrelated wait operation.Proposed Solution
Insert
handle.Completed -= completedCallback
within the following if statement:UniTask/src/UniTask/Assets/Plugins/UniTask/Runtime/External/Addressables/AddressablesAsyncExtensions.cs
Lines 237 to 246 in 8042b29
This change should ensure that the completion callback does not unintentionally invoked by unrelated load operations.
Sample Code
Conditions for Reproduction
Result
In the log output for the "test2" load, the name of the asset from "test1" (which was supposed to be canceled) is displayed.
The text was updated successfully, but these errors were encountered: