Search Issue Tracker
Fixed in 2020.2.X
Fixed in 2019.4.X, 2020.1.X
Votes
0
Found in
2019.3
2019.3.9f1
2020.1
2020.2
Issue ID
1243010
Regression
No
[WebGL] Async Tasks do not run on WebGL when Threading is enabled
Reproduction steps:
1. Open the attached project ("case_1243010-WebG-Threads.zip")
2. Open the repro scene ("SampleScene")
3. Enter Play Mode
4. Notice the logs about async tasks being printed out to the screen
5. Exit Play Mode and make a WebGL build
6. Run the build and inspect the printed messages on the screen
Expected result: Async task messages are printed to the screen
Actual result: Only 'Start' and 'End' messages are printed to the screen (async tasks doesn't run)
Reproducible with: 2019.3.14f1, 2020.1.0b9, 2020.2.0a11
Couldn't test with 2018.4 (errors when building the project)
Tested with: Chrome (81.0.4044.138)
Comments (8)
-
Duardo712
Jun 30, 2023 23:45
The plugin I commented about below actually caused my project to crash after a while, so I don't recommend using it (I believe it makes everything single-threaded, even the Editor code). A simpler solution I came up with was:
1. Define a singleton GameObject.
2. Define a replacement for Task.Delay which returns a Task generated from a TaskCompletionSource. The task completes after the desired delay, using the singleton's StartCoroutine to implement the waiting. -
Duardo712
Jun 30, 2023 20:48
2021.3.19f1 still not working. A workaround is to download Mono.Cecil from NuGet and use https://github.com/VolodymyrBS/WebGLThreadingPatcher. I did this and it worked.
-
Siccity
Jul 29, 2022 09:00
Still not fixed in 2019.4.26f1
Just found this out after replacing all my coroutines with async/await :D
-
AndersenCastaneda
Jul 07, 2022 19:07
Task.Delay() is implemented for WebGL, but it uses a System.Timer, which requires threading support, and because of that is not compatible.
code source: https://github.com/Unity-Technologies/mono/blob/unity-mono-4.8.0-branch/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs#L5909Replace Task.Delay() with Task.Yield() and the code will work on WebGL.
-
jacobsmith3204
Jan 23, 2022 03:43
I've tried this in 2020.3.26f1, 2019.4.34.f1 (LTS) and 2019.4.7f1
and none of those have worked. (first 2 being the latest (LTS) builds) -
David_GameDev
Jan 20, 2022 14:16
Can confirm, still not working in 2021.2.7f1
-
Tom-Mensink
Feb 22, 2021 19:33
Why is this closed, doesn't work in 2019.4.8f1 either.
-
vvmichalk
Jan 13, 2021 12:31
Just tested in 2019.4.7f1, it does not work.
Simple thing like this does not work:Test.text = "1";
await Task.Delay(1000);
Test.text += "2";
await Task.Delay(1000);
Test.text += "3";Unity only pretends it's multi-platform, it's actually multi-pain.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Uninitialized variable warning appears in the Inspector of a custom shader when the variable is initialized
- "Failed creating toolbar element from ID..." error is thrown when resetting the Scene view Overlay layout while an Asset Transformer Toolbox overlay is active
- Entity ID for Font Assets is serialized twice which throws an error when using Debug Inspector
- Play Mode can be entered when disabling Adaptive Performance and pressing either the Play Mode button or the keyboard shortcut to enter Play Mode before recompilation leading to errors and warnings thrown
- Parent ListView element also becomes selected when inner ListView element is selected
Resolution Note (fix version 2020.2):
IL2CPP wasn't generating the correct threaded code when threadingSupport flag was set in the project settings. Fixed in 2020.2.0a16
Resolution Note (fix version 2020.1):
Fixed in 2020.1.0b17.4177
Resolution Note (fix version 2019.4):
Fixed in - 2019.4.7f1