Bug 25212 - Support constructing nested workers.
Summary: Support constructing nested workers.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 40288 (view as bug list)
Depends on:
Blocks: 22723
  Show dependency treegraph
 
Reported: 2009-04-15 10:47 PDT by Jian Li
Modified: 2023-03-27 03:59 PDT (History)
10 users (show)

See Also:


Attachments
Proposed Patch (7.19 KB, patch)
2009-04-15 10:49 PDT, Jian Li
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jian Li 2009-04-15 10:47:22 PDT
This is to make nested worker constructor work in JS bindings.
Comment 1 Jian Li 2009-04-15 10:49:33 PDT
Created attachment 29502 [details]
Proposed Patch
Comment 2 Alexey Proskuryakov 2009-04-16 13:03:33 PDT
We can't enable constructing nested workers in default build when they don't work nearly correctly. What changes does this depend upon?
Comment 3 Jian Li 2009-04-16 13:17:36 PDT
(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.
Comment 4 Alexey Proskuryakov 2010-06-08 13:15:10 PDT
*** Bug 40288 has been marked as a duplicate of this bug. ***
Comment 5 Jesper van den Ende 2021-06-02 01:02:58 PDT
Are there any plans for this?
Comment 6 Peter B 2022-09-09 10:55:57 PDT
This is extremely useful to support parallelism
Comment 7 Chris Dumez 2022-09-17 19:39:22 PDT
https://commits.webkit.org/254597@main
Comment 8 Radar WebKit Bug Importer 2022-09-17 19:41:25 PDT
<rdar://problem/100079582>
Comment 9 Peter B 2022-09-18 01:30:10 PDT
(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?
Comment 10 Lanny Heidbreder 2022-11-20 14:29:17 PST
This appears to have already made it into Safari Technology Preview, at least.
Comment 11 frederik.bertling 2023-03-26 12:22:55 PDT
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.
Comment 12 Jesper van den Ende 2023-03-26 14:52:06 PDT
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
Comment 13 frederik.bertling 2023-03-27 02:27:51 PDT
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);
  }
};
Comment 14 Jesper van den Ende 2023-03-27 02:41:48 PDT
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.
Comment 15 frederik.bertling 2023-03-27 03:59:50 PDT
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 :-).