emscripten-core / emscripten-core/emscripten
[question] A lot of FS calls / wasm module calls get browser UI frozen (a recipe for such scenarios would be very welcome)
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I have a code similar to this pseudo-code in my JavaScript (displayed on a webpage in Chrome). After clicking on mybutton, my UI freezes and all updates to UI are displayed only after the function completes execution. It seems I'm doing something bad with async + FS. Would you have any advice for a good pattern of async + FS + UI events getting processed?
It seems that somehow this handler gets executed on the main thread and asyncability doesn't trigger
Thanks!
```js
mybutton.onclick = () => func();
async func()
{
for(let i = 0; i < 1000; i++)
{
const contents = await fetch(...).then(r => r.text());
// save to FS contents received from internet via fetch
mydiv.innerText += `${i}\n`;
}
// Similar problems if I'm adding Promises to a list and then await Promise.all(that_list)
}
```
Contributor guide
Assessment
This issue has not been assessed yet.