Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

(Case 1202034) InvalidKeyException on folder with label in Addressables 1.4.0

Discussion in 'Addressables' started by Dark_Templar, Dec 2, 2019.

  1. Dark_Templar

    Dark_Templar

    Joined:
    Jan 26, 2014
    Posts:
    5
    When i load several sprite assets from folder on Addressables 1.4.0 i have InvalidKeyException error. There is no error on Addressables 1.3.8 or with text assets.
     
  2. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    295
    definitely sounds like a bug, we'll look into it.
     
    Dark_Templar likes this.
  3. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    147
    I just updated to 1.4.0 from 1.1.10 today and ran into this.

    I was about to report it in the bug reporting tool but the tool showed this thread as possibly the same issue, so I'll comment here instead.

    I think it is the same issue, but I will provide some additional explanation and findings.

    For an example project, here is my Addressables Groups.
    upload_2019-12-9_21-11-9.png

    Here is my scene:
    upload_2019-12-9_21-11-46.png

    My "Sprite" GameObject has this script attached to it:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AddressableAssets;
    5.  
    6. public class Test : MonoBehaviour
    7. {
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.         LoadSprite();
    12.     }
    13.  
    14.     async void LoadSprite()
    15.     {
    16.  
    17.         var sprite = await Addressables.LoadAssetAsync<Sprite>("Assets/MyAssets/Textures/UnityLogo.png").Task;
    18.         this.GetComponent<SpriteRenderer>().sprite = sprite;
    19.     }
    20. }
    21.  
    Results when run:
    * For Simulate Groups (advanced): Works fine.
    * For Use Existing Build (requires built groups): After building it works fine.
    * For Use Asset Database (faster):

    Code (CSharp):
    1. Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.Sprite], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Assets/MyAssets/Textures/UnityLogo.png
    2. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:<.ctor>b__27_0(AsyncOperationHandle)
    3. DelegateList`1:Invoke(AsyncOperationHandle) (at Library/PackageCache/com.unity.addressables@1.4.0/Runtime/ResourceManager/Util/DelegateList.cs:69)
    4. UnityEngine.AddressableAssets.Initialization.<>c__DisplayClass13_0:<LoadContentCatalogInternal>b__0(AsyncOperationHandle`1)
    5. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.4.0/Runtime/ResourceManager/Util/DelegateList.cs:69)
    6. UnityEngine.ResourceManagement.ChainOperation`2:OnWrappedCompleted(AsyncOperationHandle`1)
    7. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.4.0/Runtime/ResourceManager/Util/DelegateList.cs:69)
    8. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    9. MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.4.0/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)
    10.  
    Current workaround is to use Simulate Groups for development for now .. which makes development slower because the "Calculate Asset Dependencies" step.

    I also confirmed that version 1.3.8 doesn't have this issue.
     

    Attached Files:

    Last edited: Dec 9, 2019
  4. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    295
    hmm... interesting. Thanks for the info. I'm going to try and track down what might have changed between 1.3.8 and 1.4.0
     
    KB73 likes this.
  5. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    147
    Has this been fixed in 1.5.0??
    This should be high priority as for anyone who adds folders as Addressables will not be able to work with Fast play mode!
     
  6. pshtif

    pshtif

    Joined:
    Mar 6, 2017
    Posts:
    8
  7. cemleme

    cemleme

    Joined:
    Mar 24, 2017
    Posts:
    26
    it still happens on 1.7.4

    took me a lot of time to understand the problem after updating addressables from an older version.

    as it wasn't fixed for so long, can we assume it's not a bug and we are not supposed to use folders with sprite assets as addressables?

    does any one recommend another method? I don't want to create a sprite atlas for my current case as none of the sprites will show up together and I don't want to load the whole sprite atlas into the memory
     
    magmagma likes this.
  8. magmagma

    magmagma

    Joined:
    Oct 27, 2017
    Posts:
    23
    It is very much a bug, and the Unity guys themselves have admitted to it. They just haven't fixed it...
    But hopefully very soon.
     
    chanon81 likes this.
  9. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    147
    Fast Play Mode with addressable folders is practically a core feature required for quick development if you use addressable folders.

    And I believe making folders addressable rather than adding assets one by one is a best practice too cause with Addressable bugs, sometimes some Addressables will vanish and it will be hard to detect if you have too many Addressable entries. Also it allows you to easily use file path as Addressable key.

    I think the main reason Unity are so slow at fixing somewhat critical bugs like this is they don't actually use Unity to develop games, so they don't really understand developer's pain. And I assume most of us are paying customers, so it is somewhat aggravating to see a bug like this being unfixed for almost 4 months now.
     
  10. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    147
    You can go back to 1.3.8 or:

    KB73 recommended this workaround:
    https://forum.unity.com/threads/addressables-1-4-0-bug.791342/#post-5611261

    You have to fix Addressables code yourself here (from rg_johnokane):
    https://forum.unity.com/threads/addressables-1-4-0-bug.791342/#post-5421225

    ie. someone fixed Addressable's code for them since 2 months ago but they still haven't put it in a release .. and yeah it might be a 'hack' but Fast Play Mode is just for development so put in temporary fix is better than nothing.

    I haven't done that yet and still using 1.3.8 as it is still working ok for me and I don't want to pollute my git history with the whole addressables source code.

    Nearer my game's release if it is still not fixed then I will have to do it.
     
    Last edited: Mar 26, 2020
  11. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    295
    Hey all, we actually fixed an issue with location generation (that was manifesting in folders) in Fast Mode/Use Asset Database mode in 1.7.4 (but use 1.7.5 as 1.7.4 introduced a bug with unknown types in a Resources folder). @cemleme you're saying you still saw the same invalid key issue in 1.7.4?
     
  12. cemleme

    cemleme

    Joined:
    Mar 24, 2017
    Posts:
    26
    hello @DavidUnity3d

    yes I confirm i had the invalid key in 1.7.4. then I got back to 1.3.8 and it is working great

    now just for testing, I updated it to 1.7.5

    and this is the error I receive:

    Code (CSharp):
    1. Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.Sprite], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=DetailedIcons/Nozzle.png, Type=UnityEngine.Sprite
    2. UnityEngine.AddressableAssets.Addressables:LoadAssetAsync(Object)
    3.  
    as I said this is after simply upgrading the addressables, without changing anything else

    also tried rebuilding the addressables and the result is same
     
  13. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    449
    I'm running into the same issue at the moment.
    I've got a
    AssetReferenceSprite
    which its asset is under a folder that is in a bundle group.
    Loading it will cause it to throw an invalid key exception.
    Using 1.7.5 on Unity 2019.3.7
     
unityunity