[Webkit-unassigned] [Bug 239614] New: Web Locks held in a Worker are not released on page refresh or exit

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Apr 21 10:39:53 PDT 2022


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

            Bug ID: 239614
           Summary: Web Locks held in a Worker are not released on page
                    refresh or exit
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Mac (Intel)
                OS: macOS 12
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKit Misc.
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: apple-rth at hashimoto.us

There is a test page at this link:
https://rhashimoto.github.io/web-locks-test/

1. Open the test page in Safari or Safari Technology Preview.
2. Refresh the page a few times.

The expected output (which is shown by Chrome and Firefox) should always be this:

{
  "held": [],
  "pending": []
}
lock acquired from window
lock acquired from worker

On Safari, the expected output is shown on the first page load, but on subsequent loads, it shows held and pending locks for "worker-lock" and the lock is *not* acquired from the worker.


Here's what the page does:

Using the Web Locks API, my test page collects lock status (with navigator.locks.query) and then acquires a lock like this from both the Window context and a Worker context:

navigator.locks.request('worker-lock', function() {
  postMessage('lock acquired from worker');

  return new Promise(resolve => {
    // Don't release the lock.
  });
});

By returning an unresolved Promise from the request callback, this holds an exclusive lock indefinitely. I know that real code would have a means to release the lock; this is just to demonstrate the problem.

I expect when the contexts are exited, e.g. by refreshing the page, that the lock will be released and so will be available the next time the page starts. This is true for all other browsers I have tried, but on Safari, this is the case for the Window context but not for the Worker context.

This has the potential to cause deadlock in any application that uses Web Locks in a Worker. The only way I have found for a user to recover is to restart Safari.

-- 
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/20220421/c5319cc5/attachment.htm>


More information about the webkit-unassigned mailing list