Created attachment 465890 [details] Safari Console A Web Worker can spawn other Web Workers; these are sometimes referred to as subworkers or sub-workers. Safari does not seem to request the subworker file and only spawns a Worker from the main thread. Note the screenshots: chrome.png: The expected behavior in Chrome. firefox.png: The expected behavior in Firefox. safari-console.png: Safari only logs the message from worker.js. safari-network.png: Safari does not seem to make the request for subworker.js. safari-sources.png: Safari does not show subworker.js in its sources. Minimal repro: https://safari-subworker.glitch.me/
Created attachment 465891 [details] Safari Network
Created attachment 465892 [details] Safari Sources
Created attachment 465893 [details] Chrome
Created attachment 465894 [details] Firefox
This does _not_ work in: - Safari Tech Preview Release 167 (Safari 16.4, WebKit 18616.1.8.2) - Safari Version 16.5 (18615.2.5.11.2) (I'm on Ventura 13.4 Beta (22F5037d))
Nested workers were implemented in bug 22723, quite surprising that this isn't working.
And this is passing. https://wpt.fyi/results/workers/semantics/multiple-workers/003.html?label=experimental&label=master&aligned And the example given in the spec. https://html.spec.whatwg.org/multipage/workers.html#delegation is working https://html.spec.whatwg.org/demos/workers/multicore/page.html Maybe it's about something else. Is it about the console.log()?
I even wonder if it's in fact just a Web Inspector issue. a bit like Bug 252685
That sounds right. I see that https://safari-subworker.glitch.me/subworker.js does get loaded when I test https://safari-subworker.glitch.me and have Charles Proxy running.
I renamed the bug.
On Safari 16.4, macOS Ventura 13.3.1 (22E261), MacBook Pro 14" 2023 (Mac14,9), I am seeing the "from subworker" console messages, though I can't see anything in the Sources or Network tabs. Given I can see them on relatively fast hardware, this makes me wonder if there's some race happening somewhere?
I have added a bunch of postMessage() calls to the demo at https://safari-subworker.glitch.me/, so we can see communication happening in all directions. I can indeed confirm that the worker.js postMessage() call arrives in subworker.js, since its response is logged in worker.js. ## Here're the logs from Chrome: Hello from main thread worker.js:1 Hello from worker.js worker.js:4 Message received in worker.js: From main thread to worker.js script.js:6 Message received in main thread: From worker.js to main thread after message from main thread subworker.js:1 Hello from subworker.js subworker.js:4 Message received in subworker.js: From worker.js to subworker.js worker.js:11 Message received in worker.js: From subworker to worker.js script.js:6 Message received in main thread: From worker.js to main thread after message from subworker.js ## Here're the logs from Firefox: Hello from main thread script.js:1:9 Hello from worker.js worker.js:1:9 Message received in worker.js: From main thread to worker.js worker.js:4:11 Message received in main thread: From worker.js to main thread after message from main thread script.js:6:11 Hello from subworker.js subworker.js:1:9 Message received in subworker.js: From worker.js to subworker.js subworker.js:4:11 Message received in worker.js: From subworker to worker.js worker.js:11:11 Message received in main thread: From worker.js to main thread after message from subworker.js script.js:6:11 ## Here're the logs from Safari (Safari Tech Preview and Stable agree): [Log] Hello from main thread (script.js, line 1) [Log] Hello from worker.js (worker.js, line 1) [Log] Message received in worker.js: – "From main thread to worker.js" (worker.js, line 4) [Log] Message received in main thread: – "From worker.js to main thread after message from main thread" (script.js, line 6) [Log] Message received in worker.js: – "From subworker to worker.js" (worker.js, line 11) [Log] Message received in main thread: – "From worker.js to main thread after message from subworker.js" (script.js, line 6) This means it's indeed a complete Web Inspector blindness to anything happening in subworker.js. Also, it doesn't yet explain why SQLite Wasm backed by the OPFS (https://sqlite-wasm-opfs.glitch.me/) isn't working on Safari yet, but that's a different story then (maybe). I'll keep investigating. The subworkers theory was a good lead, though…
Found the root cause of the SQLite Wasm problem: `navigator.storage.getDirectory()` fails in subworker with an `InvalidStateError`: https://bugs.webkit.org/show_bug.cgi?id=255458.
<rdar://problem/108322385>
Pull request: https://github.com/WebKit/WebKit/pull/13614
*** Bug 255637 has been marked as a duplicate of this bug. ***
*** Bug 272382 has been marked as a duplicate of this bug. ***
Committed 279793@main (b5d3f9b6724b): <https://commits.webkit.org/279793@main> Reviewed commits have been landed. Closing PR #13614 and removing active labels.