Bug 255637 - Create a sub worker in worker is not supported
Summary: Create a sub worker in worker is not supported
Status: RESOLVED DUPLICATE of bug 255402
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-04-18 19:18 PDT by Jeason Xu
Modified: 2023-05-24 09:29 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeason Xu 2023-04-18 19:18:36 PDT
If I want to create a sub-worker in a woker, Worker api is not supported.

// worker.js
new Worker('sub-woker.js');

// main.js
new Worker('worker.js');

worker.js will console.error, "can not find variable Worker"
Comment 1 Alexey Proskuryakov 2023-04-19 07:42:27 PDT
We support nested workers since bug 22723. Are you testing with an older Safari version?
Comment 2 Radar WebKit Bug Importer 2023-04-25 19:19:19 PDT
<rdar://problem/108537000>
Comment 3 Jeason Xu 2023-05-24 01:14:19 PDT
(In reply to Alexey Proskuryakov from comment #1)
> We support nested workers since bug 22723. Are you testing with an older
> Safari version?

I test this on lateset 16.4, The Worker api now is not undefined, however. The nested Worker handle can't be built successfully, seems the workes api implemention has bugs.

Here is simple demo code for nested worker:
// worker.js
function Create_Worker() {
    let data = "let data = \"setInterval(function(){console.log(\\\"hello1\\\")},10)\"\n" +
        "workerhandle = new Worker(URL.createObjectURL(new Blob([data])));\n" +
		"console.error(\" typeofworker\",typeof\ Worker)\n"+
        "setInterval(function () {\n" +
        "    console.log(\"hello\")\n" +
        "},10)"
    workerhandle = new Worker(URL.createObjectURL(new Blob([data])));
}
Comment 4 Alexey Proskuryakov 2023-05-24 09:29:45 PDT
Console logging not working is a known issue, tracked as bug 255402.

Please test the actual effects of the scripts for now, presumably by posting messages from the nested worker. 

If you still see issues, please file a new bug - that way, it will be easier for people working on it to see what it is about without digging through old discussions.

*** This bug has been marked as a duplicate of bug 255402 ***