WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
235958
Add support for sharing Shared Workers (including across WebProcesses)
https://bugs.webkit.org/show_bug.cgi?id=235958
Summary
Add support for sharing Shared Workers (including across WebProcesses)
Chris Dumez
Reported
2022-02-01 09:01:00 PST
Add support for sharing Shared Workers (including across WebProcesses).
Attachments
WIP Patch
(281.88 KB, patch)
2022-02-01 09:03 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(300.46 KB, patch)
2022-02-01 11:00 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(303.17 KB, patch)
2022-02-01 11:35 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(321.56 KB, patch)
2022-02-01 13:18 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(321.50 KB, patch)
2022-02-01 14:05 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(330.07 KB, patch)
2022-02-01 15:25 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(314.22 KB, patch)
2022-02-01 19:04 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(314.41 KB, patch)
2022-02-01 22:09 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(322.41 KB, patch)
2022-02-02 09:53 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(321.45 KB, patch)
2022-02-02 11:48 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(317.74 KB, patch)
2022-02-02 11:53 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(309.24 KB, patch)
2022-02-02 12:47 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(310.06 KB, patch)
2022-02-02 13:31 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(307.07 KB, patch)
2022-02-02 16:09 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(293.78 KB, patch)
2022-02-02 18:55 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(251.22 KB, patch)
2022-02-03 09:13 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(262.26 KB, patch)
2022-02-03 10:39 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(257.08 KB, patch)
2022-02-03 11:43 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(253.79 KB, patch)
2022-02-03 12:22 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(297.48 KB, patch)
2022-02-03 13:05 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(301.56 KB, patch)
2022-02-03 15:17 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
WIP Patch
(310.65 KB, patch)
2022-02-03 17:11 PST
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP Patch
(268.23 KB, patch)
2022-02-04 09:34 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(288.33 KB, patch)
2022-02-04 11:28 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(290.60 KB, patch)
2022-02-04 12:05 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(296.29 KB, patch)
2022-02-04 13:28 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(298.21 KB, patch)
2022-02-04 15:24 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(311.50 KB, patch)
2022-02-04 17:02 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(316.35 KB, patch)
2022-02-07 08:21 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(316.28 KB, patch)
2022-02-07 12:11 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(29)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-02-01 09:01:25 PST
<
rdar://problem/88330666
>
Chris Dumez
Comment 2
2022-02-01 09:03:23 PST
Created
attachment 450537
[details]
WIP Patch
Chris Dumez
Comment 3
2022-02-01 11:00:48 PST
Created
attachment 450548
[details]
WIP Patch
Chris Dumez
Comment 4
2022-02-01 11:35:34 PST
Created
attachment 450554
[details]
WIP Patch
Chris Dumez
Comment 5
2022-02-01 13:18:35 PST
Created
attachment 450561
[details]
WIP Patch
Chris Dumez
Comment 6
2022-02-01 14:05:07 PST
Created
attachment 450565
[details]
WIP Patch
Chris Dumez
Comment 7
2022-02-01 15:25:12 PST
Created
attachment 450581
[details]
WIP Patch
Chris Dumez
Comment 8
2022-02-01 16:43:57 PST
The patch is huge so I'll try and split parts of it out to facilitate review a bit.
Chris Dumez
Comment 9
2022-02-01 19:04:54 PST
Created
attachment 450602
[details]
WIP Patch
Chris Dumez
Comment 10
2022-02-01 22:09:56 PST
Created
attachment 450610
[details]
WIP Patch
Chris Dumez
Comment 11
2022-02-02 09:53:53 PST
Created
attachment 450662
[details]
WIP Patch
Chris Dumez
Comment 12
2022-02-02 11:48:53 PST
Created
attachment 450683
[details]
WIP Patch
Chris Dumez
Comment 13
2022-02-02 11:53:11 PST
Created
attachment 450684
[details]
WIP Patch
Chris Dumez
Comment 14
2022-02-02 12:47:11 PST
Created
attachment 450691
[details]
WIP Patch
Chris Dumez
Comment 15
2022-02-02 13:31:43 PST
Created
attachment 450694
[details]
WIP Patch
Chris Dumez
Comment 16
2022-02-02 16:09:30 PST
Created
attachment 450710
[details]
WIP Patch
Chris Dumez
Comment 17
2022-02-02 18:55:22 PST
Created
attachment 450727
[details]
WIP Patch
Chris Dumez
Comment 18
2022-02-03 09:13:25 PST
Created
attachment 450777
[details]
WIP Patch
Chris Dumez
Comment 19
2022-02-03 10:39:15 PST
Created
attachment 450791
[details]
WIP Patch
Chris Dumez
Comment 20
2022-02-03 11:43:21 PST
Created
attachment 450801
[details]
WIP Patch
Chris Dumez
Comment 21
2022-02-03 12:22:50 PST
Created
attachment 450803
[details]
WIP Patch
Chris Dumez
Comment 22
2022-02-03 13:05:50 PST
Created
attachment 450806
[details]
WIP Patch
Chris Dumez
Comment 23
2022-02-03 15:17:57 PST
Created
attachment 450829
[details]
WIP Patch
Chris Dumez
Comment 24
2022-02-03 17:11:31 PST
Created
attachment 450840
[details]
WIP Patch
Chris Dumez
Comment 25
2022-02-04 09:34:45 PST
Created
attachment 450906
[details]
WIP Patch
Chris Dumez
Comment 26
2022-02-04 11:28:23 PST
Created
attachment 450921
[details]
Patch
Chris Dumez
Comment 27
2022-02-04 12:05:31 PST
Created
attachment 450928
[details]
Patch
Chris Dumez
Comment 28
2022-02-04 13:28:44 PST
Created
attachment 450934
[details]
Patch
Chris Dumez
Comment 29
2022-02-04 15:24:11 PST
Created
attachment 450943
[details]
Patch
Chris Dumez
Comment 30
2022-02-04 17:02:16 PST
Created
attachment 450954
[details]
Patch
Darin Adler
Comment 31
2022-02-05 22:42:48 PST
Comment on
attachment 450954
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=450954&action=review
Looks good, I didn’t spot any mistakes.
> Source/WebCore/workers/shared/SharedWorkerKey.h:52 > + Hasher hasher; > + add(hasher, origin.hash()); > + add(hasher, url); > + add(hasher, name); > + return hasher.hash();
Instead, we should write: return computeHash(origin.hash(), url, name); That does the same thing. But also, it’s not good to hash a hash. Instead, we should write these functions: inline add(Hasher& hasher, const SharedWorkerKey& key) { hasher.add(key.origin, key.url, key.name); } inline add(Hasher& hasher, const ClientOrigin& origin) { add(hasher, origin.topOrigin, origin.clientOrigin); } inline add(Hasher& hasher, const SecurityOriginData& data) { add(hasher, data.protocol, data.host, data.port); } These don’t have to be inlined, and of course they should go in the appropriate headers. Once those functions are all defined, we can call computeHash on any of these types, without any hashing of a hash getting involved. If we want, we can still define SharedWorkerKey::hash, but it should just call computeHash: unsigned hash() const { return computeHash(*this); }
Darin Adler
Comment 32
2022-02-05 22:43:37 PST
Forgot the "void" above: inline void add ... But otherwise the code should work.
Chris Dumez
Comment 33
2022-02-07 08:21:54 PST
Created
attachment 451107
[details]
Patch
Chris Dumez
Comment 34
2022-02-07 10:36:32 PST
Hmm, http/tests/cache-storage/cache-origins.https.html appears to be failing on EWS. I'll have to investigate. It is not involving Shared Workers but maybe I messed up the new hash functions somehow.
Darin Adler
Comment 35
2022-02-07 11:06:01 PST
Comment on
attachment 451107
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=451107&action=review
> Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h:32 > +#include <wtf/Hasher.h> > #include <wtf/text/StringHash.h> > #include <wtf/text/WTFString.h>
We don’t need any of these includes. ClientOrigin.h already pulls them in (I’m not sure about StringHash, but if it’s needed it’s pulled in).
> Source/WebCore/page/SecurityOriginData.h:103 > + add(hasher, data.protocol, data.host, data.port);
If we wanted to more closely match the old hash function, this would need to be data.port.value_or(0) unless we want "no port" to hash differently than a port number. We probably do want them distinct just the way this is written, but I noticed it is a difference.
> Source/WebCore/workers/shared/SharedWorkerKey.h:31 > +#include <wtf/Hasher.h> > +#include <wtf/URL.h> > +#include <wtf/text/WTFString.h>
Don’t need this any of these. They are all included by ClientOrigin.h already.
Chris Dumez
Comment 36
2022-02-07 12:11:12 PST
Created
attachment 451136
[details]
Patch
Chris Dumez
Comment 37
2022-02-07 12:11:52 PST
(In reply to Darin Adler from
comment #35
)
> Comment on
attachment 451107
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=451107&action=review
> > > Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h:32 > > +#include <wtf/Hasher.h> > > #include <wtf/text/StringHash.h> > > #include <wtf/text/WTFString.h> > > We don’t need any of these includes. ClientOrigin.h already pulls them in > (I’m not sure about StringHash, but if it’s needed it’s pulled in). > > > Source/WebCore/page/SecurityOriginData.h:103 > > + add(hasher, data.protocol, data.host, data.port); > > If we wanted to more closely match the old hash function, this would need to > be data.port.value_or(0) unless we want "no port" to hash differently than a > port number. We probably do want them distinct just the way this is written, > but I noticed it is a difference.
It appears this was the cause of the regression, thanks!
Darin Adler
Comment 38
2022-02-07 12:16:23 PST
Comment on
attachment 451107
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=451107&action=review
>> Source/WebCore/page/SecurityOriginData.h:103 >> + add(hasher, data.protocol, data.host, data.port); > > If we wanted to more closely match the old hash function, this would need to be data.port.value_or(0) unless we want "no port" to hash differently than a port number. We probably do want them distinct just the way this is written, but I noticed it is a difference.
You said this caused the regression. That is very mysterious! Because the == operator does not treat std::nullopt as equal to 0, so it should not matter whether the hash function does or not!
Chris Dumez
Comment 39
2022-02-07 12:29:35 PST
(In reply to Darin Adler from
comment #38
)
> Comment on
attachment 451107
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=451107&action=review
> > >> Source/WebCore/page/SecurityOriginData.h:103 > >> + add(hasher, data.protocol, data.host, data.port); > > > > If we wanted to more closely match the old hash function, this would need to be data.port.value_or(0) unless we want "no port" to hash differently than a port number. We probably do want them distinct just the way this is written, but I noticed it is a difference. > > You said this caused the regression. That is very mysterious! Because the == > operator does not treat std::nullopt as equal to 0, so it should not matter > whether the hash function does or not!
My bet is that this has to do with conversion of SecurityOriginData to and from String. In particular, the databaseIdentifier() / fromDatabaseIdentifier() implementation seem to treat a port that is 0 the same way has not having a port.
Darin Adler
Comment 40
2022-02-07 12:45:07 PST
Still kind of mysterious, because in any context where we are converting to a string, then we should be hashing the string.
Chris Dumez
Comment 41
2022-02-07 12:57:40 PST
(In reply to Darin Adler from
comment #40
)
> Still kind of mysterious, because in any context where we are converting to > a string, then we should be hashing the string.
What I meant was: 1. Add a SecurityOriginData S1 "
http://foo:0
" to a HashMap H 2. Convert the SecurityOriginData S1 to a database identifier and save in database 3. Read identifier from database and convert back to a SecurityOriginData S2 "
http://foo
" (because fromDatabaseIdentifier() strips the port). 4. Check if S2 is present in HashMap H -> Says false (should probably say true?) That said, because operator==(S1, S2) would say false before and after my change, then it should say S2 is not in the map, even if the hashes for S1 and S2 were to match... I am perplexed too.
Chris Dumez
Comment 42
2022-02-07 14:16:01 PST
(In reply to Chris Dumez from
comment #41
)
> (In reply to Darin Adler from
comment #40
) > > Still kind of mysterious, because in any context where we are converting to > > a string, then we should be hashing the string. > > What I meant was: > 1. Add a SecurityOriginData S1 "
http://foo:0
" to a HashMap H > 2. Convert the SecurityOriginData S1 to a database identifier and save in > database > 3. Read identifier from database and convert back to a SecurityOriginData S2 > "
http://foo
" (because fromDatabaseIdentifier() strips the port). > 4. Check if S2 is present in HashMap H -> Says false (should probably say > true?) > > That said, because operator==(S1, S2) would say false before and after my > change, then it should say S2 is not in the map, even if the hashes for S1 > and S2 were to match... > > I am perplexed too.
I added some logging and we never hash a SecurityOriginData that has a port that is 0. All security origins getting hashed have a valid port, except for "file://" which has no port. Haven't had any success figuring out yet why the value_or(0) is needed but it is definitely what fixes the test.
Chris Dumez
Comment 43
2022-02-07 14:53:33 PST
Oh, I think I got it. The hashing is actually correct either way. What changes is the order of keys in the map (map of ClientOrigin keys). http/tests/cache-storage/cache-origins.https.html seems to rely on a specific ordering and needs to be fixed.
Darin Adler
Comment 44
2022-02-07 15:06:43 PST
(In reply to Chris Dumez from
comment #43
)
> http/tests/cache-storage/cache-origins.https.html seems to rely on a > specific ordering and needs to be fixed.
Yes, WebKit::CacheStorage::Engine::representation needs to add things to the string in an order not based on hash table ordering.
Darin Adler
Comment 45
2022-02-07 15:07:10 PST
Move the data into an array, sort the array, then build the string, I think.
Chris Dumez
Comment 46
2022-02-07 15:07:45 PST
(In reply to Darin Adler from
comment #45
)
> Move the data into an array, sort the array, then build the string, I think.
I uploaded a proposal at
https://bugs.webkit.org/show_bug.cgi?id=236263
. Just fixing the test.
Chris Dumez
Comment 47
2022-02-07 16:19:09 PST
Comment on
attachment 451136
[details]
Patch Clearing flags on attachment: 451136 Committed
r289247
(
246931@trunk
): <
https://commits.webkit.org/246931@trunk
>
Chris Dumez
Comment 48
2022-02-07 16:19:14 PST
All reviewed patches have been landed. Closing bug.
Jonathan Bedard
Comment 49
2022-02-22 15:00:02 PST
https://results.webkit.org/?suite=layout-tests&test=imported%2Fw3c%2Fweb-platform-tests%2Fworkers%2Fsemantics%2Fmultiple-workers%2F004.html
indicates that
246931@main
caused imported/w3c/web-platform-tests/workers/semantics/multiple-workers/004.html to start flakily failing.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug