WebKit Bugzilla
Attachment 370853 Details for
Bug 198333
: Reestablish WebSWClientConnection in case of network process crash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198333-20190529090916.patch (text/plain), 28.48 KB, created by
youenn fablet
on 2019-05-29 09:09:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-05-29 09:09:17 PDT
Size:
28.48 KB
patch
obsolete
>Subversion Revision: 245849 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a208d52bc4eda0f16355272164410063e59650f5..fb0e5e64891a91c30be77d418a04b330177f4ca2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2019-05-29 Youenn Fablet <youenn@apple.com> >+ >+ Reestablish WebSWClientConnection in case of network process crash >+ https://bugs.webkit.org/show_bug.cgi?id=198333 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Refactor DocumentLoader to no longer take a ref to the SWClientConnection. >+ Instead, store the sessionID and get the SWClientConnection from it. >+ Remove unused code from ServiceWorkerContainer. >+ >+ Test: http/wpt/service-workers/service-worker-networkprocess-crash.html >+ >+ * loader/DocumentLoader.cpp: >+ (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): >+ (WebCore::DocumentLoader::unregisterTemporaryServiceWorkerClient): >+ * loader/DocumentLoader.h: >+ * workers/service/ServiceWorkerContainer.cpp: >+ * workers/service/ServiceWorkerContainer.h: >+ * workers/service/ServiceWorkerJobClient.h: >+ > 2019-05-29 Ludovico de Nittis <ludovico.denittis@collabora.com> > > PlatformEventKeyboardGtk still uses old key aliases >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 900bbe8f18da4eb8056c2e0bac6d50800c85a7c6..8e14552018c270ad12cfdec52a0b66f038cd89bc 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,45 @@ >+2019-05-29 Youenn Fablet <youenn@apple.com> >+ >+ Reestablish WebSWClientConnection in case of network process crash >+ https://bugs.webkit.org/show_bug.cgi?id=198333 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ WebSWClientConnection now takes a RefPtr<IPC::Connection> so that on network process crash, it will set it back to null. >+ On the next call that needs the connection, WebSWClientConnection will reinitialize its underlying IPC connection and its own identifier. >+ Make sure that all code paths requiring this initialization are covered. >+ >+ * WebProcess/Network/NetworkProcessConnection.cpp: >+ (WebKit::NetworkProcessConnection::didClose): >+ (WebKit::NetworkProcessConnection::serviceWorkerConnectionForSession): >+ (WebKit::NetworkProcessConnection::isRegisteredActiveSWClientConnection): >+ (WebKit::NetworkProcessConnection::initializeSWClientConnection): >+ * WebProcess/Network/NetworkProcessConnection.h: >+ * WebProcess/Storage/WebSWClientConnection.cpp: >+ (WebKit::WebSWClientConnection::WebSWClientConnection): >+ (WebKit::WebSWClientConnection::~WebSWClientConnection): >+ (WebKit::WebSWClientConnection::initializeConnectionIfNeeded): >+ (WebKit::WebSWClientConnection::ensureConnectionAndSend): >+ (WebKit::WebSWClientConnection::scheduleJobInServer): >+ (WebKit::WebSWClientConnection::finishFetchingScriptInServer): >+ (WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer): >+ (WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer): >+ (WebKit::WebSWClientConnection::registerServiceWorkerClient): >+ (WebKit::WebSWClientConnection::unregisterServiceWorkerClient): >+ (WebKit::WebSWClientConnection::didResolveRegistrationPromise): >+ (WebKit::WebSWClientConnection::matchRegistration): >+ (WebKit::WebSWClientConnection::runOrDelayTaskForImport): >+ (WebKit::WebSWClientConnection::whenRegistrationReady): >+ (WebKit::WebSWClientConnection::getRegistrations): >+ (WebKit::WebSWClientConnection::startFetch): >+ (WebKit::WebSWClientConnection::cancelFetch): >+ (WebKit::WebSWClientConnection::continueDidReceiveFetchResponse): >+ (WebKit::WebSWClientConnection::connectionToServerLost): >+ (WebKit::WebSWClientConnection::syncTerminateWorker): >+ (WebKit::WebSWClientConnection::serverConnectionIdentifier const): >+ (WebKit::WebSWClientConnection::updateThrottleState): >+ * WebProcess/Storage/WebSWClientConnection.h: >+ > 2019-05-28 Fujii Hironori <Hironori.Fujii@sony.com> > > [WinCairo] REGRESSION(r245186) Crash in NetworkCache::IOChannel::read in http/tests/IndexedDB some tests >diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp >index bd9cef804147bdcb04dda7eb92a85fa18a6c336c..d1d98138d0e7f3b97a04749299edb5c0e5540fcd 100644 >--- a/Source/WebCore/loader/DocumentLoader.cpp >+++ b/Source/WebCore/loader/DocumentLoader.cpp >@@ -1815,18 +1815,20 @@ void DocumentLoader::registerTemporaryServiceWorkerClient(const URL& url) > > m_temporaryServiceWorkerClient = TemporaryServiceWorkerClient { > DocumentIdentifier::generate(), >- *ServiceWorkerProvider::singleton().existingServiceWorkerConnectionForSession(m_frame->page()->sessionID()) >+ m_frame->page()->sessionID() > }; > >+ auto& serviceWorkerConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(m_temporaryServiceWorkerClient->sessionID); >+ > // FIXME: Compute ServiceWorkerClientFrameType appropriately. >- ServiceWorkerClientData data { { m_temporaryServiceWorkerClient->serviceWorkerConnection->serverConnectionIdentifier(), m_temporaryServiceWorkerClient->documentIdentifier }, ServiceWorkerClientType::Window, ServiceWorkerClientFrameType::None, url }; >+ ServiceWorkerClientData data { { serviceWorkerConnection.serverConnectionIdentifier(), m_temporaryServiceWorkerClient->documentIdentifier }, ServiceWorkerClientType::Window, ServiceWorkerClientFrameType::None, url }; > > RefPtr<SecurityOrigin> topOrigin; > if (m_frame->isMainFrame()) > topOrigin = SecurityOrigin::create(url); > else > topOrigin = &m_frame->mainFrame().document()->topOrigin(); >- m_temporaryServiceWorkerClient->serviceWorkerConnection->registerServiceWorkerClient(*topOrigin, WTFMove(data), m_serviceWorkerRegistrationData->identifier, m_frame->loader().userAgent(url)); >+ serviceWorkerConnection.registerServiceWorkerClient(*topOrigin, WTFMove(data), m_serviceWorkerRegistrationData->identifier, m_frame->loader().userAgent(url)); > #else > UNUSED_PARAM(url); > #endif >@@ -1838,7 +1840,8 @@ void DocumentLoader::unregisterTemporaryServiceWorkerClient() > if (!m_temporaryServiceWorkerClient) > return; > >- m_temporaryServiceWorkerClient->serviceWorkerConnection->unregisterServiceWorkerClient(m_temporaryServiceWorkerClient->documentIdentifier); >+ auto& serviceWorkerConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(m_temporaryServiceWorkerClient->sessionID); >+ serviceWorkerConnection.unregisterServiceWorkerClient(m_temporaryServiceWorkerClient->documentIdentifier); > m_temporaryServiceWorkerClient = WTF::nullopt; > #endif > } >diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h >index 59acb7e9f46d5edff41e504b34e7cce94a356c77..7f2697bc5675f56930b52498f2cc08e7ebe485bf 100644 >--- a/Source/WebCore/loader/DocumentLoader.h >+++ b/Source/WebCore/loader/DocumentLoader.h >@@ -611,7 +611,7 @@ private: > Optional<ServiceWorkerRegistrationData> m_serviceWorkerRegistrationData; > struct TemporaryServiceWorkerClient { > DocumentIdentifier documentIdentifier; >- Ref<SWClientConnection> serviceWorkerConnection; >+ PAL::SessionID sessionID; > }; > Optional<TemporaryServiceWorkerClient> m_temporaryServiceWorkerClient; > #endif >diff --git a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >index dfda10d818ac13d160f35429a2245f704732b5f4..b2d2615a1263d16266182004648f90eda69206b5 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >@@ -575,12 +575,6 @@ void ServiceWorkerContainer::destroyJob(ServiceWorkerJob& job) > m_jobMap.remove(job.identifier()); > } > >-SWServerConnectionIdentifier ServiceWorkerContainer::connectionIdentifier() >-{ >- ASSERT(m_swConnection); >- return m_swConnection->serverConnectionIdentifier(); >-} >- > const char* ServiceWorkerContainer::activeDOMObjectName() const > { > return "ServiceWorkerContainer"; >diff --git a/Source/WebCore/workers/service/ServiceWorkerContainer.h b/Source/WebCore/workers/service/ServiceWorkerContainer.h >index 83165f012fd46012f58172e4e39e7821a894e8d3..bc40d060c71bda17ea099b48e84eab25a21ab48a 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContainer.h >+++ b/Source/WebCore/workers/service/ServiceWorkerContainer.h >@@ -103,7 +103,6 @@ private: > void didFinishGetRegistrationRequest(uint64_t requestIdentifier, Optional<ServiceWorkerRegistrationData>&&); > void didFinishGetRegistrationsRequest(uint64_t requestIdentifier, Vector<ServiceWorkerRegistrationData>&&); > >- SWServerConnectionIdentifier connectionIdentifier() final; > DocumentOrWorkerIdentifier contextIdentifier() final; > > SWClientConnection& ensureSWClientConnection(); >diff --git a/Source/WebCore/workers/service/ServiceWorkerJobClient.h b/Source/WebCore/workers/service/ServiceWorkerJobClient.h >index 6c4818ef8fbf4f1c08c92cbd534407ae0ae49056..c09249a9f2c0858e0c2972d2cb0a96a69b880d30 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerJobClient.h >+++ b/Source/WebCore/workers/service/ServiceWorkerJobClient.h >@@ -51,8 +51,6 @@ public: > virtual void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) = 0; > virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String& script, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy) = 0; > virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Exception&&) = 0; >- >- virtual SWServerConnectionIdentifier connectionIdentifier() = 0; > }; > > } // namespace WebCore >diff --git a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >index 8b1ad5edf0e6b90d58c24e615fadc9c7107a5f68..037f71004b77153ab1acd6cd9db6ceea6f8a5897 100644 >--- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >+++ b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >@@ -195,11 +195,9 @@ void NetworkProcessConnection::didClose(IPC::Connection&) > #endif > > #if ENABLE(SERVICE_WORKER) >+ m_swConnectionsByIdentifier.clear(); > for (auto& connection : m_swConnectionsBySession.values()) > connection->connectionToServerLost(); >- >- m_swConnectionsByIdentifier.clear(); >- m_swConnectionsBySession.clear(); > #endif > } > >@@ -262,14 +260,22 @@ WebIDBConnectionToServer& NetworkProcessConnection::idbConnectionToServerForSess > WebSWClientConnection& NetworkProcessConnection::serviceWorkerConnectionForSession(PAL::SessionID sessionID) > { > ASSERT(sessionID.isValid()); >- return *m_swConnectionsBySession.ensure(sessionID, [&] { >- auto connection = WebSWClientConnection::create(m_connection, sessionID); >- >- auto result = m_swConnectionsByIdentifier.add(connection->serverConnectionIdentifier(), connection.ptr()); >- ASSERT_UNUSED(result, result.isNewEntry); >- >- return connection; >+ return *m_swConnectionsBySession.ensure(sessionID, [sessionID] { >+ return WebSWClientConnection::create(sessionID); > }).iterator->value; > } >+ >+SWServerConnectionIdentifier NetworkProcessConnection::initializeSWClientConnection(WebSWClientConnection& connection) >+{ >+ SWServerConnectionIdentifier identifier; >+ bool result = m_connection->sendSync(Messages::NetworkConnectionToWebProcess::EstablishSWServerConnection(connection.sessionID()), Messages::NetworkConnectionToWebProcess::EstablishSWServerConnection::Reply(identifier), 0); >+ ASSERT_UNUSED(result, result); >+ >+ ASSERT(!m_swConnectionsByIdentifier.contains(identifier)); >+ m_swConnectionsByIdentifier.add(identifier, &connection); >+ >+ return identifier; >+} >+ > #endif > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h >index b8b31398517fa28e9ae4dd9c1126bfaa26b27e58..5a9c4dc4bf41e040fea50dea5f9924cd4f812b50 100644 >--- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h >+++ b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h >@@ -29,6 +29,7 @@ > #include "Connection.h" > #include "ShareableResource.h" > #include "WebIDBConnectionToServer.h" >+#include <WebCore/ServiceWorkerTypes.h> > #include <wtf/RefCounted.h> > #include <wtf/text/WTFString.h> > >@@ -74,6 +75,8 @@ public: > #if ENABLE(SERVICE_WORKER) > WebSWClientConnection* existingServiceWorkerConnectionForSession(PAL::SessionID sessionID) { return m_swConnectionsBySession.get(sessionID); } > WebSWClientConnection& serviceWorkerConnectionForSession(PAL::SessionID); >+ >+ WebCore::SWServerConnectionIdentifier initializeSWClientConnection(WebSWClientConnection&); > #endif > > private: >diff --git a/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp b/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp >index bef0422f93331538a9a25cbf01bc83bb68d33203..951e65f6c05b1c5531c80ae3344fb4d540ace35e 100644 >--- a/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp >+++ b/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp >@@ -31,7 +31,7 @@ > #include "DataReference.h" > #include "FormDataReference.h" > #include "Logging.h" >-#include "NetworkConnectionToWebProcessMessages.h" >+#include "NetworkProcessConnection.h" > #include "ServiceWorkerClientFetch.h" > #include "WebCoreArgumentCoders.h" > #include "WebProcess.h" >@@ -51,40 +51,57 @@ namespace WebKit { > using namespace PAL; > using namespace WebCore; > >-WebSWClientConnection::WebSWClientConnection(IPC::Connection& connection, SessionID sessionID) >+ >+WebSWClientConnection::WebSWClientConnection(SessionID sessionID) > : m_sessionID(sessionID) >- , m_connection(connection) > , m_swOriginTable(makeUniqueRef<WebSWOriginTable>()) > { > ASSERT(sessionID.isValid()); >- bool result = sendSync(Messages::NetworkConnectionToWebProcess::EstablishSWServerConnection(sessionID), Messages::NetworkConnectionToWebProcess::EstablishSWServerConnection::Reply(m_identifier)); >+ initializeConnectionIfNeeded(); >+} >+ >+WebSWClientConnection::~WebSWClientConnection() >+{ >+} >+ >+void WebSWClientConnection::initializeConnectionIfNeeded() >+{ >+ if (m_connection) >+ return; >+ >+ auto& networkProcessConnection = WebProcess::singleton().ensureNetworkProcessConnection(); >+ >+ m_connection = &networkProcessConnection.connection(); >+ m_identifier = networkProcessConnection.initializeSWClientConnection(*this); > >- ASSERT_UNUSED(result, result); > updateThrottleState(); > } > >-WebSWClientConnection::~WebSWClientConnection() >+template<typename U> >+void WebSWClientConnection::ensureConnectionAndSend(const U& message) > { >+ initializeConnectionIfNeeded(); >+ send(message); > } > > void WebSWClientConnection::scheduleJobInServer(const ServiceWorkerJobData& jobData) > { >- send(Messages::WebSWServerConnection::ScheduleJobInServer(jobData)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::ScheduleJobInServer(jobData)); > } > > void WebSWClientConnection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result) > { >- send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result)); > } > > void WebSWClientConnection::addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier identifier) > { >- send(Messages::WebSWServerConnection::AddServiceWorkerRegistrationInServer(identifier)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::AddServiceWorkerRegistrationInServer(identifier)); > } > > void WebSWClientConnection::removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier identifier) > { >- send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(identifier)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(identifier)); > } > > void WebSWClientConnection::postMessageToServiceWorker(ServiceWorkerIdentifier destinationIdentifier, MessageWithMessagePorts&& message, const ServiceWorkerOrClientIdentifier& sourceIdentifier) >@@ -96,17 +113,17 @@ void WebSWClientConnection::postMessageToServiceWorker(ServiceWorkerIdentifier d > > void WebSWClientConnection::registerServiceWorkerClient(const SecurityOrigin& topOrigin, const WebCore::ServiceWorkerClientData& data, const Optional<WebCore::ServiceWorkerRegistrationIdentifier>& controllingServiceWorkerRegistrationIdentifier, const String& userAgent) > { >- send(Messages::WebSWServerConnection::RegisterServiceWorkerClient { topOrigin.data(), data, controllingServiceWorkerRegistrationIdentifier, userAgent }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::RegisterServiceWorkerClient { topOrigin.data(), data, controllingServiceWorkerRegistrationIdentifier, userAgent }); > } > > void WebSWClientConnection::unregisterServiceWorkerClient(DocumentIdentifier contextIdentifier) > { >- send(Messages::WebSWServerConnection::UnregisterServiceWorkerClient { ServiceWorkerClientIdentifier { serverConnectionIdentifier(), contextIdentifier } }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::UnregisterServiceWorkerClient { ServiceWorkerClientIdentifier { serverConnectionIdentifier(), contextIdentifier } }); > } > > void WebSWClientConnection::didResolveRegistrationPromise(const ServiceWorkerRegistrationKey& key) > { >- send(Messages::WebSWServerConnection::DidResolveRegistrationPromise(key)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::DidResolveRegistrationPromise(key)); > } > > bool WebSWClientConnection::mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData& origin) const >@@ -157,23 +174,25 @@ void WebSWClientConnection::matchRegistration(SecurityOriginData&& topOrigin, co > runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = WTFMove(topOrigin), clientURL]() mutable { > uint64_t callbackID = ++m_previousCallbackIdentifier; > m_ongoingMatchRegistrationTasks.add(callbackID, WTFMove(callback)); >- send(Messages::WebSWServerConnection::MatchRegistration(callbackID, topOrigin, clientURL)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::MatchRegistration(callbackID, topOrigin, clientURL)); > }); > } > > void WebSWClientConnection::runOrDelayTaskForImport(WTF::Function<void()>&& task) > { >- if (m_swOriginTable->isImported()) >+ if (m_swOriginTable->isImported()) { > task(); >- else >- m_tasksPendingOriginImport.append(WTFMove(task)); >+ return; >+ } >+ m_tasksPendingOriginImport.append(WTFMove(task)); >+ initializeConnectionIfNeeded(); > } > > void WebSWClientConnection::whenRegistrationReady(const SecurityOrigin& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&& callback) > { > uint64_t callbackID = ++m_previousCallbackIdentifier; > m_ongoingRegistrationReadyTasks.add(callbackID, WTFMove(callback)); >- send(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, topOrigin.data(), clientURL)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, topOrigin.data(), clientURL)); > } > > void WebSWClientConnection::registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&& registrationData) >@@ -195,27 +214,29 @@ void WebSWClientConnection::getRegistrations(SecurityOriginData&& topOrigin, con > runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = WTFMove(topOrigin), clientURL]() mutable { > uint64_t callbackID = ++m_previousCallbackIdentifier; > m_ongoingGetRegistrationsTasks.add(callbackID, WTFMove(callback)); >- send(Messages::WebSWServerConnection::GetRegistrations(callbackID, topOrigin, clientURL)); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::GetRegistrations(callbackID, topOrigin, clientURL)); > }); > } > > void WebSWClientConnection::startFetch(FetchIdentifier fetchIdentifier, ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier, const ResourceRequest& request, const FetchOptions& options, const String& referrer) > { >- send(Messages::WebSWServerConnection::StartFetch { serviceWorkerRegistrationIdentifier, fetchIdentifier, request, options, IPC::FormDataReference { request.httpBody() }, referrer }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::StartFetch { serviceWorkerRegistrationIdentifier, fetchIdentifier, request, options, IPC::FormDataReference { request.httpBody() }, referrer }); > } > > void WebSWClientConnection::cancelFetch(FetchIdentifier fetchIdentifier, ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier) > { >- send(Messages::WebSWServerConnection::CancelFetch { serviceWorkerRegistrationIdentifier, fetchIdentifier }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::CancelFetch { serviceWorkerRegistrationIdentifier, fetchIdentifier }); > } > > void WebSWClientConnection::continueDidReceiveFetchResponse(FetchIdentifier fetchIdentifier, ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier) > { >- send(Messages::WebSWServerConnection::ContinueDidReceiveFetchResponse { serviceWorkerRegistrationIdentifier, fetchIdentifier }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::ContinueDidReceiveFetchResponse { serviceWorkerRegistrationIdentifier, fetchIdentifier }); > } > > void WebSWClientConnection::connectionToServerLost() > { >+ m_connection = nullptr; >+ > auto registrationTasks = WTFMove(m_ongoingMatchRegistrationTasks); > for (auto& callback : registrationTasks.values()) > callback(WTF::nullopt); >@@ -229,13 +250,21 @@ void WebSWClientConnection::connectionToServerLost() > > void WebSWClientConnection::syncTerminateWorker(ServiceWorkerIdentifier identifier) > { >+ initializeConnectionIfNeeded(); >+ > sendSync(Messages::WebSWServerConnection::SyncTerminateWorkerFromClient(identifier), Messages::WebSWServerConnection::SyncTerminateWorkerFromClient::Reply()); > } > >+WebCore::SWServerConnectionIdentifier WebSWClientConnection::serverConnectionIdentifier() const >+{ >+ const_cast<WebSWClientConnection*>(this)->initializeConnectionIfNeeded(); >+ return m_identifier; >+} >+ > void WebSWClientConnection::updateThrottleState() > { > m_isThrottleable = WebProcess::singleton().areAllPagesThrottleable(); >- send(Messages::WebSWServerConnection::SetThrottleState { m_isThrottleable }); >+ ensureConnectionAndSend(Messages::WebSWServerConnection::SetThrottleState { m_isThrottleable }); > } > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h b/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h >index 5177a34913b0d3a2f78afeb1be9910cea889e321..1ee72844648b09eff6016c3161ebbc3e132909ba 100644 >--- a/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h >+++ b/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h >@@ -47,12 +47,12 @@ namespace WebKit { > class WebSWOriginTable; > class WebServiceWorkerProvider; > >-class WebSWClientConnection final : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver { >+class WebSWClientConnection final : public WebCore::SWClientConnection, private IPC::MessageSender, public IPC::MessageReceiver { > public: >- static Ref<WebSWClientConnection> create(IPC::Connection& connection, PAL::SessionID sessionID) { return adoptRef(*new WebSWClientConnection { connection, sessionID }); } >+ static Ref<WebSWClientConnection> create(PAL::SessionID sessionID) { return adoptRef(*new WebSWClientConnection { sessionID }); } > ~WebSWClientConnection(); > >- WebCore::SWServerConnectionIdentifier serverConnectionIdentifier() const final { return m_identifier; } >+ WebCore::SWServerConnectionIdentifier serverConnectionIdentifier() const final; > > void addServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier) final; > void removeServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier) final; >@@ -69,8 +69,12 @@ public: > > void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final; > >+ PAL::SessionID sessionID() const { return m_sessionID; } >+ > private: >- WebSWClientConnection(IPC::Connection&, PAL::SessionID); >+ explicit WebSWClientConnection(PAL::SessionID); >+ >+ void initializeConnectionIfNeeded(); > > void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final; > void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final; >@@ -94,16 +98,18 @@ private: > > void runOrDelayTaskForImport(WTF::Function<void()>&& task); > >- IPC::Connection* messageSenderConnection() const final { return m_connection.ptr(); } >+ IPC::Connection* messageSenderConnection() const final { return m_connection.get(); } > uint64_t messageSenderDestinationID() const final { return m_identifier.toUInt64(); } > > void setSWOriginTableSharedMemory(const SharedMemory::Handle&); > void setSWOriginTableIsImported(); > >+ template<typename U> void ensureConnectionAndSend(const U& message); >+ > PAL::SessionID m_sessionID; > WebCore::SWServerConnectionIdentifier m_identifier; > >- Ref<IPC::Connection> m_connection; >+ RefPtr<IPC::Connection> m_connection; > UniqueRef<WebSWOriginTable> m_swOriginTable; > > uint64_t m_previousCallbackIdentifier { 0 }; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 51dd24fe0d9c614c37777738f94b69bec7c9111a..45d2e9fa2f053f7baad1ca18da406c156aa557c0 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2019-05-29 Youenn Fablet <youenn@apple.com> >+ >+ Reestablish WebSWClientConnection in case of network process crash >+ https://bugs.webkit.org/show_bug.cgi?id=198333 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt: Added. >+ * http/wpt/service-workers/service-worker-networkprocess-crash.html: Added. >+ > 2019-05-28 Yacine Bandou <yacine.bandou@softathome.com> > > [MSE][GStreamer] update the readyState correctly in MediaPlayerPrivateGStreamerMSE >diff --git a/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt b/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..12dea0fb91b10416d049bc61329def990d3ebea6 >--- /dev/null >+++ b/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt >@@ -0,0 +1,5 @@ >+ >+PASS Setup worker >+PASS Frame being controlled >+PASS Frame being controlled after network process crash >+ >diff --git a/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html b/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html >new file mode 100644 >index 0000000000000000000000000000000000000000..80420c2ee047810fe5101a201ba76c8f3d5a8b86 >--- /dev/null >+++ b/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html >@@ -0,0 +1,58 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<title>Cache Storage: network process crash</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+</head> >+<body> >+<script> >+var scope = "/WebKit/service-workers/resources"; >+ >+function withFrame(url) >+{ >+ return new Promise((resolve) => { >+ let frame = document.createElement('iframe'); >+ frame.src = url; >+ frame.onload = function() { resolve(frame); }; >+ document.body.appendChild(frame); >+ }); >+} >+ >+async function registerServiceWorker() >+{ >+ var registration = await navigator.serviceWorker.register("fetchEvent-worker.js", { scope : scope }); >+ var activeWorker = registration.active; >+ if (activeWorker) >+ return; >+ activeWorker = registration.installing; >+ return new Promise(resolve => { >+ activeWorker.addEventListener('statechange', () => { >+ if (activeWorker.state === "activated") >+ resolve(registration); >+ }); >+ }); >+} >+ >+promise_test(async (test) => { >+ await registerServiceWorker(); >+}, "Setup worker"); >+ >+promise_test(async (test) => { >+ const frame = await withFrame(scope + "/empty.html"); >+ assert_not_equals(frame.contentWindow.navigator.serviceWorker.controller, null); >+ frame.remove(); >+}, "Frame being controlled"); >+ >+promise_test(async (test) => { >+ if (window.testRunner && window.testRunner.terminateNetworkProcess) >+ testRunner.terminateNetworkProcess(); >+ >+ const frame = await withFrame(scope + "/empty.html"); >+ assert_not_equals(frame.contentWindow.navigator.serviceWorker.controller, null); >+ frame.remove(); >+}, "Frame being controlled after network process crash"); >+</script> >+</body> >+</html> >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198333
: 370853