Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

InvalidKeyException or 'Unknown error' when attempting to load mesh assets

Discussion in 'Addressables' started by dinomut, Jan 10, 2020.

  1. dinomut

    dinomut

    Joined:
    Jul 17, 2019
    Posts:
    2
    I'm trying to use the Addressables system to load mesh assets at runtime. My Unity project is running on 2019.2.17f1, on Windows 10, with Addressables System v1.5. I'm using 'Use Asset Database' setting. I have generated a collection of mesh assets that are addressed thusly:



    I have the addresses stored in a SQLite database and am retrieving lists of asset addresses via queries. Once the addresses have been received, the async load operation is called thusly (I know one can use LoadAssetsAsync for lists of assets but I am trying to get the singleton case working first):

    Code (CSharp):
    1.  
    2.  
    3.             int nAssets = nearbyAssets.Count;
    4.  
    5.             _mesh = new Mesh();
    6.             for(int i = 0; i < nAssets; i++)
    7.             {
    8.                 AddressQueryResult queryResult = nearbyAssets[i];
    9.                 AsyncOperationHandle loadHandle = Addressables.LoadAssetAsync<GameObject>(queryResult.Address);
    10.                 loadHandle.Completed += OnKeyLoaded;
    11.             }
    12.  
    The callback has zero functionality at the moment as I'm still debugging the async load operation:
    Code (CSharp):
    1. private void OnKeyLoaded(AsyncOperationHandle handle)
    2.         {
    3.             Debug.Log("check handle contents");
    4.  
    5.             CombineInstance[] combines = new CombineInstance[1];
    6.             //combines[0].mesh = loadedMesh;
    7.             _mesh.CombineMeshes(combines);
    8.         }
    9.  
    So far I have never made it to the callback without exceptions being thrown for every async load operation called.
    If I set the load operation to be "Addressables.LoadAssetAsync<GameObject>(queryResults.Address)" then I get an InvalidKeyException, even though I know that the key string exactly matches the intended address:


    If I set the load operation to be "Addressables.LoadAssetAsync<Mesh>(queryResults.Address)"
    then I get a weird message saying "Unknown error in AsyncOperation":


    The second result seems closer to correct, since the Addressables module is apparently finding the correct asset with the given key and then running into an issue with loading it, but I am totally lost as to how to debug an 'Unknown error'. The event viewer gives no hints as to the cause either.
    Has anyone encountered this before? Is the Addressables system simply unable to load Mesh assets at this time?
     
  2. dinomut

    dinomut

    Joined:
    Jul 17, 2019
    Posts:
    2
    UPDATE:
    I have since created a base case in which the Addressable system fails to load even the most basic prefab object.

    First, I created a default cube GameObject using the Create menu. I then turned this cube into a prefab called "DumbCube". It has been set to addressable and given the address "mostbasic":


    I then created the most basic Addressable loader possible with this code:
    Code (CSharp):
    1. public class SimpleAddressableLoader : MonoBehaviour
    2. {
    3.     public GameObject asset;
    4.  
    5.     void Start()
    6.     {
    7.         Addressables.LoadAssetAsync<GameObject>("mostbasic").Completed += SimpleAddressableLoader_Completed;
    8.     }
    9.  
    10.     private void SimpleAddressableLoader_Completed(AsyncOperationHandle<GameObject> obj)
    11.     {
    12.         asset = Instantiate(obj.Result);
    13.     }
    14. }
    Again, like before, I get an "Unkown error in AsyncOperation" exception before the callback is reached, meaning once again that the asset is being found and then something wacky is happening in the loading process.
    With so few moving parts in this base case, I am led to believe that something in my project settings is to blame.

    EDIT: I tried this same base case in a blank project with only the Addressables package imported and the asset loads just fine. So there is some sort of issue in my project that is causing the Addressables module to fail loading any assets.
     
    Last edited: Jan 10, 2020
  3. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    Hello all, another dev on the team working with @dinomut here.

    Like he said his most basic example works fine in an empty project. (unity 2019.2.17 addressables 1.5.0)

    but when we try in our larger existing project loading anything from addessables in any mode or way just returns 2 exceptions:

    Exception encountered in operation Resource<GameObject>(Cube.prefab): Unknown error in AsyncOperation
    UnityEngine.ResourceManagement.Util.DelayedActionManager:LateUpdate() (at Library/PackageCache/com.unity.addressables@1.5.0/Runtime/ResourceManager/Util/DelayedActionManager.cs:169)


    and

    Exception encountered in operation UnityEngine.AddressableAssets.Initialization.InitializationOperation, result='', status='Succeeded' - Chain<GameObject>: ChainOperation of Type: UnityEngine.GameObject failed because dependent operation failed
    Unknown error in AsyncOperation
    UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1:OnWrappedCompleted(AsyncOperationHandle`1)
    DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.5.0/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.5.0/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)


    I've been tracing and step through debugging all morning trying to figure out what might be causing the issue and it seems the exceptions are thrown when ProvideHandle.Complete is called from any of the ResourceProviders.

    Any suggestions or advice on how to proceed or thoughts on what might be causing the issue would be much appreciated.
     
  4. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    GB_HB likes this.