Title: [149934] trunk/Source/WebKit2
Revision
149934
Author
[email protected]
Date
2013-05-11 11:53:13 -0700 (Sat, 11 May 2013)

Log Message

When possible, terminate web processes immediately when closing their last page.
<http://webkit.org/b/115964>
<rdar://problem/13869266>

Reviewed by Geoffrey Garen.

When we're using a network process, there's no need for the UI process to wait for web processes
to clear resource caches and terminate nicely.

We can just kill them off right away in WebProcessProxy::removeWebPage() when the last page is closed.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::removeWebPage):

    Terminate the child process immediately if possible.

* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::canTerminateChildProcess):
(WebKit::WebProcessProxy::shouldTerminate):

    Broke out the logic from the shouldTerminate() IPC message handler into a separate function
    so we can call it from removeWebPage().

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (149933 => 149934)


--- trunk/Source/WebKit2/ChangeLog	2013-05-11 18:00:40 UTC (rev 149933)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-11 18:53:13 UTC (rev 149934)
@@ -1,3 +1,28 @@
+2013-05-11  Andreas Kling  <[email protected]>
+
+        When possible, terminate web processes immediately when closing their last page.
+        <http://webkit.org/b/115964>
+        <rdar://problem/13869266>
+
+        Reviewed by Geoffrey Garen.
+
+        When we're using a network process, there's no need for the UI process to wait for web processes
+        to clear resource caches and terminate nicely.
+
+        We can just kill them off right away in WebProcessProxy::removeWebPage() when the last page is closed.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::removeWebPage):
+
+            Terminate the child process immediately if possible.
+
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::canTerminateChildProcess):
+        (WebKit::WebProcessProxy::shouldTerminate):
+
+            Broke out the logic from the shouldTerminate() IPC message handler into a separate function
+            so we can call it from removeWebPage().
+
 2013-05-11  Anders Carlsson  <[email protected]>
 
         Crash when terminating a process that has not been fully launched

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (149933 => 149934)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-05-11 18:00:40 UTC (rev 149933)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-05-11 18:53:13 UTC (rev 149934)
@@ -198,6 +198,13 @@
     m_processSuppressiblePages.remove(pageID);
     updateProcessSuppressionState();
 #endif
+
+#if ENABLE(NETWORK_PROCESS)
+    // Terminate the web process immediately if we have enough information to confidently do so.
+    // This only works if we're using a network process. Otherwise we have to wait for the web process to clean up.
+    if (canTerminateChildProcess() && m_context->usesNetworkProcess())
+        requestTermination();
+#endif
 }
 
 Vector<WebPageProxy*> WebProcessProxy::pages() const
@@ -505,19 +512,29 @@
     return result;
 }
 
-void WebProcessProxy::shouldTerminate(bool& shouldTerminate)
+bool WebProcessProxy::canTerminateChildProcess()
 {
-    if (!m_pageMap.isEmpty() || (m_downloadProxyMap && !m_downloadProxyMap->isEmpty()) || !m_context->shouldTerminate(this)) {
-        shouldTerminate = false;
-        return;
-    }
+    if (!m_pageMap.isEmpty())
+        return false;
 
-    shouldTerminate = true;
+    if (m_downloadProxyMap && !m_downloadProxyMap->isEmpty())
+        return false;
 
-    // We know that the web process is going to terminate so disconnect it from the context.
-    disconnect();
+    if (!m_context->shouldTerminate(this))
+        return false;
+
+    return true;
 }
 
+void WebProcessProxy::shouldTerminate(bool& shouldTerminate)
+{
+    shouldTerminate = canTerminateChildProcess();
+    if (shouldTerminate) {
+        // We know that the web process is going to terminate so disconnect it from the context.
+        disconnect();
+    }
+}
+
 void WebProcessProxy::updateTextCheckerState()
 {
     if (canSendMessage())

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (149933 => 149934)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-05-11 18:00:40 UTC (rev 149933)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-05-11 18:53:13 UTC (rev 149934)
@@ -178,6 +178,8 @@
     void didReceiveWebProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
     void didReceiveSyncWebProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
 
+    bool canTerminateChildProcess();
+
     ResponsivenessTimer m_responsivenessTimer;
     
     RefPtr<WebConnectionToWebProcess> m_webConnection;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to