-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C# threads / tasks don't work on the web (async / await) #34506
Comments
Browsers don't enable multithreading in WebAssembly for now, so this is normal. Duplicate of #12699. |
There is a I'll re-open this as this is about Mono's threading while #12699 is about Godot's. |
Apparently in Chrome 70, webassembly will be able to support threads Source: https://developers.google.com/web/updates/2018/10/wasm-threads |
According to the article linked by @NovemberDev Google Chrome 74+ should have threads for webassembly enabled by default, but doesn't work with my Mono build in Chrome 79 |
It should be possible to schedule the work to run on the main thread. I think unity does this aswell. This would make it more compatible for browsers that don't support threads. |
I wouldn't mind checking myself but had trouble compiling godot myself (ran both into an error and finding time is also not the easiest) because threaded wasm is a thing in 3.2.4 due to: #12699 does that mean that threads and/or tasks now also work in C#? if it doesn't work in the normal C# way, is there a (possible) work around because that feature got closed? (Maybe through communication with gdscript to have that spawn the thread?) thanks in advance :) |
@lenscas Sadly, we were not yet able to build a mono version with threads support. |
@neikeq Now that #12699 is solved (threads support in Godot's WebAssembly port), we could indeed try https://github.com/mono/mono/blob/master/sdks/wasm/README.md#threading-support to see if it can work with Mono. |
Just curious if anyone has tried a custom build with this yet or if this is working in 4.0? Would I just have to compile a new wasm export template with threads on in order to try this myself, or would I have to recompile the engine too? |
@animanmaster I tried compiling a mono wasm export template with threads for 3.4, but I am always running into some problems. For example, I get several duplicate symbols between libmonosgen and libstubs.a (from emscripten) (getpwnam_r, getpwuid_r, getgrnam, getgrgid, pthread_sigmask), but maybe someone with more knowledge has better luck. Edit: I got it to compile by removing the stub functions from "mono\mono\mini\mini-wasm.c". Have to test if everything works now. |
Regarding the milestone change: Godot 4 C# doesn't support the web platform at all at the moment, so this problem is not really relevant there. |
The symptoms of this issue are:
Thus, the following issues are really just duplicates of this one:
I suggest we merge them into this one. |
Godot version:
3.2 beta 4
OS/device including version:
Windows 10
Issue description:
Threading and tasks don't seem to work at all when exporting mono projects to the web.
Steps to reproduce:
Minimal reproduction project:
https://1drv.ms/u/s!AvsEaC7oMEMagstwXvyFlCMdOOMO2A?e=uuytsD
The label should change text to "it worked" when the program starts.
The text was updated successfully, but these errors were encountered: