This is to make nested worker constructor work in JS bindings.
Created attachment 29502 [details] Proposed Patch
We can't enable constructing nested workers in default build when they don't work nearly correctly. What changes does this depend upon?
(In reply to comment #2) > We can't enable constructing nested workers in default build when they don't > work nearly correctly. What changes does this depend upon? > This change depends on the script loading work and termination work. I am currently working on the termination issue. I can have this change check in at last.
*** Bug 40288 has been marked as a duplicate of this bug. ***
Are there any plans for this?
This is extremely useful to support parallelism
https://commits.webkit.org/254597@main
<rdar://problem/100079582>
(In reply to Chris Dumez from comment #7) > https://commits.webkit.org/254597@main Chris! My hero! Do you know approximately when this commit will see the light of day?
This appears to have already made it into Safari Technology Preview, at least.
When trying to use sqlite wasm on safari tech preview, "new Worker(new URL("sqlite3-opfs-async-proxy.js", import.meta.url));" inside a worker successfully creates a new worker, but it never starts.
Fwiw I managed to work around this challenge using the following polyfill: https://github.com/dmihal/Subworkers I have created a fork that adds support for module imports, i.e: new Worker("file.js", { type: "module" }); https://github.com/jespertheend/Subworkers
Thanks for the polyfill, I tried it, but in subworkers.js the following message function is called: self.postMessage({ _subworker: true, cmd: 'newWorker', id: this.id, path: absPath }); but never receiver anywhere. I guess, it should be received here: var messageRecieved = function(event){ if (event.data._subworker){ cmds[event.data.cmd](event); } };
When I first used the polyfill I wasn't working for me either. I believe it was because I was also using this module workers polyfill: https://gist.github.com/developit/220246bc99044af74a6680ce13284f59 and they were interfering with each other. I had to play around with the order of imports for a bit in order to fix it. Though I'm not sure if you're running into the same issue here.
I'm not sure why, but I have to load the subworkers script in the head part of my index.html to work. It has to be there in the tests as well. Anyway thanks :-).