[webgl] WebGLPlayer does not support synchronous Addressable loading.

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

build.framework.js:3 Exception: WebGLPlayer does not support synchronous Addressable loading.  Please do not use WaitForCompletion on the WebGLPlayer platform.
  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

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/com.unity.localization@1.4/manual/Scripting.html#using-asyncoperationhandle
https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/SynchronousAddressables.html
https://docs.unity3d.com/Packages/com.unity.addressables@1.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

Ok I’m still kind of stuck. I commented out every GetLocalizedString except one.

I have some kind of network manager that has this

IEnumerator Start()
    {
        yield return LocalizationSettings.InitializationOperation;
        Debug.Log(LocalizationSettings.SelectedLocale);
        Start2();
    }

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.

string key = "botchat" + UnityEngine.Random.Range(1, 29);
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.

If your string table is not marked as preload then it will be loaded on demand when its first used. This is likely what’s happening here. Try marking the table as preload. String Tables | Localization | 1.4.5

Hmm it doesn’t have that config area to the right.

Also this

Oh damn, found it, that’s hidden well. :slight_smile:

1 Like

[quote=“Roest, post:7, topic: 908347, username:Roest”]
Oh damn, found it, that’s hidden well. :slight_smile:
[/quote] where to look for this window?)

Not sure if you’re still interested in this, but maybe it could help someone else:
9597784--1360513--upload_2024-1-22_21-2-1.png

2 Likes

We have moved the option in 1.5 so its easier to find.