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

Question Addressables instantiateasync does not create object on some devices.

Discussion in 'Addressables' started by neph_2, Apr 16, 2023.

  1. neph_2

    neph_2

    Joined:
    Jul 23, 2013
    Posts:
    3
    Good day

    I made addressables instantiateasync and it works for my editor and other platform builds well. I have builded links to individual animations and on 95%+ devices including android, linux,macOS,desktop it works totally fine, smooth, no peak or performance drops.

    Here is the important code in short (this is a method called moments before the objects are needed & put aside):

    Code (CSharp):
    1.  
    2. AsyncOperationHandle<GameObject> goHandle = UnityEngine.AddressableAssets.Addressables.InstantiateAsync("Assets/ALL_ANIMATIONS/SPECIAL_SCENE_ANIMATIONS/" + name + ".prefab",GameObject.Find("LOCS").transform);
    3.  
    4.         yield return goHandle;
    5.         if (goHandle.Status == AsyncOperationStatus.Succeeded) {
    6.             if (goHandle.Result != null) {
    7.                   //success and code after spawns it and re-positions anims.
    8.             }
    9.         }
    10.  
    But some people have reported to us it doesn't load the objects (animations in our case) for some reason. I have spend last week seaching through the forums, checking link build in unity, re-building it, different packages and looking for a possible reason. The problem is some people still experience the issues, and there is no error in the debugger log (of the special builded solution for debug in this case).

    I have talked to some people who used it and because we were not able to replicate the issue (on 10 devices we tried it works fine) so I asked even chatGPT to name possible reasons and checked them one by one and spend hours discussing possible explainations in detail step by step from memory usage to process of finding the individual files, their type definition and object allocation, but couldn't find solution myself so I humbly and desperately ask for advice or help.

    I came to conclusion that:
    1 - I am missing something simple (I am an idiot) and there is a reasonable logical explaination
    2 - It is localization related issue (But I don't know how to for example make path to work everywhere \ vs / you know)
    3 - Addressables are not 100% working at the moment (there may be some bugs causing this inside them, like a timeout, issue during object ram allocation) and are reliable only in 99% in current cases (or based on system specific configuration).

    I would be gratefull for an advice or clue here.
    Thank you all I would really appreciate it.
     
  2. CheapMeow

    CheapMeow

    Joined:
    Mar 30, 2021
    Posts:
    4
    I just ran into a similar situation, and `InstantiateAsync` was able to execute without error and was able to return Succeeded. If I take handle.Result and print it to the console, the name of the object can also be displayed on the console, but when I run the game, I just can't see him.
    For my situation, the reason for this problem is that I executed `InstantiateAsync` when I have multiple scenes, and this object is instantiated into the currently active scene, which can be used `Debug.LogError(SceneManager.GetActiveScene().name );` to view the name of the currently active scene. Then I quickly unload the currently active scene in the code, so the objects I just instantiated are deleted along with the scene.
     
  3. neph_2

    neph_2

    Joined:
    Jul 23, 2013
    Posts:
    3
    Not sure if this might help but what we did to partially solve this problem was to initiate load like 10 seconds before the object was going to be needed and if it didn't load in 5 seconds then we requested it again and also at 0 when it was needed. We don't know why on some devices this ''timeout'' or something happened, but we have confirmed multiple cases when it happened. (roughly from 10.000 people around 50 experienced this problem.

    I can't confirm or reject this is a problem with InstantiateAsync or even InstantiateSync.