Add lofigui.Yield() for WASM-friendly cooperative scheduling #4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In WASM,
runtime.Gosched()only yields between Go goroutines — it never returns control to the JavaScript event loop. This means tight goroutine loops (e.g. batch customer generation) freeze the browser UI even though they release the mutex each iteration.time.Sleep(time.Millisecond)fixes this in WASM because it suspends the Go runtime and lets the browser run. On native builds it is unnecessary overhead.Proposal:
lofigui.Yield()that does the right thing per platform:js/wasm):time.Sleep(time.Millisecond)runtime.Gosched()App code in tight background loops calls
lofigui.Yield()instead of choosing the mechanism directly. This keeps the browser responsive under heavy compute without penalising the native server build.Discovered in gobank —
AddCustomersBatchwas callingruntime.Gosched()and the dashboard graphs froze until the batch completed.Migrated from Codeberg: originally #4, opened 2026-03-24.