WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
201459
Use WebProcess processIdentifier to identify Service Worker connections
https://bugs.webkit.org/show_bug.cgi?id=201459
Summary
Use WebProcess processIdentifier to identify Service Worker connections
youenn fablet
Reported
2019-09-04 07:26:52 PDT
Use WebProcess processIdentifier to identify Service Worker connections
Attachments
Patch
(82.81 KB, patch)
2019-09-05 01:06 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(82.81 KB, patch)
2019-09-05 02:03 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(82.81 KB, patch)
2019-09-05 02:21 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(82.81 KB, patch)
2019-09-05 02:34 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(83.07 KB, patch)
2019-09-05 03:30 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(83.25 KB, patch)
2019-09-05 06:55 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(83.01 KB, patch)
2019-09-06 03:14 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(84.13 KB, patch)
2019-09-06 09:41 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(85.18 KB, patch)
2019-09-09 02:50 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch for landing
(86.22 KB, patch)
2019-09-12 00:00 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(86.30 KB, patch)
2019-09-13 04:29 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(10)
View All
Add attachment
proposed patch, testcase, etc.
youenn fablet
Comment 1
2019-09-05 01:06:27 PDT
Created
attachment 378055
[details]
Patch
youenn fablet
Comment 2
2019-09-05 02:03:44 PDT
Created
attachment 378064
[details]
Patch
youenn fablet
Comment 3
2019-09-05 02:21:32 PDT
Created
attachment 378067
[details]
Patch
youenn fablet
Comment 4
2019-09-05 02:34:34 PDT
Created
attachment 378068
[details]
Patch
youenn fablet
Comment 5
2019-09-05 03:30:35 PDT
Created
attachment 378073
[details]
Patch
youenn fablet
Comment 6
2019-09-05 06:55:57 PDT
Created
attachment 378078
[details]
Patch
youenn fablet
Comment 7
2019-09-06 03:14:43 PDT
Created
attachment 378180
[details]
Patch
Chris Dumez
Comment 8
2019-09-06 08:27:08 PDT
Comment on
attachment 378180
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=378180&action=review
> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > + HashMap<uint64_t, WeakPtr<WebSWServerConnection>> m_swConnections;
Going from a strong identifier type to uint64_t seems like a pretty bad regression for me :/
youenn fablet
Comment 9
2019-09-06 08:36:21 PDT
(In reply to Chris Dumez from
comment #8
)
> Comment on
attachment 378180
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=378180&action=review
> > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > > + HashMap<uint64_t, WeakPtr<WebSWServerConnection>> m_swConnections; > > Going from a strong identifier type to uint64_t seems like a pretty bad > regression for me :/
This is not a regression. This map is an internal detail of NetworkConnectionToWebProcess that is not exposed anywhere else. It is used to get a connection from a decoderId which is a uint64_t. I can make the map take a PAL::SessionID, in which case I will need to add a way to create a PAL::SessionID from a uint64_t (similarly to makeObjectIdentifier). I thought this was not really needed but can change the patch accordingly, this might improve the readability of the code.
Chris Dumez
Comment 10
2019-09-06 08:48:40 PDT
(In reply to youenn fablet from
comment #9
)
> (In reply to Chris Dumez from
comment #8
) > > Comment on
attachment 378180
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=378180&action=review
> > > > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > > > + HashMap<uint64_t, WeakPtr<WebSWServerConnection>> m_swConnections; > > > > Going from a strong identifier type to uint64_t seems like a pretty bad > > regression for me :/ > > This is not a regression. > This map is an internal detail of NetworkConnectionToWebProcess that is not > exposed anywhere else. > It is used to get a connection from a decoderId which is a uint64_t. > I can make the map take a PAL::SessionID, in which case I will need to add a > way to create a PAL::SessionID from a uint64_t (similarly to > makeObjectIdentifier). > I thought this was not really needed but can change the patch accordingly, > this might improve the readability of the code.
If it is really a sessionID then I think it should use the PAL::SessionID type, even if it means converting IPC ids to strong identifiers in a couple of places. Strong identifier types are safer and improve readability a lot.
youenn fablet
Comment 11
2019-09-06 09:41:35 PDT
Created
attachment 378201
[details]
Patch
Chris Dumez
Comment 12
2019-09-06 09:55:36 PDT
Comment on
attachment 378201
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=378201&action=review
> Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:65 > + : SWServer::Connection(server, makeObjectIdentifier<SWServerConnectionIdentifierType>(processIdentifier.toUInt64()))
This is very weird, seems like terrible practice to convert one ID type to another.
> Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp:60 > + , m_identifier(makeObjectIdentifier<SWServerConnectionIdentifierType>(Process::identifier().toUInt64()))
ditto.
youenn fablet
Comment 13
2019-09-09 02:50:08 PDT
Created
attachment 378359
[details]
Patch
Chris Dumez
Comment 14
2019-09-09 08:46:31 PDT
Comment on
attachment 378359
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
> Source/WebCore/ChangeLog:3 > + Use WebProcess processIdentifier to identify Service Worker connections
This change log does not explain why we're making this change, what was used before to identify the connections and why the new approach is better?
> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > + HashMap<PAL::SessionID, WeakPtr<WebSWServerConnection>> m_swConnections;
It does not look to me that we're going in the right direction. We want 1 sessionID per WebContent process so doing to a HashMap of SessionID on the NetworkConnectionToWebProcess does not make sense to me.
youenn fablet
Comment 15
2019-09-09 09:17:06 PDT
(In reply to Chris Dumez from
comment #14
)
> Comment on
attachment 378359
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
> > > Source/WebCore/ChangeLog:3 > > + Use WebProcess processIdentifier to identify Service Worker connections > > This change log does not explain why we're making this change, what was used > before to identify the connections and why the new approach is better?
The change log says that these IDs are stable over network process crash. This makes the network process crash handling easier and more robust on WebProcess side. The change log also says that this removes a sync IPC. We generally want to avoid sync IPC.
> > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > > + HashMap<PAL::SessionID, WeakPtr<WebSWServerConnection>> m_swConnections; > > It does not look to me that we're going in the right direction. We want 1 > sessionID per WebContent process so doing to a HashMap of SessionID on the > NetworkConnectionToWebProcess does not make sense to me.
We need this map to preserve status quo and make sure service workers are working properly. This patch is actually helping if we want to do the simplification of one sessionID per web process. We will just have to go from two sessionID-based maps (one in web process and one in network process) to singletons. This should be very straightforward compared to the current code base where we have 3 maps, two of them being not keyed by session IDs.
youenn fablet
Comment 16
2019-09-09 09:24:40 PDT
Third benefit in change log I forgot to mention here is the changes to WebSWServerToContextConnection which will make it possible to run service workers in web processes that also run pages.
Chris Dumez
Comment 17
2019-09-09 09:26:24 PDT
(In reply to youenn fablet from
comment #15
)
> (In reply to Chris Dumez from
comment #14
) > > Comment on
attachment 378359
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
> > > > > Source/WebCore/ChangeLog:3 > > > + Use WebProcess processIdentifier to identify Service Worker connections > > > > This change log does not explain why we're making this change, what was used > > before to identify the connections and why the new approach is better? > > The change log says that these IDs are stable over network process crash. > This makes the network process crash handling easier and more robust on > WebProcess side. > > The change log also says that this removes a sync IPC. > We generally want to avoid sync IPC. > > > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > > > + HashMap<PAL::SessionID, WeakPtr<WebSWServerConnection>> m_swConnections; > > > > It does not look to me that we're going in the right direction. We want 1 > > sessionID per WebContent process so doing to a HashMap of SessionID on the > > NetworkConnectionToWebProcess does not make sense to me. > > We need this map to preserve status quo and make sure service workers are > working properly. > > This patch is actually helping if we want to do the simplification of one > sessionID per web process. We will just have to go from two sessionID-based > maps (one in web process and one in network process) to singletons. This > should be very straightforward compared to the current code base where we > have 3 maps, two of them being not keyed by session IDs.
I do still have concerns about refactoring code that is wrong (before fixing what is wrong about it) and potentially making it harder to fix the bug by reinforcing the bad design. My preference would be to first stop sharing service worker processes for sessionIDs and then refactor. Having a HashMap of sessionIDs on a connection to the webProcess looks very wrong.
Chris Dumez
Comment 18
2019-09-09 09:31:27 PDT
(In reply to Chris Dumez from
comment #17
)
> (In reply to youenn fablet from
comment #15
) > > (In reply to Chris Dumez from
comment #14
) > > > Comment on
attachment 378359
[details]
> > > Patch > > > > > > View in context: > > >
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
> > > > > > > Source/WebCore/ChangeLog:3 > > > > + Use WebProcess processIdentifier to identify Service Worker connections > > > > > > This change log does not explain why we're making this change, what was used > > > before to identify the connections and why the new approach is better? > > > > The change log says that these IDs are stable over network process crash. > > This makes the network process crash handling easier and more robust on > > WebProcess side. > > > > The change log also says that this removes a sync IPC. > > We generally want to avoid sync IPC. > > > > > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:324 > > > > + HashMap<PAL::SessionID, WeakPtr<WebSWServerConnection>> m_swConnections; > > > > > > It does not look to me that we're going in the right direction. We want 1 > > > sessionID per WebContent process so doing to a HashMap of SessionID on the > > > NetworkConnectionToWebProcess does not make sense to me. > > > > We need this map to preserve status quo and make sure service workers are > > working properly. > > > > This patch is actually helping if we want to do the simplification of one > > sessionID per web process. We will just have to go from two sessionID-based > > maps (one in web process and one in network process) to singletons. This > > should be very straightforward compared to the current code base where we > > have 3 maps, two of them being not keyed by session IDs. > > I do still have concerns about refactoring code that is wrong (before fixing > what is wrong about it) and potentially making it harder to fix the bug by > reinforcing the bad design. > My preference would be to first stop sharing service worker processes for > sessionIDs and then refactor. Having a HashMap of sessionIDs on a connection > to the webProcess looks very wrong.
And by. the way, I do not mind doing the work for having separate service worker processes per session if you'd like. The only reason I have not done so last week is because this patch is blocking me.
youenn fablet
Comment 19
2019-09-09 11:47:09 PDT
> I do still have concerns about refactoring code that is wrong (before fixing > what is wrong about it) and potentially making it harder to fix the bug by > reinforcing the bad design.
I don't think there is consensus yet to stop sharing web processes for service worker with different sessionIDs. This is the current implementation, it works and there are some known perf benefits. Agreed there are some potential privacy risks, that would be nice to fix. To fix this bug, the patch will mostly change UIProcess code, not code doing WebProcess/NetworkProcess communication, which is the part you seem to be against. So this part of the patch is not making it harder to fix it in any way. In fact, the is actually getting us closer to the fix. The current code base is not always giving the session ID when creating a service worker process. With the patch, the service worker process is always launched with a known session ID (see WebProcessPool::establishWorkerContextConnectionToNetworkProcess). This patch is also helpful for simplifications to the code base when service workers are sessionID partitioned.
> My preference would be to first stop sharing service worker processes for > sessionIDs and then refactor. Having a HashMap of sessionIDs on a connection > to the webProcess looks very wrong.
I think we should continue with the plan to run service workers in existing web processes that run pages. Once done (and we are not too far), the bug you mention will be fixed.
Chris Dumez
Comment 20
2019-09-09 12:26:48 PDT
(In reply to youenn fablet from
comment #19
)
> > I do still have concerns about refactoring code that is wrong (before fixing > > what is wrong about it) and potentially making it harder to fix the bug by > > reinforcing the bad design. > > I don't think there is consensus yet to stop sharing web processes for > service worker with different sessionIDs.
This exact issue had to be fixed before shipping PSON, service workers are not any different. This has to be fixed asap.
Chris Dumez
Comment 21
2019-09-09 12:27:44 PDT
(In reply to Chris Dumez from
comment #20
)
> (In reply to youenn fablet from
comment #19
) > > > I do still have concerns about refactoring code that is wrong (before fixing > > > what is wrong about it) and potentially making it harder to fix the bug by > > > reinforcing the bad design. > > > > I don't think there is consensus yet to stop sharing web processes for > > service worker with different sessionIDs. > > This exact issue had to be fixed before shipping PSON, service workers are > not any different. This has to be fixed asap.
+ Geoff. Brady & Alex are already in cc and are also familiar with this matter.
Chris Dumez
Comment 22
2019-09-09 12:31:18 PDT
(In reply to youenn fablet from
comment #19
)
> > I do still have concerns about refactoring code that is wrong (before fixing > > what is wrong about it) and potentially making it harder to fix the bug by > > reinforcing the bad design. > > I don't think there is consensus yet to stop sharing web processes for > service worker with different sessionIDs. > This is the current implementation, it works and there are some known perf > benefits. Agreed there are some potential privacy risks, that would be nice > to fix.
> To fix this bug, the patch will mostly change UIProcess code, not code doing > WebProcess/NetworkProcess communication, which is the part you seem to be > against. So this part of the patch is not making it harder to fix it in any > way.
I had started to write that patch (split Service workers by sessionID) and had to stop when I saw your refactoring patch because we are clearly touching the same code. I also think the priority should be to fix our security / privacy issue before refactoring code to help with performance.
Geoffrey Garen
Comment 23
2019-09-09 17:09:28 PDT
> I don't think there is consensus yet to stop sharing web processes for > service worker with different sessionIDs. > This is the current implementation, it works and there are some known perf > benefits. Agreed there are some potential privacy risks, that would be nice > to fix.
I didn't read the rest of the discussion, but I want to comment on this detail: It is a Privacy requirement not to share the same web process for distinct sessionIDs. You can read more in <
rdar://problem/48421064
>.
Chris Dumez
Comment 24
2019-09-11 08:50:59 PDT
Comment on
attachment 378359
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
r=me, let's split the sessions in a follow-up.
> Source/WebCore/workers/service/ServiceWorkerTypes.h:75 > using SWServerConnectionIdentifier = ObjectIdentifier<SWServerConnectionIdentifierType>;
Why isn't this simply using SWServerConnectionIdentifier = ProcessIdentifier; ?
> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:298 > + sessionID = server.sessionID();
Seems unfortunate we'll keep iterating even though we've found the sessionID.
> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:893 > + m_swContextConnection = WebSWServerToContextConnection::create(m_networkProcess, registrableDomain, m_connection.get());
WTFMove(registrableDomain) ?
> Source/WebKit/UIProcess/WebProcessPool.cpp:699 > + WebsiteDataStore* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID);
auto*
youenn fablet
Comment 25
2019-09-11 23:23:39 PDT
(In reply to Chris Dumez from
comment #24
)
> Comment on
attachment 378359
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=378359&action=review
> > r=me, let's split the sessions in a follow-up. > > > Source/WebCore/workers/service/ServiceWorkerTypes.h:75 > > using SWServerConnectionIdentifier = ObjectIdentifier<SWServerConnectionIdentifierType>; > > Why isn't this simply using SWServerConnectionIdentifier = > ProcessIdentifier; ?
There are some uses of makeObjectIdentifier<SWServerConnectionIdentifierType> We could rewrite them as makeObjectIdentifier<ProcessIdentifierType> but that seems a bit weird.
> > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:298 > > + sessionID = server.sessionID(); > > Seems unfortunate we'll keep iterating even though we've found the sessionID.
We need to iterate other all SWServers, so that all related service worker states get updated. This code will go away with next patch (
bug 201643
).
> > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:893 > > + m_swContextConnection = WebSWServerToContextConnection::create(m_networkProcess, registrableDomain, m_connection.get()); > > WTFMove(registrableDomain) ?
This refactoring is done in next patch (
bug 201643
) where we touch the constructor.
> > Source/WebKit/UIProcess/WebProcessPool.cpp:699 > > + WebsiteDataStore* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID); > > auto*
OK
youenn fablet
Comment 26
2019-09-12 00:00:55 PDT
Created
attachment 378626
[details]
Patch for landing
WebKit Commit Bot
Comment 27
2019-09-12 01:18:22 PDT
Comment on
attachment 378626
[details]
Patch for landing Clearing flags on attachment: 378626 Committed
r249801
: <
https://trac.webkit.org/changeset/249801
>
WebKit Commit Bot
Comment 28
2019-09-12 01:18:24 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 29
2019-09-12 01:19:19 PDT
<
rdar://problem/55293963
>
Ryan Haddad
Comment 30
2019-09-12 15:58:55 PDT
This change has caused http/tests/workers/service/postmessage-after-sw-process-crash.https.html to frequently fail and http/tests/workers/service/postmessage-after-terminate.https.html to frequently time out Mojave / iOS 12 Release WK2 bots --- /Volumes/Data/slave/ios-simulator-12-release-tests-wk2/build/layout-test-results/http/tests/workers/service/postmessage-after-sw-process-crash.https-expected.txt +++ /Volumes/Data/slave/ios-simulator-12-release-tests-wk2/build/layout-test-results/http/tests/workers/service/postmessage-after-sw-process-crash.https-actual.txt @@ -1,5 +1,5 @@ * Sending State to Service Worker * Asking Service Worker if it received the state * Simulating Service Worker process crash -PASS: service worker lost the state and responded the postMessage after process termination +FAIL: service worker did not respond after process termination
https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=http%2Ftests%2Fworkers%2Fservice%2Fpostmessage-after-sw-process-crash.https.html%20http%2Ftests%2Fworkers%2Fservice%2Fpostmessage-after-terminate.https.html
Ryan Haddad
Comment 31
2019-09-12 16:59:39 PDT
Reverted
r249801
for reason: Caused two servier worker layout tests to become flaky. Committed
r249820
: <
https://trac.webkit.org/changeset/249820
>
youenn fablet
Comment 32
2019-09-13 04:28:07 PDT
(In reply to Ryan Haddad from
comment #31
)
> Reverted
r249801
for reason: > > Caused two servier worker layout tests to become flaky. > > Committed
r249820
: <
https://trac.webkit.org/changeset/249820
>
There was a race condition between destruction of the old context connection and the new one, which is screwing the connection map. I updated the patch to destroy the WebSWServerToContextConnection just after it gets closed.
youenn fablet
Comment 33
2019-09-13 04:29:21 PDT
Created
attachment 378723
[details]
Patch
WebKit Commit Bot
Comment 34
2019-09-13 05:32:56 PDT
Comment on
attachment 378723
[details]
Patch Clearing flags on attachment: 378723 Committed
r249832
: <
https://trac.webkit.org/changeset/249832
>
WebKit Commit Bot
Comment 35
2019-09-13 05:32:58 PDT
All reviewed patches have been landed. Closing bug.
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