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. Dismiss Notice

Bug Loading many items at once leads to deadlock

Discussion in 'Addressables' started by iyed, Mar 2, 2021.

  1. iyed

    iyed

    Joined:
    Aug 20, 2013
    Posts:
    5
    As the title states im encountering a deadlock/race condition issue with using the addressable system
    The issue happens when i load many addressables at once the SECOND time from a server (that means they are already cashed) without awaiting
    the code is something like this:
    foreach(var itemkey in items)
    {
    Gameobject loadingobj = await Library.loadItemAddressable("loadingicon");
    GameObject loadingobjinstance = instantiate(loadingobj);
    Library.loadItemAddressable(itemkey, delegate(GameObject obj){
    //callback after addressables are done loading
    //some iterations here including instantiate and destroying items from context
    Instantiate(obj);
    Destroy(loadingobjinstance);
    ......
    });
    }
    This is what the thread dump looks like like: https://pastebin.com/PRywKCyX
    Any Advice on how to resolve the issue or what im doing wrong?
     
    Last edited: Mar 3, 2021
  2. iyed

    iyed

    Joined:
    Aug 20, 2013
    Posts:
    5
  3. iyed

    iyed

    Joined:
    Aug 20, 2013
    Posts:
    5
    I forgot to mention that the callback sometimes have another loadAssetAsync, one of the scripts that i disabled removed the freeze on game start, it was a loadAssetAsync function in an initializing function I called on the callback of the items loading
    adding a coroutine with WaitForEndOfFrame on the initializing function of the item also removed the freeze i had on game start
     
    Last edited: Mar 5, 2021
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,795
    I'll flag this for the team to have a look! Which version of Addressables are you using?
     
  5. felipe-shida-playkids

    felipe-shida-playkids

    Joined:
    Sep 16, 2020
    Posts:
    13
    Any updates on this issue? We are experiencing something very similar. We ran the game and got the procdump of the moment it happens, it leads to a semaphore been acquired and never getting freed.

    At this point, we are only loading around 20 sprites (256x256), from remote bundles, packed separately using LZMA compression. The bundles are probably already downloaded, so it is coming from the disk, not from the network.

    We are on Unity Editor 2019.4.17 using addressables 1.16.19, the bug mostly happens on Windows, but it was seen on Android, iOS, and Mac as well, but with low frequency.

    Here goes the top of the callstack when it freezes.

    @unity_bill any ideas of what could it be?

    image (1).png image.png
     
    Last edited: Aug 10, 2021