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

(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. davidla_unity

    davidla_unity

    Unity Technologies

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

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    168
    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. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    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:
    168
    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:
    12
  7. cemleme

    cemleme

    Joined:
    Mar 24, 2017
    Posts:
    30
    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:
    41
    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:
    168
    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:
    168
    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. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    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:
    30
    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:
    1,058
    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
     
  14. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    These sprites that you're trying to load, are they part of a SpriteAtlas?
     
  15. cemleme

    cemleme

    Joined:
    Mar 24, 2017
    Posts:
    30
    no they are not. when we load the spriteatlas it works (I have both of the cases in my project)
     
  16. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    168
    David, this problem is easily reproducible using the project files I attached in the post above (4 months ago):
    https://forum.unity.com/threads/cas...el-in-addressables-1-4-0.786908/#post-5262116

    No need to ask us for more details. Just download that and run it using Play Mode Script "Use Asset Database (faster)".

    Using Addressables 1.3.8 it runs fine. Using Addressables 1.7.5 it gives an InvalidKeyException.

    Thus we are stuck with 1.3.8 for months now.
     
    Matew likes this.
  17. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    Still getting InvalidKeyException from 1.16 and above. 1.15 works fine
     
  18. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    The only way to solve this problem for me was to enable "Force Unique Provider" for all of my groups and enable "Simulate addressables groups". Use Asset Database mode is completely broken for me.