Search Unity

(Case 160106) [0.8.6][BUG] "Exception encountered in operation Resource" when load resources

Discussion in 'Addressables' started by Sylmerria, May 29, 2019.

  1. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hi team, @unity_bill ,

    When I try to load my assets in fast mode some objects are reporting an error.
    The strange things is somes don't work and somes work.

    save1.PNG

    You can see error log is pretty useless :(

    When I switch to virtual mode, I have better error log but with strange behaviour :

    Code (CSharp):
    1. Exception: Provider of type UnityEngine.ResourceManagement.ResourceProviders.Simulation.VirtualBundledAssetProvider with id UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider has provided a result of type System.Object which cannot be converted to requested type HMH.Data.AnimationClipSprite. The operation will be marked as failed.
    2. UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/AsyncOperations/ProviderOperation.cs:118)
    3. UnityEngine.ResourceManagement.ResourceProviders.ProvideHandle.Complete[T] (T result, System.Boolean status, System.Exception exception) (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/ResourceProviders/IResourceProvider.cs:107)
    4. UnityEngine.ResourceManagement.ResourceProviders.Simulation.VirtualBundledAssetProvider+InternalOp.RequestOperation_Completed (UnityEngine.ResourceManagement.ResourceProviders.Simulation.VBAsyncOperation`1[TObject] obj) (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/ResourceProviders/Simulation/VirtualBundledAssetProvider.cs:82)
    5. DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/Util/DelegateList.cs:69)
    6. UnityEngine.Debug:LogException(Exception)
    7. DelegateList`1:Invoke(VBAsyncOperation`1) (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/Util/DelegateList.cs:73)
    8. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    9. MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@0.8.6-preview/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)

    HMH.Data.AnimationClipSprite class is a scriptableObject.

    The loading script ( a part) :

    Code (CSharp):
    1.         private IEnumerator LoadingProcedure()
    2.         {
    3.             _name2AgentAnimationInfo = new Dictionary<string, AgentAnimationInfo>(StringComparer.Ordinal);
    4.             _name2ResourceInfo = new Dictionary<string, ResourceInfo>(StringComparer.Ordinal);
    5.             _name2EquipmentInfo = new Dictionary<string, EquipmentInfo>(StringComparer.Ordinal);
    6.             _name2InfluencingVariableInfo = new Dictionary<string, InfluencingVariableInfo>(StringComparer.Ordinal);
    7.             _name2TileInfoTerrain = new Dictionary<string, TileInfoTerrain>(StringComparer.Ordinal);
    8.             _name2AgentInfo = new Dictionary<string, AgentInfo>(StringComparer.Ordinal);
    9.             _name2TileInfoBuilding = new Dictionary<string, TileInfoBuilding>(StringComparer.Ordinal);
    10.  
    11.             yield return Preload();
    12.  
    13.             yield return LoadData(AddressableAgentAnimationName, _name2AgentAnimationInfo);
    14.             yield return LoadData(AddressableResourceName, _name2ResourceInfo);
    15.             yield return LoadData(AddressableEquipmentName, _name2EquipmentInfo);
    16.            // yield return LoadData(AddressableInfluencingVariableName, _name2InfluencingVariableInfo);
    17.             yield return LoadData(AddressableGroundName, _name2TileInfoTerrain);
    18.             yield return LoadData(AddressableAgentName, _name2AgentInfo);
    19.             yield return LoadData(AddressableBuildingName, _name2TileInfoBuilding);
    20.         }
    21.  
    22.         private IEnumerator Preload()
    23.         {
    24.             var initHandler = Addressables.InitializeAsync();
    25.  
    26.             while (initHandler.IsDone == false)
    27.                 yield return null;
    28.  
    29.             var assetsRaw = Addressables.DownloadDependenciesAsync("Assets Raw");
    30.  
    31.             while (assetsRaw.IsDone == false)
    32.                 yield return null;
    33.  
    34.             var assets = Addressables.DownloadDependenciesAsync(AddressableAssetsName);
    35.  
    36.             while (assets.IsDone == false)
    37.                 yield return null;
    38.  
    39.             var agentAnimationHandler = Addressables.DownloadDependenciesAsync(AddressableAgentAnimationName);
    40.             var resourceHandler = Addressables.DownloadDependenciesAsync(AddressableResourceName);
    41.           //  var influencingVariableHandler = Addressables.DownloadDependenciesAsync(AddressableInfluencingVariableName);
    42.             var groundHandler = Addressables.DownloadDependenciesAsync(AddressableGroundName);
    43.             var agentHandler = Addressables.DownloadDependenciesAsync(AddressableAgentName);
    44.             var buildingHandler = Addressables.DownloadDependenciesAsync(AddressableBuildingName);
    45.  
    46.             while (agentAnimationHandler.IsDone == false)
    47.                 yield return null;
    48.  
    49.             while (resourceHandler.IsDone == false)
    50.                 yield return null;
    51.  
    52.           //  while (influencingVariableHandler.IsDone == false)
    53.           //      yield return null;
    54.  
    55.             while (groundHandler.IsDone == false)
    56.                 yield return null;
    57.  
    58.             while (agentHandler.IsDone == false)
    59.                 yield return null;
    60.  
    61.             while (buildingHandler.IsDone == false)
    62.                 yield return null;
    63.         }
    64.  
    65.         private IEnumerator LoadData<T>(string labelName, Dictionary<string, T> storage) where T : DataInfo, new()
    66.         {
    67.             var asyncOperationHandle = Addressables.LoadAssetsAsync<TextAsset>(labelName, null);
    68.  
    69.             while (asyncOperationHandle.IsDone == false)
    70.                 yield return null;
    71.  
    72.             if (asyncOperationHandle.Status == AsyncOperationStatus.Failed)
    73.                 yield break;
    74.  
    75.             var datas = asyncOperationHandle.Result;
    76.  
    77.             foreach (var dataBytes in datas)
    78.             {
    79.                 Debug.Log($"Loading {dataBytes.name}");
    80.                 var di = DataInfo.TransformByte2DataInfo<T>(dataBytes.bytes);
    81.  
    82.                 storage.Add(di.Name, di);
    83.             }
    84.  
    85.             while (_counterUnityResourcesLoading > 0)
    86.                 yield return null;
    87.         }
    88.  

    I don't understand if it's an error from me or from addressables

    Help !

    Thanks
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    From looking at your code, all you're ever actually loading is a <TextAsset>, and yet your error is an inability to load an AnimationClipSprite. You paste the wrong loading code?

    Also, you can look at sprite loading here: https://github.com/Unity-Technologies/Addressables-Sample, though the sprite sample is a bit problematic at the moment.
     
  3. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hi, thanks for answer.

    Indeed I forget a part :/

    For simpler duplication, I made a simple project and I have found the bug, the case number is 1160106

    I paste the loading code here anyway :

    Code (CSharp):
    1.  
    2.     private void LoadObjectInternal<T>(string objectName, Action<T> assignT) where T : Object
    3.     {
    4.         AsyncOperationHandle<T> handle;
    5.         Debug.Log("Try to load " + objectName);
    6.  
    7.         handle = Addressables.LoadAssetAsync<T>(objectName);
    8.         handle.CompletedTypeless += h => { Debug.Log("Loaded " + objectName); };
    9.  
    10.         if (handle.IsDone)
    11.             assignT(handle.Result);
    12.         else
    13.             handle.Completed += operationHandle => assignT(operationHandle.Result);
    14.     }
    15.  
     
  4. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    This bug and loading sprite problem is very a hard corner for my isometric 2D game :/
    I can't play my game from this git branch since I switch to addressables :(