[Webkit-unassigned] [Bug 250839] New: SharedWorkerGlobalScope.close() does not fully remove SharedWorker so a SharedWorker cannot be replaced or restarted

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 19 07:48:51 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=250839

            Bug ID: 250839
           Summary: SharedWorkerGlobalScope.close() does not fully remove
                    SharedWorker so a SharedWorker cannot be replaced or
                    restarted
           Product: WebKit
           Version: Safari 16
          Hardware: Mac (Apple Silicon)
                OS: macOS 13
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: nathan at shareup.app

I've created a git repo with a test project demonstrating the bug here: https://github.com/shareup/sharedworker-restart-webkit-bug

To replace or restart a `SharedWorker`, the shared worker can call `self.close()` on itself, then a window can use `new SharedWorker('worker.js')` to create and connect to a new worker. 

The expectation is `new SharedWorker('worker.js')` will always either connect to an existing, running `SharedWorker`, or boot one. It's important to be able to replace a `SharedWorker` when non-backwards compatible code is deployed, and still have the guarantee that there is only ever zero or one shared worker is running (by always using the same pathname `'worker.js'`).

After `SharedWorkerGlobalScope.close()` is called, any other window which uses `new SharedWorker(worker.js)` will get a broken `SharedWorker`. I can see an HTTP request is made for `worker.js` (I don't have any headers which would cache the request), so WebKit is correctly loading the file from the network. However, it appears to never start up the shared worker or connect. 

The only remedy appears to be to close all tabs/windows which ever connected to the original `SharedWorker` (which is now closed), then `new SharedWorker('worker.js')` in a new window will work as expected again. 

I've tested in Safari 16 on macOS and iOS and in Safari Tech Preview on macOS and they all work the way I describe above.

The test in the linked repo will close, and recreate the same `SharedWorker` 5 times in the same window session and works correctly in other UAs which support `SharedWorker`, but not in WebKit.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230119/86a46410/attachment.htm>


More information about the webkit-unassigned mailing list