Search Unity

[bug] possible bad IResourceLocation.Hash

Discussion in 'Addressables' started by nik_d, Jun 19, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    50
    The crash from production environment (just dozens for millions, but don't like it in any case) - from Fabric's Crashlytics:

    Code (CSharp):
    1. InvalidCastException : Unable to cast object of type 'ProviderOperation`1' to type 'AsyncOperationBase`1'.
    2. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].op_Implicit (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject])
    3. UnityEngine.ResourceManagement.ResourceManager.ProvideResource[TObject] (UnityEngine.ResourceManagement.ResourceManager)
    4. UnityEngine.AddressableAssets.AddressablesImpl.LoadAssetAsync[TObject] (UnityEngine.AddressableAssets.AddressablesImpl)
    5. UnityEngine.AddressableAssets.Addressables.LoadAssetAsync[TObject] (UnityEngine.AddressableAssets.Addressables)
    6. Address.AddressablesExt.LoadAssetAsync[T] (Address.AddressablesExt)
    I could not repeat it externally but found the only way to reproduce the same exception/callstack - to fake
    m_AssetOperationCache.TryGetValue returns op for different type.

    So just decided to strengthen cache checking in ResourceManager.ProvideResource() for now:
    Code (CSharp):
    1.             if (m_AssetOperationCache.TryGetValue(hash, out op)
    2.                 //**addressables: possible bugfix: by Crashlytics: "InvalidCastException : Unable to cast object of type 'ProviderOperation`1' to type 'AsyncOperationBase`1'." in ProvideResource()
    3.                 && op.ResultType == desiredType)
    4.  
    (to see in next release: whether CreateOperation() will fail with m_AssetOperationCache.Add =))
     
    Last edited: Jun 19, 2019
    unity_bill likes this.