Search Unity

Multiple errors from calling Release()

Discussion in 'Addressables' started by fendercodes, Jun 3, 2021.

  1. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    192
    We're getting a couple of errors related to calling Release() on handles. I think it has something to do with calling Release() twice on the same handle within quick succession but I cannot be sure. I'm unable to reproduce this as this is in-production and we're getting these reports from a small subset of users in our error reporting dashboard. We're on the latest version of Addressables.

    Code (CSharp):
    1.  
    2. ArgumentNullException: Value cannot be null. Parameter name: key
    3.  
    4. Managed Stack Trace:
    5.  
    6. System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <9577ac7a62ef43179789031239ba8798>:0)
    7. System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <9577ac7a62ef43179789031239ba8798>:0)
    8. UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider.ReleaseInstance (UnityEngine.ResourceManagement.ResourceManager resourceManager, UnityEngine.GameObject instance) (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    9. UnityEngine.ResourceManagement.ResourceManager+InstanceOperation.Destroy () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    10. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].DecrementReferenceCount () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    11. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation.DecrementReferenceCount () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    12. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.Release () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    13. UnityEngine.ResourceManagement.ResourceManager.Release (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle handle) (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    14. UnityEngine.AddressableAssets.AddressablesImpl.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <cb322a16d0ca4c05bd7f272351d2b6d0>:0)
    15. UnityEngine.AddressableAssets.Addressables.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <cb322a16d0ca4c05bd7f272351d2b6d0>:0)
    16. OutfitPreviewLoader.Release () (at <2e1192c355854c679d6358f2c565503a>:0)
    17. OutfitPreviewLoader.Clear () (at <2e1192c355854c679d6358f2c565503a>:0)
    18. OutfitPreviewLoader+<PreviewInternal>d__16.MoveNext () (at <2e1192c355854c679d6358f2c565503a>:0)
    19. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <e3cc0d511c49480aba0b4b05faed2ad3>:0)
    20. UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    21. OutfitPreviewLoader:Preview(String, String, String)
    22. Horror.Menu:ShowCharacterOutfits()
    23. UnityEngine.EventSystems.EventSystem:Update()
    Code (CSharp):
    1.  
    2. Exception: Cannot decrement reference count for operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result='null', status='Succeeded' because it is already 0
    3.  
    4. Managed Stack Trace:
    5.  
    6. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].DecrementReferenceCount () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    7. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation.DecrementReferenceCount () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    8. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.Release () (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    9. UnityEngine.ResourceManagement.ResourceManager.Release (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle handle) (at <4bbc31d55fc445d6b6e8afda9343ccd1>:0)
    10. UnityEngine.AddressableAssets.AddressablesImpl.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <cb322a16d0ca4c05bd7f272351d2b6d0>:0)
    11. UnityEngine.AddressableAssets.Addressables.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <cb322a16d0ca4c05bd7f272351d2b6d0>:0)
    12. OutfitPreviewLoader.Release () (at <2e1192c355854c679d6358f2c565503a>:0)
    13. OutfitPreviewLoader.OnDestroy () (at <2e1192c355854c679d6358f2c565503a>:0)
    14.  
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    We'll flag with the team for some guidance!
     
  3. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    So, normally calling Release twice on a handle would give an "Attempting to use an invalid operation handle" error. Since you're not seeing that as your error I'm curious what load code you have going on around these releases. I figure there's something bumping the ref count of the internal operation of your handle which warrants releasing it twice? If so, there must be some race condition that's happening. Let me know what the loading situation looks like and then if there's nothing I can glean you may need to file a bug so we can get your repro project