A prewarmed Web process should have a process assertion.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Feb 2019 19:11:57 +0000 (19:11 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Feb 2019 19:11:57 +0000 (19:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195006

Reviewed by Geoffrey Garen.

To make sure the prewarm message is handled in the Web process before the process is suspended,
the process should have a process assertion. This can be fixed by sending the prewarm message
inside WebProcessPool::initializeNewWebProcess, since all message sent inside this method are
guaranteed to be handled before the WebContent process is suspended.

This patch is based on Chris Dumez' idea and obervation of the issue.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::initializeNewWebProcess):
* UIProcess/WebProcessPool.h:

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h

index 1885460..2f9e89e 100644 (file)
@@ -1,3 +1,22 @@
+2019-02-25  Per Arne Vollan  <pvollan@apple.com>
+
+        A prewarmed Web process should have a process assertion.
+        https://bugs.webkit.org/show_bug.cgi?id=195006
+
+        Reviewed by Geoffrey Garen.
+
+        To make sure the prewarm message is handled in the Web process before the process is suspended,
+        the process should have a process assertion. This can be fixed by sending the prewarm message
+        inside WebProcessPool::initializeNewWebProcess, since all message sent inside this method are
+        guaranteed to be handled before the WebContent process is suspended.
+
+        This patch is based on Chris Dumez' idea and obervation of the issue.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::createNewWebProcess):
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        * UIProcess/WebProcessPool.h:
+
 2019-02-25  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Enable PSON
index f3598b8..c9674f9 100644 (file)
@@ -764,14 +764,8 @@ WebProcessProxy& WebProcessPool::createNewWebProcess(WebsiteDataStore& websiteDa
 {
     auto processProxy = WebProcessProxy::create(*this, websiteDataStore, isPrewarmed);
     auto& process = processProxy.get();
-    initializeNewWebProcess(process, websiteDataStore);
+    initializeNewWebProcess(process, websiteDataStore, isPrewarmed);
     m_processes.append(WTFMove(processProxy));
-    if (isPrewarmed == WebProcessProxy::IsPrewarmed::Yes) {
-        ASSERT(!m_prewarmedProcess);
-        m_prewarmedProcess = &process;
-        
-        m_prewarmedProcess->send(Messages::WebProcess::PrewarmGlobally(), 0);
-    }
 
     if (m_serviceWorkerProcessesTerminationTimer.isActive())
         m_serviceWorkerProcessesTerminationTimer.stop();
@@ -813,7 +807,7 @@ static void registerDisplayConfigurationCallback()
 }
 #endif
 
-void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDataStore& websiteDataStore)
+void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDataStore& websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
 {
     auto initializationActivityToken = process.throttler().backgroundActivityToken();
     auto scopeExit = makeScopeExit([&process, initializationActivityToken] {
@@ -964,6 +958,12 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
 
     ASSERT(m_messagesToInjectedBundlePostedToEmptyContext.isEmpty());
 
+    if (isPrewarmed == WebProcessProxy::IsPrewarmed::Yes) {
+        ASSERT(!m_prewarmedProcess);
+        m_prewarmedProcess = &process;
+        process.send(Messages::WebProcess::PrewarmGlobally(), 0);
+    }
+
 #if ENABLE(REMOTE_INSPECTOR)
     // Initialize remote inspector connection now that we have a sub-process that is hosting one of our web views.
     Inspector::RemoteInspector::singleton(); 
index 7c11b7b..f4d5213 100644 (file)
@@ -505,7 +505,7 @@ private:
     RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);
 
     WebProcessProxy& createNewWebProcess(WebsiteDataStore&, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
-    void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore&);
+    void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore&, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
 
     void requestWebContentStatistics(StatisticsRequest&);
     void requestNetworkingStatistics(StatisticsRequest&);