Godot version:
Official 3.1.1-stable
_Edit: Still works in Godot 3.2.3 rc1_
OS/device including version:
Windows 10 64-bit and any common browsers I could find.
Issue description:
Godot Engine HTML5 exports crash on initial loading when using 2D physics thread model "Multi-Threaded". Have tested this with any common browser I could find on my Windows machines, so far the same effect everywhere - the loading circle just freezes and the page dies.
This does not only affect exports though, the "launch in browser" button for debugging also leads to the same, I guess this is because Godot's just exporting in the back.
I also know that it's stupid to try and want to have Multi-Threaded performance in a browser, but my main goal is to be able to use the same project to both export to web and desktop, without having to adjust the thread model everytime. Notably though, the Rendering Thread Model does not show the same behavior.
Steps to reproduce:
Start a random project, change the physics 2D Thread Model to "Multi-Threaded" and try to launch your project in any browser. Done.
Minimal reproduction project:
BrowserThreadCrash.zip
I think I know why. As far as I remember, there's no option to multithread using web assembly yet and that's why it crashed.
But then why doesn't it crash with rendering thread model multi-threaded?
But then why doesn't it crash with rendering thread model multi-threaded?
Tested it on my current project with multi-threaded rendering.
Still fails.
Ok, strange. Is there any way to silently disable multi-threading in the background when exporting to web maybe?
silently disable multi-threading
Right now we're assuming that the current problem is actually because WASM doesn't support multi threading. Which is quite possible seeing the evidence shown. But I think we need another opinion on this matter knowing that I'm don't have in depth knowledge about the engine.
But what I could say if "multi-threading" is an actual problem is that, you could check what your platform is right now by checking OS.get_name() in gdscript. This will give you back the name of the platform that your game is running on and with that name you could customize the behaviour of your game dynamically where ever it is. Possible values are: "Android", "Haiku", "iOS", "HTML5", "OSX", "Server", "Windows", "UWP", "X11". My concern about this approach is that if your code is not decoupled enough, it would be HELL to refactor all of those methods and classes.
I'm going to mention @willnationsdev for this one.
Ok, strange. Is there any way to silently disable multi-threading in the background when exporting to web maybe?
This can be done using feature tags, which don't require any scripting. In the Project Settings, select the appropriate setting, then click on Override For… and choose HTML5 in the list. The new HTML5-only setting will appear at the bottom of the list.

But then why doesn't it crash with rendering thread model multi-threaded?
Tested it on my current project with multi-threaded rendering.
Still fails.
Had some more testing and couldn't reproduce this in my empty test project. So it looks to me like it really only crashes with physics multi-threaded out of the box and something more is going on behind the scenes here.
Can anyone still reproduce this bug in Godot 3.2.3 rc1 or any later release?
If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.
Yes the bug remains unchanged and the original MRP still works.
BrowserThreadCrash.zip
You can see the text pop up when physics is single-safe threaded, however it doesn't load at all/crashes when setting multi-threaded.
The HTML5 platform doesn't support threads by default, unless compiled with threads_enabled=yes (not enabled by default yet as browser support for WebAssembly Threads is not a given).
@Faless We should probably catch this and override the multi-threaded physics (and possibly rendering) settings for HTML5.
Most helpful comment
This can be done using feature tags, which don't require any scripting. In the Project Settings, select the appropriate setting, then click on Override For… and choose HTML5 in the list. The new HTML5-only setting will appear at the bottom of the list.