Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question [webgl] WebGLPlayer does not support synchronous Addressable loading.

Discussion in 'Localization Tools' started by Roest_, Feb 6, 2023.

  1. Roest_

    Roest_

    Joined:
    Nov 3, 2014
    Posts:
    25
    So I have my localization working just fine in the editor. Just a few string tables and one sprite table.

    Tried a build and run and sure get this error in Chrome

    Code (CSharp):
    1. build.framework.js:3 Exception: WebGLPlayer does not support synchronous Addressable loading.  Please do not use WaitForCompletion on the WebGLPlayer platform.
    2.   at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () [0x00000] in <00000000000000000000000000000000>:0
    After half an hour of googling I still have no idea what to do differently to get aroundt this. Any help?

    unity 2021.3.1f1, localization plugin 1.4.3
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,275
    As the error says, you can not use WaitForCompletion in WebGL, this is a limitation of Addressables. If you are calling any synchronous methods (SelectedLocale, GetLocalizedString etc) then they will use WaitForCompletion internally if the data has not already been loaded. You need to let the localization system initialize before you use it by waiting on
    LocalizationSettings.InitializationOperation.

    https://docs.unity3d.com/Packages/c...ual/Scripting.html#using-asyncoperationhandle
    https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/SynchronousAddressables.html
    https://docs.unity3d.com/Packages/c....21/manual/SynchronousAddressables.html#webgl

    See the samples for ways to handle initialization
    https://docs.unity3d.com/Packages/com.unity.localization@1.4/manual/Package-Samples.html
     
  3. Roest_

    Roest_

    Joined:
    Nov 3, 2014
    Posts:
    25
    Ok I'm still kind of stuck. I commented out every GetLocalizedString except one.

    I have some kind of network manager that has this
    Code (CSharp):
    1. IEnumerator Start()
    2.     {
    3.         yield return LocalizationSettings.InitializationOperation;
    4.         Debug.Log(LocalizationSettings.SelectedLocale);
    5.         Start2();
    6.     }
    in Start2 it opens a websocket and gets game data including chat history. The chat history has some random bot chatter that is contained in a string table.

    Code (CSharp):
    1. string key = "botchat" + UnityEngine.Random.Range(1, 29);
    2. var op = LocalizationSettings.StringDatabase.GetLocalizedString("bot-chat", key);
    This fails on first load with the above error even though it is now clearly behind the InitializationOperation. Just have in a try catch now so it doesn't crash entirely.

    When I end turn after a few seconds and get new chat messages it works.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,275
  5. Roest_

    Roest_

    Joined:
    Nov 3, 2014
    Posts:
    25
    Hmm it doesn't have that config area to the right.
     

    Attached Files:

  6. Roest_

    Roest_

    Joined:
    Nov 3, 2014
    Posts:
    25
    Also this
     

    Attached Files:

  7. Roest_

    Roest_

    Joined:
    Nov 3, 2014
    Posts:
    25
    Oh damn, found it, that's hidden well. :)
     
    karl_jones likes this.
  8. OlegGrizzly

    OlegGrizzly

    Joined:
    Nov 25, 2019
    Posts:
    2
    where to look for this window?)
     
  9. fidgetik

    fidgetik

    Joined:
    May 16, 2018
    Posts:
    1
    Not sure if you're still interested in this, but maybe it could help someone else:
    upload_2024-1-22_21-2-1.png
     
    DMorock likes this.
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,275
    We have moved the option in 1.5 so its easier to find.