Skip to content

Commit

Permalink
Cherry-pick 7a4f947. rdar://problem/108884055
Browse files Browse the repository at this point in the history
    Webkit PWA in Bad State After Opening in-PWA Webkit Tab
    https://bugs.webkit.org/show_bug.cgi?id=256280
    rdar://108884055

    Reviewed by Chris Dumez.

    Network process is registerng a process with pages as service worker clients to a given service worker process.
    This allows UIProcess to suspend/resume the service worker process based on all its registered processes.
    Our logic to register page processes is working fine.
    Our logic to unregister page processes is not working fine if the same process has clients with different origins but the same registrable domain,
    for instance a process with a page 'a.example.org' and another page 'b.example.org'.
    In that case, when the 'b.example.org' page is gone, we would unregister the process while 'a.example.org' is still running.

    We update WebSWServerConnection::unregisterServiceWorkerClient to check for registrable domains of all pages.

    Manually tested, we cannot yet write tests with different registrable domains that make use of service workers.

    * Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
    (WebKit::WebSWServerConnection::unregisterServiceWorkerClient):

    Canonical link: https://commits.webkit.org/263901@main

Identifier: 259548.789@safari-7615-branch
  • Loading branch information
youennf authored and MyahCobbs committed May 30, 2023
1 parent 0292d56 commit 20c4a32
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,12 @@ void WebSWServerConnection::unregisterServiceWorkerClient(const ScriptExecutionC
});

if (isDeletedOrigin) {
if (auto* contextConnection = server().contextConnectionForRegistrableDomain(RegistrableDomain { clientOrigin.clientOrigin })) {
auto& connection = static_cast<WebSWServerToContextConnection&>(*contextConnection);
m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::UnregisterRemoteWorkerClientProcess { RemoteWorkerType::ServiceWorker, identifier(), connection.webProcessIdentifier() }, 0);
RegistrableDomain potentiallyRemovedDomain { clientOrigin.clientOrigin };
if (!hasMatchingClient(potentiallyRemovedDomain)) {
if (auto* contextConnection = server().contextConnectionForRegistrableDomain(potentiallyRemovedDomain)) {
auto& connection = static_cast<WebSWServerToContextConnection&>(*contextConnection);
m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::UnregisterRemoteWorkerClientProcess { RemoteWorkerType::ServiceWorker, identifier(), connection.webProcessIdentifier() }, 0);
}
}
}
}
Expand Down

0 comments on commit 20c4a32

Please sign in to comment.