Search Unity

Question Unable to load asset of type StringTable - non-deterministically

Discussion in 'Localization Tools' started by Aurelinator, Jun 2, 2022.

  1. Aurelinator

    Aurelinator

    Joined:
    Feb 27, 2012
    Posts:
    19
    Hi there,

    I've been working on our game's localization pipeline for a while, and now I seem to have run into a very strange bug that I cannot figure out. It seems to be non-deterministic build-time issue, because sometimes builds will have this bug, and sometimes they won't.

    We have a system, that on start, loads a subtitle table. I've simplified my code for this example:


    Code (CSharp):
    1.         private IEnumerator Start()
    2.         {          
    3.             Debug.Log("[Subtitles] Waiting for Localization Settings to Initialize");
    4.             yield return LocalizationSettings.InitializationOperation;
    5.             Debug.Log("[Subtitles] Registering for Localization Table Change");
    6.             localizationTable.TableChanged += TableChanged;
    7.         }
    In the logs, I see the following immediately after the "Registering for localization Table Change"


    Code (CSharp):
    1.  
    2. Should not occur! Internal logic error: please report bug.
    3. (Filename: C:\buildslave\unity\build\Runtime/Scripting/ManagedReference/SerializableManagedRefTransfer.cpp Line: 30)
    4.  
    5. [Error] System.Exception: Unable to load asset of type UnityEngine.Localization.Tables.StringTable from location Assets/Localization/Tables/Subtitles_fr.asset.
    6. ...
    7. UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception)
    8. System.Action`2:Invoke(T1, T2)
    9. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception)
    10. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
    11. UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1:ProviderCompleted(T, Boolean, Exception)
    12. UnityEngine.ResourceManagement.ResourceProviders.InternalOp:CompleteOperation()
    13. System.Action`1:Invoke(T)
    14. UnityEngine.AsyncOperation:InvokeCompletionEvent()
    15.  
    16.  
    17.  
    18.  
    19. [Error] System.Exception: Unable to load asset of type UnityEngine.Localization.Tables.StringTable from location Assets/Localization/Tables/Subtitles_fr.asset.
    20. ...
    21. UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception)
    22. System.Action`2:Invoke(T1, T2)
    23. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception)
    24. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
    25. UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1:ProviderCompleted(T, Boolean, Exception)
    26. UnityEngine.ResourceManagement.ResourceProviders.InternalOp:CompleteOperation()
    27. System.Action`1:Invoke(T)
    28. UnityEngine.AsyncOperation:InvokeCompletionEvent()
    29.  
    I checked out the final build files, and sure enough, I was able to find the appropriate addressable asset bundle in the _data/streaming assets/aa/... by cracking it open with an asset bundle extractor tool and checking that the data in say, French does exist.

    So here's the conundrum:

    This happens sometimes. I keep thinking I fixed it, only for it to show up again later. It happens with other tables, like if I try to load german subtitles. Same thing. It does not repro for our English data. Our pseudoloc system is working just fine by piping through the English information.

    A few notes:
    - Our builds clean the addressables cache and completely rebuild it each time.
    - I have run the addressables analyze and there is no issue.
    - Here is the current state of the addressable groups, so the things seem poised well (I've hidden some groups so as to hide the name of what we're working on)
    upload_2022-6-2_11-51-1.png
    - This is the asset bundle schema for one of the bundles:
    upload_2022-6-2_11-54-34.png

    We aren't currently doing anything remote; just trying to test out loading of things baked into the client. Sometimes, certain builds from the same commit just "work", and I'm able to get the table loaded and able to see the content translated. It will work for that build. But I might build from the same commit, and it will spit out the errors I mentioned above; and that is just messed up for the time being.

    What in the world could I do to even investigate this? I've confirmed the bundle IS in the project and is accessible, but I cannot for the life of me understand why this is failing like this from time to time. Do you have any suggestions?

    Thanks!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    If you are using the TableChanged event then you don't need to worry about the InitializationOperation, it will handle that for you.

    What version of Unity are you using? This looks like something caused by SerializeReference. Are you using any custom Metadata on the tables? Can you try updating to the latest patch version of Unity, its possible the issue is fixed? These issues look related to serialization. Perhaps the Addressables are being built for the wrong platform? Make sure to switch platforms before you do the build.
     
  3. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    96
    I've stumbled across a very similar issue. SerializeReference caused the issue for me indeed!

    We've recently introduced custom Metadata, that is only meant for tracking changes to loca entries. Because of that, we put it into the Editor assembly. Of course, this assembly is not present in the build, which resulted in the exception mentioned above.

    We ended up having a script, that removes the metadata before we build and then we re-add them afterwards using git.
     
    karl_jones likes this.
  4. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    96
    @karl_jones
    What would be nice though, if metadata classes could be marked to be excluded from the (addressable) build, so that development metadata (e.g. the Comment metadata is meant do be that I guess) won’t end up in the build.

    It works the script way, but feels hacky to temper with yaml files using find/sed.
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    I'll speak to the addressables team and see if they have any ideas.
     
    magnetic_scho likes this.