Title: [150384] trunk/Source/WebKit2
Revision
150384
Author
akl...@apple.com
Date
2013-05-20 15:55:49 -0700 (Mon, 20 May 2013)

Log Message

PPT: Closing tab that is hung or chewing 100% CPU leaves abandoned WebProcess.
<http://webkit.org/b/116464>
<rdar://problem/10103795>

Reviewed by Anders Carlsson.

Give the web process a 10 second chance to exit nicely after closing the last tab belonging to it.
This code only runs if there was something on the page (e.g an unload/beforeunload event handler)
preventing the UI process from killing it right away.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (150383 => 150384)


--- trunk/Source/WebKit2/ChangeLog	2013-05-20 21:38:37 UTC (rev 150383)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-20 22:55:49 UTC (rev 150384)
@@ -1,3 +1,22 @@
+2013-05-20  Andreas Kling  <akl...@apple.com>
+
+        PPT: Closing tab that is hung or chewing 100% CPU leaves abandoned WebProcess.
+        <http://webkit.org/b/116464>
+        <rdar://problem/10103795>
+
+        Reviewed by Anders Carlsson.
+
+        Give the web process a 10 second chance to exit nicely after closing the last tab belonging to it.
+        This code only runs if there was something on the page (e.g an unload/beforeunload event handler)
+        preventing the UI process from killing it right away.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::WebProcessProxy):
+        (WebKit::WebProcessProxy::removeWebPage):
+        (WebKit::WebProcessProxy::forcefulTerminationTimerFired):
+        * UIProcess/WebProcessProxy.h:
+        (WebProcessProxy):
+
 2013-05-20  Anders Carlsson  <ander...@apple.com>
 
         Add helper function for converting a KeyedCodingValue to a CFTypeRef

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (150383 => 150384)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-05-20 21:38:37 UTC (rev 150383)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-05-20 22:55:49 UTC (rev 150384)
@@ -98,6 +98,7 @@
 #if PLATFORM(MAC)
     , m_processSuppressionEnabled(false)
 #endif
+    , m_forcefulTerminationTimer(RunLoop::main(), this, &WebProcessProxy::forcefulTerminationTimerFired)
 {
     connect();
 }
@@ -201,12 +202,17 @@
     updateProcessSuppressionState();
 #endif
 
-#if ENABLE(NETWORK_PROCESS)
+    if (!canTerminateChildProcess())
+        return;
+
     // 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 (!m_suddenTerminationCounter && canTerminateChildProcess() && m_context->usesNetworkProcess())
+    if (m_context->usesNetworkProcess() && !m_suddenTerminationCounter)
         requestTermination();
-#endif
+    else {
+        const double timeBeforeForcefullyKillingWebProcessInSeconds = 10;
+        m_forcefulTerminationTimer.startOneShot(timeBeforeForcefullyKillingWebProcessInSeconds);
+    }
 }
 
 Vector<WebPageProxy*> WebProcessProxy::pages() const
@@ -655,6 +661,13 @@
         send(Messages::WebProcess::ReleasePageCache(), 0);
 }
 
+void WebProcessProxy::forcefulTerminationTimerFired()
+{
+#if PLATFORM(MAC)
+    WTFLogAlways("Killing runaway web process, pid=%d\n", processIdentifier());
+#endif
+    requestTermination();
+}
 
 void WebProcessProxy::requestTermination()
 {

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (150383 => 150384)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-05-20 21:38:37 UTC (rev 150383)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-05-20 22:55:49 UTC (rev 150384)
@@ -185,6 +185,7 @@
     void didReceiveSyncWebProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
 
     bool canTerminateChildProcess();
+    void forcefulTerminationTimerFired();
 
     ResponsivenessTimer m_responsivenessTimer;
     
@@ -210,6 +211,8 @@
     HashSet<uint64_t> m_processSuppressiblePages;
     bool m_processSuppressionEnabled;
 #endif
+
+    WebCore::RunLoop::Timer<WebProcessProxy> m_forcefulTerminationTimer;
 };
     
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to