Multithreading and WebGL

I see that support for this has been added in 2019.3. What is the browser situation currently? Which browsers has enabled multithreading (shared array buffer) fully?

Unfortunately not many as of yet: https://caniuse.com/#feat=sharedarraybuffer but it . looks like the gears are slowly starting to turn to get it re enabled.

@ChristianKoGaMa Hi! Where did you find the info that support for multithreading has been added in 2019.3? The info in the Unity documentation for WebGL in 2019.3 still states the following:

  • Threads are not supported due to the lack of threading supporting in JavaScript. This applies to both Unity’s internal use of threads to speed up performance, and to the use of threads in script code and managed dlls. Essentially, anything in the System.Threading namespace is not supported.

We added WASM multi-threading as an experimental feature in 2019.1 but due to the CPU exploit issues this has not been spread as far as folks were hoping as the link above shows.

2 Likes

@Schubkraft Is WebGL threading technically possible in 2019.x by setting webGLThreadsSupport to 1 in project settings?

1 Like

-- @Schubkraft Is WebGL threading technically possible in 2019.x by setting webGLThreadsSupport to 1

Re: multithreading and WebGL -- you are damaging good will with developers by heavily marketing this feature and then failing to explain the degree to which it is working, isn't working, or even should be expected to work. Is this related to the issue with ConcurrentDictionary.Count causing the WebGL player to crash?

2 Likes

@Schubkraft we'd also love to get more info about the extent to which webGL multithreading is functional. It's in FireFox nightly and shipped a while ago with Chrome 74.

Ah, I found some info in the webgl roadmap post :
[quote]
As mentioned in the performance section, we plan to support multi-threading for our internal engine code using Shared Array Buffers, once browsers ship support for that. We hope to eventually extend this support to user code using System.Threading.* as well, but that is a more difficult problem to solve, as Shared Array Buffers will not provide some functionality required by our GC. We have some thoughts on how to work around that, and expect to have a working solution eventually at some point in the future, but that will likely be at a later point in time after we have added multithreading support for Unity Engine code internally.
[/quote]

I'm interested in knowing whether the experimental multithreading support in 2019.3 & 2020.1 is for the internals of the Unity engine only or if anything in Sytem.Threading.* works yet

2 Likes

Update that WebAssembly threads have shipped with FireFox 79: https://hacks.mozilla.org/2020/07/firefox-79/

1 Like

I can confirm multi threading enabled worked on chrome but still displays the error message for firefox both 79 and 80.
Only worked with a empty cube scene so far. Didnt work with my ecs project though.
Was tested on 2020.1.1 I believe.

4 Likes


interesting


I tried to enable WebGLThreadsSupport in 2020.1.2 and it breaks builds, the project does not compile after this setting is enabled. Looks like this feature is broken in 2020.1.2

2 Likes

What unity version do you have? I cant enable this function in 2020.1.2 cause builds start failing :frowning:

Edit:
My bug was reproduced with Unity QA Team:
https://discussions.unity.com/t/804788

2 Likes

Hi Dr ViJ, I believe that you need to build the web build with development build settings. I can confirm in 2020.1.2f that I get the same error without development, same with 2020.1.1f.
Edit: Wait never mind, dev is not working now too! Maybe I set something differently… I think it’s just not working anymore haha.

1 Like

Thank you! I will try this way as temporary solution until bug is fixed.

Edit:
I tried to compile with Development Build, Unfortunatly the build failed, so I will wait for Unity Technologies fix that. But thank you for support :)

1 Like

Is there any unity version where this currently works?

2020.1.2f, 2020.1.4f fails. 2020.1.0f works.

1 Like

I had difficulties with EntityCommandBuffers inside jobs were breaking. I removed that and I got it to work. But burst didnt work. And my custom animation system uses burst to do bone skinning. Does anyone know if unitys SkinnedMeshRenders work lol

[quote]
But burst didnt work
[/quote]

@deus0 what error(s) did you get from Burst?

Surly this can't be true: