Conversation
This example can be built with ./wasm-pack.sh This example can be run with `npx serve -c serve.json pkg`
|
Thanks for the minimal bug example, I have identified the bug. Before refactoring, main thread was identified as the one that was first to spawn a thread, however, I changed that to a check if The need for main thread identification is explained in #5, which implemented sub-worker spawning by sending a spawn request back to the main thread. But this does not seem neccessary now, because worker spawning from inside another worker seem to work just fine. Maybe @DouglasDwyer could explain what exatly the problem was? |
|
Hey @chemicstry, good to hear from you. The problem was exactly what you mention - certain browser environments could not spawn web workers from other workers. For example, nested workers were only implemented in WebKit a few months ago. It does look like more browsers have support for this now, so maybe the requirement can be relaxed. But before allowing workers to spawn other workers directly, I would recommend testing against all modern browser vendors :) |
|
Thanks for both of your insights! Very interesting |
I wanted to understand how the changes in the refactor branch "broke" my code
So I made a minimal reproduce of the bug as an example, also having more example (more end-to-end) might be beneficial
How to test the difference:
What should you see:
refactorthe worker spawns & despawns instantlymainthe worker spawns & does its counting