How does WASM gorutine schedular work



I have just started to port one of my hobby games to WASM.

The experience so far has been superb. :smiley:
Got most of it up and running in a few hours and it is looking really promising.

But after a few minutes/seconds of game play run in to these deadlocks that I just can’t wrap my head around. It is not reported as a deadlock by the runtime and it just freezes my browser. (Same with all major browsers)


The game runs fin on lots of other platforms and have multiple backends so I’m pretty sure this is an issue only in the WASM backend.

Since this deadlock is not reported by the runtime as “deadlock: all goruntines are asleep” I’m thinking there is some consideration I need to take when calling JS from my WASM code or starting new gorutines.


If I understand it correctly the “WASM standard” does not support/define os threads? So how are gorutines multiplexed in the runtime? Are there some limitation that I need to consider?

Can the runtime handle two gorutines in a tight loop? (Preemptive multitasking)
This dosn’t seem to work for me. It looks like only one of the tight loops prints to the console.
I have tried both runtime.Gosched() and a select statement (with a default) within the tight loops but only one seems to execute.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.