9 ms·
How would it serialize? That means potentially interrupting any other JavaScript or WASM code running on the main UI thread and executing other JS code there? T
by Matthias247 5y ago
How would it serialize? That means potentially interrupting any other JavaScript or WASM code running on the main UI thread and executing other JS code there? That seems kind of against what JavaScript is (100% singlethreaded).
I assume if it’s even possible, it might execute the code only if the main thread is not executing any events - which happens only once per eventloop iteration.
I guess what is happening is that worker can call into JS, but can not access the DOM or anything else living on the main thread. They have to send messages to the other thread, just as JavaScript workers would need to do.
- monocasa 5y agoBecause it's structured as WASM popping a normal event on the event queue of the normal JS main thread. There's no 'now run JS on the WASM thread but with DOM access'.
- fosefx 5y ago> 100% singlethreaded You can (and should) use Web Workers[1], those run off the UI thread, but also don't have access to the DOM. [1] https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...