RESOLVED FIXED Bug 233289
Add initial implementation for the Web Lock API
https://bugs.webkit.org/show_bug.cgi?id=233289
Summary Add initial implementation for the Web Lock API
Chris Dumez
Reported 2021-11-17 15:58:33 PST
Add initial implementation for the Web Lock API. For now, it only coordinates locks within one WebProcess to keep things the patch as small as possible. Support for multiple processes with be added in a follow-up.
Attachments
WIP Patch (104.96 KB, patch)
2021-11-17 17:02 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (104.37 KB, patch)
2021-11-18 09:00 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (103.19 KB, patch)
2021-11-18 10:52 PST, Chris Dumez
no flags
WIP Patch (102.53 KB, patch)
2021-11-18 10:54 PST, Chris Dumez
no flags
WIP Patch (102.45 KB, patch)
2021-11-18 11:20 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (114.05 KB, patch)
2021-11-18 16:27 PST, Chris Dumez
no flags
WIP Patch (113.35 KB, patch)
2021-11-18 16:45 PST, Chris Dumez
no flags
WIP Patch (112.96 KB, patch)
2021-11-18 16:49 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (112.47 KB, patch)
2021-11-18 17:42 PST, Chris Dumez
no flags
WIP Patch (112.52 KB, patch)
2021-11-18 18:02 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (112.52 KB, patch)
2021-11-18 19:27 PST, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (112.57 KB, patch)
2021-11-19 07:43 PST, Chris Dumez
no flags
WIP Patch (111.53 KB, patch)
2021-11-19 08:48 PST, Chris Dumez
no flags
WIP Patch (112.88 KB, patch)
2021-11-19 08:59 PST, Chris Dumez
no flags
Patch (125.19 KB, patch)
2021-11-19 10:11 PST, Chris Dumez
no flags
Patch (126.36 KB, patch)
2021-11-19 13:02 PST, Chris Dumez
no flags
Patch (125.75 KB, patch)
2021-11-19 16:40 PST, Chris Dumez
no flags
Patch (125.76 KB, patch)
2021-11-19 16:47 PST, Chris Dumez
no flags
Patch (125.87 KB, patch)
2021-11-19 18:13 PST, Chris Dumez
no flags
Patch (125.91 KB, patch)
2021-11-19 23:13 PST, Chris Dumez
no flags
Patch (126.04 KB, patch)
2021-11-29 07:29 PST, Chris Dumez
no flags
Patch (125.94 KB, patch)
2021-11-29 16:28 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2021-11-17 17:02:03 PST
Created attachment 444611 [details] WIP Patch
Chris Dumez
Comment 2 2021-11-18 09:00:35 PST
Created attachment 444686 [details] WIP Patch
Chris Dumez
Comment 3 2021-11-18 10:52:31 PST
Created attachment 444702 [details] WIP Patch
Chris Dumez
Comment 4 2021-11-18 10:54:41 PST
Created attachment 444703 [details] WIP Patch
Chris Dumez
Comment 5 2021-11-18 11:20:59 PST
Created attachment 444705 [details] WIP Patch
Chris Dumez
Comment 6 2021-11-18 16:27:23 PST
Created attachment 444755 [details] WIP Patch
Chris Dumez
Comment 7 2021-11-18 16:45:17 PST
Created attachment 444757 [details] WIP Patch
Chris Dumez
Comment 8 2021-11-18 16:49:07 PST
Created attachment 444759 [details] WIP Patch
Chris Dumez
Comment 9 2021-11-18 17:42:21 PST
Created attachment 444763 [details] WIP Patch
Chris Dumez
Comment 10 2021-11-18 18:02:36 PST
Created attachment 444764 [details] WIP Patch
Chris Dumez
Comment 11 2021-11-18 19:27:53 PST
Created attachment 444772 [details] WIP Patch
Chris Dumez
Comment 12 2021-11-19 07:43:59 PST
Created attachment 444819 [details] WIP Patch
Chris Dumez
Comment 13 2021-11-19 08:48:27 PST
Created attachment 444823 [details] WIP Patch
Chris Dumez
Comment 14 2021-11-19 08:59:25 PST
Created attachment 444824 [details] WIP Patch
Chris Dumez
Comment 15 2021-11-19 10:11:52 PST
Chris Dumez
Comment 16 2021-11-19 13:02:06 PST
Chris Dumez
Comment 17 2021-11-19 16:40:35 PST
Chris Dumez
Comment 18 2021-11-19 16:47:55 PST
Chris Dumez
Comment 19 2021-11-19 18:13:13 PST
Chris Dumez
Comment 20 2021-11-19 23:13:41 PST
Radar WebKit Bug Importer
Comment 21 2021-11-24 15:59:19 PST
Chris Dumez
Comment 22 2021-11-29 07:29:48 PST
Geoffrey Garen
Comment 23 2021-11-29 15:49:23 PST
Comment on attachment 445277 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=445277&action=review r=me > Source/WTF/wtf/Deque.h:576 > +inline size_t Deque<T, inlineCapacity>::removeAllMatching(const Func& func) > { > + size_t removedCount = 0; > size_t count = size(); > while (count--) { > T value = takeFirst(); > if (!func(value)) > append(WTFMove(value)); > + else > + ++removedCount; > } > + return removedCount; > } I wonder if we should just return oldSize - size() here. Simplifies the loop a bit. > Source/WebCore/Modules/web-locks/WebLockRegistry.cpp:80 > + bool shouldPrepend = false; Might be clearer as "bool shouldPrepend = steal;", rather than using a branch below.
Chris Dumez
Comment 24 2021-11-29 16:28:04 PST
Chris Dumez
Comment 25 2021-11-29 16:30:21 PST
(In reply to Geoffrey Garen from comment #23) > Comment on attachment 445277 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=445277&action=review > > r=me > > > Source/WTF/wtf/Deque.h:576 > > +inline size_t Deque<T, inlineCapacity>::removeAllMatching(const Func& func) > > { > > + size_t removedCount = 0; > > size_t count = size(); > > while (count--) { > > T value = takeFirst(); > > if (!func(value)) > > append(WTFMove(value)); > > + else > > + ++removedCount; > > } > > + return removedCount; > > } > > I wonder if we should just return oldSize - size() here. Simplifies the loop > a bit. > > > Source/WebCore/Modules/web-locks/WebLockRegistry.cpp:80 > > + bool shouldPrepend = false; > > Might be clearer as "bool shouldPrepend = steal;", rather than using a > branch below. Good ideas, thanks. I made those changes.
EWS
Comment 26 2021-11-29 21:24:45 PST
Committed r286284 (244643@main): <https://commits.webkit.org/244643@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 445364 [details].
Darin Adler
Comment 27 2021-11-30 09:31:53 PST
Comment on attachment 445364 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=445364&action=review > Source/WebCore/bindings/js/JSDOMConvertPromise.h:54 > + auto& scriptController = *downcast<WorkerGlobalScope>(*scriptExecutionContext).script(); Just noticed that this is a function returning a pointer, but we are unconditionally dereferencing. Can we change this to return a reference? Or should we add a null check? Or a comment explaining why. Not super-important, but mysteriously missing null checks are not my favorite.
Chris Dumez
Comment 28 2021-11-30 13:05:19 PST
(In reply to Darin Adler from comment #27) > Comment on attachment 445364 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=445364&action=review > > > Source/WebCore/bindings/js/JSDOMConvertPromise.h:54 > > + auto& scriptController = *downcast<WorkerGlobalScope>(*scriptExecutionContext).script(); > > Just noticed that this is a function returning a pointer, but we are > unconditionally dereferencing. Can we change this to return a reference? Or > should we add a null check? Or a comment explaining why. > > Not super-important, but mysteriously missing null checks are not my > favorite. Will follow-up in https://bugs.webkit.org/show_bug.cgi?id=233655 to add a null check since the script controller can in theory be null.
Note You need to log in before you can comment on or make changes to this bug.