How does WASM gorutine schedular work

Hi!

Explanation:

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)

Speculation:

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.

Question:

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.