Search Unity

Bug Hard crash on Android device, no errors in adb

Discussion in 'Addressables' started by Lucas-Hehir, Jul 17, 2020.

  1. Lucas-Hehir

    Lucas-Hehir

    Joined:
    Jul 2, 2014
    Posts:
    41
    I tried calling Addressables.LoadAssetsAsync from a static class (not a Monobehaviour/singleton) like this:

    Code (CSharp):
    1. public static async Task<bool> FetchPlayerProfiles(string assetLabel)
    2. {
    3.     var fetchOp = Addressables.LoadAssetsAsync<PlayerProfile>(new List<object> {assetLabel}, null, Addressables.MergeMode.None);
    4.  
    5.     if (!fetchOp.IsValid())
    6.     {
    7.        Debug.LogWarning($"[{assetLabel}] is not a valid asset operation key.");
    8.  
    9.        Addressables.Release(fetchOp);
    10.  
    11.        return false;
    12.     }
    13.  
    14.     await fetchOp.Task;
    15.  
    16.     if (fetchOp.Status == AsyncOperationStatus.Failed)
    17.     {
    18.        Debug.LogException(biomeFetchOp.OperationException);
    19.  
    20.        Addressables.Release(fetchOp);
    21.  
    22.        return false;
    23.     }
    24.  
    25.     if (fetchOp.Result == null)
    26.     {
    27.         Debug.LogWarning("Fetched asset list is null!");
    28.  
    29.         Addressables.Release(fetchOp);
    30.  
    31.         return false;
    32.     }
    33.  
    34.     currentProfiles = new List<PlayerProfile>(fetchOp.Result.OrderBy(profile => profile.id));
    35.  
    36.     return true;
    37. }
    And hot damn it did not like that one bit. Hard crash, no errors, just completely locks up. I guess you can't do this? I'm very new to async/await as well so I might be getting something about that wrong...

    I'm using
    Addressables 1.9
    Unity 2019.3.4f1
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Have you tried upgrading to a new version of Addressables to see if this still happens? If the issue persists, please file a but report for us. :)
     
  3. Lucas-Hehir

    Lucas-Hehir

    Joined:
    Jul 2, 2014
    Posts:
    41
    I'll bring it up to 1.12 some time soon and see if it does the same thing.
     
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Are you sure you are not basically locking up the main thread by awaiting there?
     
  5. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    The whole point of await is to not block the main thread, so that in itself should not be the cause. I don't see anything wrong with OP's code.
     
  6. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Yes, that is the point of it, but it depends on what synchronisation context it was run from.