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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug "AddressableAssets.InvalidKeyException" after update to 1.14.2

Discussion in 'Addressables' started by Peter77, Aug 25, 2020.

Thread Status:
Not open for further replies.
  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,447
    Upgrading Addressables from 1.13.1 to 1.14.2 (2018.4.22f1) broke our game and loading no longer works in the editor. Unity displays the following error message:
    Code (CSharp):
    1. Exception encountered in operation CompletedOperation, status=Failed, result=UnityEngine.ResourceManagement.ResourceProviders.SceneInstance : Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=8fee809d8b6a25342bb9b513a1f8aada, Type=UnityEngine.ResourceManagement.ResourceProviders.SceneInstance
    2. UnityEngine.AddressableAssets.Addressables:LoadSceneAsync(Object, LoadSceneMode, Boolean, Int32)
    3. MyCompany.Framework.<LoadCoroutine>d__22:MoveNext() (at assets/plugins/MyCompany_framework/Loading.cs:275)
    4. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    The Android build seems to work though.

    I'm using the "Use Asset Database" play mode script option in the editor. Downgrading to 1.13.1 gets rid of the error.
     
    awallick-sd and KyleOlsen like this.
  2. KyleOlsen

    KyleOlsen

    Joined:
    Apr 3, 2012
    Posts:
    237
    It seems (in our case) addressables added to groups by folder no longer work when "Use Asset Database" is enabled. If you do a build and swap over to "Use Existing Build" things begin loading again in the editor.
     
    awallick-sd likes this.
  3. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    Hm, I wonder if this has anything to do with the fix to an issue I reported, where Enter Play Mode time went up from 5-6 seconds to about a minute on our project, spent scanning child items. It was fixed on 1.14.2.
     
  4. awallick-sd

    awallick-sd

    Joined:
    May 29, 2019
    Posts:
    13
    We're seeing the same thing @KyleOlsen - Addressables directly added to the groups load in "Use Asset Database" mode, but ones added implicitly via folders do not (with the InvalidKeyException error). Both load properly in "Simulate Groups".
     
  5. joe_nk

    joe_nk

    Joined:
    Jan 6, 2017
    Posts:
    67
    Seeing the same issue when calling Addressables.GetDownloadSizeAsync with a list of keys returned by
    Addressables.InitializeAsync()
     
  6. awallick-sd

    awallick-sd

    Joined:
    May 29, 2019
    Posts:
    13
    FWIW this bug is actually preventing our team from updating from 2019.4.6 to Unity 2019.4.9 (we were unable to upgrade to 7 and 8 due to the Android black screen bug).

    Our game started freezing on device on upgrading to Unity 2019.4.9 with Addressables 1.13.1. I found the freeze was happening on a line about loading an asset bundle asynchronously. On 1.14.1 the freeze no longer happens, but slows down our team's workflow significantly as we'd have to work in "Simulate Groups" mode.
     
  7. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    This is fixed in addressables 1.15.1. It was a specific asset ref + folder bug. From the changelog:

    • Fixed issue where AssetReference wasn't able to load Addressable assets in folders during AssetDatabase Mode.
     
    awallick-sd and Peter77 like this.
  8. joe_nk

    joe_nk

    Joined:
    Jan 6, 2017
    Posts:
    67
    GetDownloadSizeAsync still throws an exception when passing it the keys returned by Addressables.InitializeAsync(), using Addressables 1.15.1
     
  9. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    This sounds unrelated. What exception exactly, and what do you mean by "the keys returned by InitiializeAsync". The thing returned by Init is an AsyncOperationHandle<IResourceLocator>. I know our naming isn't the best, but just to be clear, an IResourceLocator is the thing that can find IResourceLocations. Locations are what you might feed into something like GetDownloadSize. A locator is what comes from loading a catalog.
     
  10. joe_nk

    joe_nk

    Joined:
    Jan 6, 2017
    Posts:
    67
    I just figured it was related because the issue didn't exist in 1.13.1, it only occurs when using the Play Mode Script, 'Use Asset Database' and it relates to directories marked as 'addressable'.

    InitializeAsync returns an IResourceLocator which itself contains an IEnumerable<object>. The following code:

    Code (CSharp):
    1. Addressables.InitializeAsync().Completed += locatorHandle => {
    2.     if (locatorHandle.Status == AsyncOperationStatus.Succeeded) {
    3.         Addressables.GetDownloadSizeAsync(locatorHandle.Result.Keys).Completed += downloadSizeHandle => {
    4.             if (downloadSizeHandle.Status == AsyncOperationStatus.Succeeded) {
    5.                 // Success download size is downloadSizeHandle.Result
    6.             }
    7.         };
    8.     }
    9. };
    Emits the following exception:

    When
    fonts.latin
    is a folder marked as addressable:



    This is essentially (stripped down) the process we go through in order to have the player download all required bundles on first launch for our game. After grabbing the download size and informing the user the amount they need to download, we pass the keys on to Addressables.DownloadDependenciesAsync. If there's a better way to 'Download everything' please do tell.

    For what it's worth, this is super easy to work around - we obviously don't need to download anything when running in Use Asset Database mode, so this chunk of code can just be skipped. But in 1.13.1 we didn't require this conditional. It's handy to have each Play Mode Script behave the same under identical API calls.

    Thanks
     
    Last edited: Aug 31, 2020
  11. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    ah, I see what's happening. The key change we made to Use Asset Database Mode, that actually makes it fast to enter play mode is that we don't generate the catalog (keys) up front. Doing that was slow and costly, and not actually needed if you are in this mode.

    I'd suggest something like (I have not compiled this, just typing straight here)

    Code (CSharp):
    1. if (locatorHandle.Status == AsyncOperationStatus.Succeeded &&
    2.     locatorHandle.Result.Keys.Count > 0)
     
  12. joe_nk

    joe_nk

    Joined:
    Jan 6, 2017
    Posts:
    67
    If Keys was empty there would be no InvalidKey exception.
     
  13. joe_nk

    joe_nk

    Joined:
    Jan 6, 2017
    Posts:
    67
    Yep, locatorHandle.Result.Keys.Count() is very much > 0 when runnung in Use Asset Database mode
     
  14. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    142
    Last edited: Nov 11, 2020
  15. dong52008

    dong52008

    Joined:
    May 3, 2016
    Posts:
    4
    I got same error message. But my key was address.
    I foud file extension may be different in catalog file. Some file extensions are in uppercase and some in lowercase. Such as '.Prefab' and '.prefab'.
    It will leads to the inability to find the correct key through the address.
    I think this is a bug
     
Thread Status:
Not open for further replies.