REGRESSION: Crash beneath ResourceLoadObserver::logSubresourceLoading
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2019 00:57:37 +0000 (00:57 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2019 00:57:37 +0000 (00:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195072

Reviewed by Ryosuke Niwa.

ResourceLoadObserver and WebProcess should exist as long as the web page (process) is running. However,
the NetworkProcess connection can close for a variety of reasons. If the ResourceLoadObserver observes
a load or user gesture in the WebProcess, we should attempt to reconnect to the NetworkProcess (if it
was disconnected), just like we do for other message send cases.

This patch switches from using the m_networkProcessConnection member (which might be null) to use the
'ensureNetworkProcessConnection' accessor which ensures we have a valid connection for message sends.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242183 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebProcess.cpp

index 7f96bf5..93d9838 100644 (file)
@@ -1,3 +1,21 @@
+2019-02-27  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION: Crash beneath ResourceLoadObserver::logSubresourceLoading
+        https://bugs.webkit.org/show_bug.cgi?id=195072
+
+        Reviewed by Ryosuke Niwa.
+
+        ResourceLoadObserver and WebProcess should exist as long as the web page (process) is running. However,
+        the NetworkProcess connection can close for a variety of reasons. If the ResourceLoadObserver observes
+        a load or user gesture in the WebProcess, we should attempt to reconnect to the NetworkProcess (if it
+        was disconnected), just like we do for other message send cases.
+
+        This patch switches from using the m_networkProcessConnection member (which might be null) to use the
+        'ensureNetworkProcessConnection' accessor which ensures we have a valid connection for message sends.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+
 2019-02-27  Chris Dumez  <cdumez@apple.com>
 
         Flaky API Test: TestWebKitAPI.ProcessSwap.SessionStorage
index 133fb48..b868770 100644 (file)
@@ -209,7 +209,7 @@ WebProcess::WebProcess()
     ResourceLoadObserver::shared().setNotificationCallback([this] (Vector<ResourceLoadStatistics>&& statistics) {
         parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);
 
-        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::RequestResourceLoadStatisticsUpdate(), 0);
+        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RequestResourceLoadStatisticsUpdate(), 0);
     });
 
     ResourceLoadObserver::shared().setRequestStorageAccessUnderOpenerCallback([this] (const RegistrableDomain& domainInNeedOfStorageAccess, uint64_t openerPageID, const RegistrableDomain& openerDomain) {
@@ -404,19 +404,19 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& domain) {
-        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, domain), 0);
+        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, domain), 0);
     });
 
     ResourceLoadObserver::shared().setLogWebSocketLoadingNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) {
-        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogWebSocketLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0);
+        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogWebSocketLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0);
     });
     
     ResourceLoadObserver::shared().setLogSubresourceLoadingNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) {
-        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0);
+        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0);
     });
 
     ResourceLoadObserver::shared().setLogSubresourceRedirectNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain) {
-        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceRedirect(sessionID, sourceDomain, targetDomain), 0);
+        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceRedirect(sessionID, sourceDomain, targetDomain), 0);
     });
 #endif