Search Unity

Question AssetBundle error when trying to do a remote content update on string tables

Discussion in 'Localization Tools' started by jake_card, Aug 29, 2022.

  1. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    I've been following the examples laid out in this post (and using the remote content update steps from this post). I've got everything working, except that after switching to an empty scene, releasing all the string tables, and completing the download, I get the following error (also posted here if the formatting is too hard to read):

    Code (CSharp):
    1. /*
    2. The AssetBundle 'http://localhost:58869/localization-assets-shared_assets_all.bundle' can't be loaded because another AssetBundle with the same files is already loaded.
    3. UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
    4. UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:GetAssetBundle () (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceProviders/AssetBundleProvider.cs:314)
    5. UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider/InternalOp:LoadBundleFromDependecies<UnityEngine.ResourceManagement.ResourceProviders.IAssetBundleResource> (System.Collections.Generic.IList`1<object>) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceProviders/BundledAssetProvider.cs:37)
    6. UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider/InternalOp:Start (UnityEngine.ResourceManagement.ResourceProviders.ProvideHandle) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceProviders/BundledAssetProvider.cs:56)
    7. UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider:Provide (UnityEngine.ResourceManagement.ResourceProviders.ProvideHandle) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceProviders/BundledAssetProvider.cs:225)
    8. UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1<UnityEngine.Localization.Tables.SharedTableData>:Execute () (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/ProviderOperation.cs:232)
    9. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.SharedTableData>:InvokeExecute () (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:469)
    10. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.SharedTableData>:Start (UnityEngine.ResourceManagement.ResourceManager,UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle,DelegateList`1<single>) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:464)
    11. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.SharedTableData>:UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation.Start (UnityEngine.ResourceManagement.ResourceManager,UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle,DelegateList`1<single>) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:531)
    12. UnityEngine.ResourceManagement.ResourceManager:StartOperation (UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation,UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceManager.cs:458)
    13. UnityEngine.ResourceManagement.ResourceManager:ProvideResource (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,System.Type,bool) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceManager.cs:419)
    14. UnityEngine.ResourceManagement.ResourceManager:ProvideResource<UnityEngine.Localization.Tables.SharedTableData> (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceManager.cs:438)
    15. UnityEngine.AddressableAssets.AddressablesImpl:LoadAssetAsync<UnityEngine.Localization.Tables.SharedTableData> (object) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/AddressablesImpl.cs:613)
    16. UnityEngine.AddressableAssets.Addressables:LoadAssetAsync<UnityEngine.Localization.Tables.SharedTableData> (object) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/Addressables.cs:817)
    17. UnityEngine.Localization.AddressablesInterface:LoadAssetFromGUIDInternal<UnityEngine.Localization.Tables.SharedTableData> (string) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Addressables/AddressablesInterface.cs:60)
    18. UnityEngine.Localization.AddressablesInterface:LoadAssetFromGUID<UnityEngine.Localization.Tables.SharedTableData> (string) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Addressables/AddressablesInterface.cs:50)
    19. UnityEngine.Localization.Settings.LocalizedDatabase`2<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>:GetSharedTableData (System.Guid) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedDatabase.cs:542)
    20. UnityEngine.Localization.LoadTableOperation`2<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>:Execute () (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Operations/LoadTableOperation.cs:58)
    21. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:InvokeExecute () (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:469)
    22. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:Start (UnityEngine.ResourceManagement.ResourceManager,UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle,DelegateList`1<single>) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:464)
    23. UnityEngine.ResourceManagement.ResourceManager:StartOperation<UnityEngine.Localization.Tables.StringTable> (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>,UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle) (at PATH/Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceManager.cs:452)
    24. UnityEngine.Localization.Settings.LocalizedDatabase`2<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>:GetTableAsync (UnityEngine.Localization.Tables.TableReference,UnityEngine.Localization.Locale) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedDatabase.cs:261)
    25. UnityEngine.Localization.Settings.LocalizedDatabase`2<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>:GetTableEntryAsync (UnityEngine.Localization.Tables.TableReference,UnityEngine.Localization.Tables.TableEntryReference,UnityEngine.Localization.Locale,UnityEngine.Localization.Settings.FallbackBehavior) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedDatabase.cs:510)
    26. UnityEngine.Localization.LocalizedString:HandleLocaleChange (UnityEngine.Localization.Locale) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Localized Reference/LocalizedString.cs:745)
    27. UnityEngine.Localization.LocalizedString:ForceUpdate () (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Localized Reference/LocalizedString.cs:643)
    28. UnityEngine.Localization.LocalizedString:add_StringChanged (UnityEngine.Localization.LocalizedString/ChangeHandler) (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Localized Reference/LocalizedString.cs:129)
    29. UnityEngine.Localization.Components.LocalizeStringEvent:RegisterChangeHandler () (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Component Localizers/LocalizeStringEvent.cs:154)
    30. UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable () (at PATH/Library/PackageCache/com.unity.localization@1.3.2/Runtime/Component Localizers/LocalizeStringEvent.cs:101)
    31. */
    I imagine this is probably some sort of Addressables configuration issue, but I've spent a lot of time digging through posts on the Addressables forum with no luck, so I'm hoping someone here may have some idea of what I might be doing wrong.

    Also worth noting: if I just update the catalog without trying to download any bundles and then restart the game, the strings are updated perfectly, so I know the whole remote side is set up properly. I just need to figure out how to get them to update without a full restart.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    This sounds like one of the operations that uses the asset bundle has not been released. Are you able to share the project or an example project so I can debug it? It can be tricky finding the operation that is still holding on to it.
     
  3. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Unfortunately I can't share the project, but it's good to know that it seems like an unreleased operation. Are you specifically talking about an unreleased string table, or something else? And any pointers on how you'd go about debugging it?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Yes likely a string table. Are you just using LocalizedStringEvents or do you have any scripts getting values?
    You can try using the addressables profiler tool which may show which string table is still in use.
     
  5. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    We've got both LocalizedStringEvents and scripts getting values.

    Is it possible to use the Addressables Profiler tool on a build? As far as I know, I need to make a build to test these string table updates.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
  7. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Oh that's good to know! I haven't used this tool before so it'll take me some time to get the hang of it, but I appreciate the info.

    In the meantime, I've tried using
    LocalizationSettings.StringDatabase.IsTableLoaded
    to validate before and after the
    ReleaseTable
    calls, and I can confirm that all my tables are returning true before the releases, and all of them are returning false afterwards. Unless I'm misunderstanding something, this leads me to believe that all string tables are being properly released. Is there something else I should be checking?
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    That just means the string database is not holding on to them. It doesn't guarantee that addressables has released them. It's still possible for something to be holding on to the table.
     
  9. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Makes sense, thanks!

    Just did some profiling, and if I'm understanding the display right, it looks like our MainMenu string table (which contains the strings for the scene we start on) is indeed being held onto. When I remove the LocalizeStringEvent components from that scene, it looks like it's no longer being held onto.

    Here's a screenshot of how the LocalizeStringEvent is being configured. Does it look like I'm doing anything wrong here?
     

    Attached Files:

  10. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Also, I can confirm that when I remove these LocalizeStringEvents from the main menu, the content update works on the strings that exist elsewhere in the game! So somehow, it just seems like these LocalizeStringEvents are keeping the table held onto, even though the scene they're in has been replaced. Any idea how to fix this?
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    When you change scene the LocalizeStringComponents OnDisable should be called which releases the operation. Can you try manually disabling the component when you change the scene?
     
  12. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Will do! I have to head out for the day, but I’ll try it first thing tomorrow and post an update then. Thanks for all your help!
     
    karl_jones likes this.
  13. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Currently trying to do this now! However,
    LocalizeStringEvent.OnDisable()
    is protected, so I tried setting the
    LocalizeStringEvent.StringReference
    to empty scene change instead (since this results in
    ClearChangeHandler()
    getting called, which is all
    OnDisable()
    does), as well as
    Destroy()
    ing the LocalizeStringEvent, but it looks like the string table is still being held onto when I do either/both of these. Any other ideas?
     
    Last edited: Aug 30, 2022
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    I suspect this could be a bug. I'll see if I can reproduce it locally.
     
  15. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Awesome, thank you!
     
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    It is indeed a bug. I have created a bug here.
    https://issuetracker.unity3d.com/issues/table-is-not-being-released-when-calling-releasetable

    I can see the problem. It seems to be a dependency from when we load the resource locations. We are holding on to this which is also holding on to the table. Ill get it fixed in the next release, which is due in October.
    The only way I can see to fix it now would be to make a change to the localization package. You can move it from the packagecache directory to the project Packages directory and then comment out line 93 Runtime\Operations\LoadTableOperation.cs
    AddressablesInterface.Acquire(tableResourceOp);

    That fixed it for me, we should not be holding on to that operation.
     
    Last edited: Aug 30, 2022
  17. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Thanks a bunch Karl! Unfortunately, commenting out
    AddressablesInterface.Acquire(tableResourceOp);
    isn't fixing it for me, according to the profiler - it looks like my MainMenu string table is still being held onto with this commented out (and I threw some debug logs into the method to ensure it was actually picking up my changes).
     
  18. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Is this table preloaded? Can you try disabling the preloading, maybe there's an issue in that as well.
     
  19. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Good news! Not only does disabling preloading fix it, it looks like it fixes it even without commenting out the
    AddressablesInterface.Acquire(tableResourceOp);
    line!

    I'm gonna do a little more testing just to make sure, but it looks like my issue might be fixed without any patches/updates!
     
  20. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Yep, I can fully confirm, my issue is fixed by just disabling preloading on the MainMenu table!

    Thanks so much for all your help! I'll look forward to the October update, but in the meantime, this should be totally fine to move forward with.
     
    karl_jones likes this.
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Thanks for checking. I'll make sure we also look at preloading.
     
    jake_card likes this.
  22. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Hey, I have done some further digging into the preloading issue. The code seems correct however unloading is done on a per asset bundle basis. So if you have 2 tables in the same Group both being preloaded and you then call Release on 1 of them, it won't be unloaded until all the tables have been released. Did you have another table being preloaded that was not unloaded at the time?
     
  23. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Hey! All 22 of my string tables had preloading enabled, and I was calling Release on all of them in alphabetical order (MainMenu was somewhere in the middle).

    If my understanding of the profiler is correct, they were all being successfully unloaded except MainMenu.
     
  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    I believe, in the end, that there were a few more parts that were holding on to the tables during preload. I have a possible fix which is just going through testing now.
     
    jake_card likes this.
  25. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Awesome! Thanks for looking into it.
     
    karl_jones likes this.