Hi everyone 👋
I’m working on a Compose Multiplatform (CMP) project targeting Web/WasmJS, and I need to perform some fairly heavy background work without blocking/freezing the UI.
On Android/JVM I would normally move this work to "
Dispatchers.IO" or another background dispatcher, but on WasmJS everything seems to stay on the browser’s main/UI thread.
I’m currently trying worker-kmp:
"worker-kmp" (
https://klibs.io/project/MobileByteLabs/worker-kmp)
It claims to support Web through Service Workers, but when I run my "CoroutineWorker.doWork()", it still appears to execute on the Window/Main UI thread, and heavy JSON downloading/parsing/database work freezes the UI.
Has anyone solved this with CMP + WasmJS?
Specifically, I’m looking for the Web/Wasm equivalent of:
"withContext(
Dispatchers.IO) { ... }"
where the work actually executes off the browser UI thread, ideally using a Web Worker.
Is there currently a recommended approach/library for running coroutine-based KMP code inside a Web Worker? And has anyone successfully used "worker-kmp" for this purpose?