Search Unity

Release error: Value cannot be null. Parameter name: key

Discussion in 'Addressables' started by fendercodes, May 29, 2021.

  1. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    192
    We're getting this error. It seems to be happening when calling
    .Release()
    on the same handle multiple times on the same frame. Any ideas?

    Code (CSharp):
    1. ArgumentNullException: Value cannot be null. Parameter name: key
    2.  
    3. Managed Stack Trace:
    4.  
    5. System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <9577ac7a62ef43179789031239ba8798>:0)
    6. System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <9577ac7a62ef43179789031239ba8798>:0)
    7. UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider.ReleaseInstance (UnityEngine.ResourceManagement.ResourceManager resourceManager, UnityEngine.GameObject instance) (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    8. UnityEngine.ResourceManagement.ResourceManager+InstanceOperation.Destroy () (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    9. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].DecrementReferenceCount () (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    10. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation.DecrementReferenceCount () (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    11. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.Release () (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    12. UnityEngine.ResourceManagement.ResourceManager.Release (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle handle) (at <30a0fe5aad054dd6935a12ccf245d660>:0)
    13. UnityEngine.AddressableAssets.AddressablesImpl.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <1c219dc3fbda46ed8edd9b8f94f69580>:0)
    14. UnityEngine.AddressableAssets.Addressables.Release[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] handle) (at <1c219dc3fbda46ed8edd9b8f94f69580>:0)
    15. CharacterLoader.ReleaseHandles () (at <64748e74b8834904a62bd2e8cd23f875>:0)
    16. CharacterLoader.OnOutfit () (at <64748e74b8834904a62bd2e8cd23f875>:0)
    17. Bolt.NetworkState.InvokeCallbacksForProperty (System.Int32 propertyIndex) (at <cebd479ea101478f8cb10abb07108f92>:0)
    18. UnityEngine.Debug:LogException(Exception)
    19. BoltLog:Exception(Exception)
    20. Bolt.NetworkState:InvokeCallbacksForProperty(Int32)
    21. Bolt.NetworkState:InvokeCallbacks()
    22. Bolt.NetworkState:Bolt.IEntitySerializer.OnSimulateBefore()
    23. Bolt.Entity:Simulate()
    24. BoltInternal.BoltCore:StepControlledEntities()
    25. BoltInternal.BoltCore:Poll()
    26. BoltPoll:FixedUpdate()
     
    MrLucid72 likes this.
  2. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    I have this issue. It seems to come from a null TryGetValue, where (name) == null
     
  3. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    If this is reproducible can you log a bug and we can look into it.

    Instances can be cleared when they are destroyed so it is likely something around that.
    The best practice for instancing Prefabs, is to not use Addressables.InstantiateAsync as you lose full control over the release and generally have more overheads on performance.
    Instead it is best to LoadAsset on the Prefab and instantiate it your self, then release the prefab when you no longer are using them.
     
  4. EMI_10

    EMI_10

    Joined:
    Mar 16, 2022
    Posts:
    1
    Is there any fix for this issue ?