Title: [214230] trunk/Source/WebKit2
Revision
214230
Author
cdu...@apple.com
Date
2017-03-21 14:08:21 -0700 (Tue, 21 Mar 2017)

Log Message

[WK2] Call processDidCrash() right away when terminating a process that exceeded background CPU limit
https://bugs.webkit.org/show_bug.cgi?id=169573
<rdar://problem/30960968>

Reviewed by Andreas Kling.

Call processDidCrash() right away when terminating a process that exceeded background CPU limit
and let the client decide when to reload the content.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::reattachToWebProcess):
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::terminateProcess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didExceedBackgroundCPULimit):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (214229 => 214230)


--- trunk/Source/WebKit2/ChangeLog	2017-03-21 20:52:51 UTC (rev 214229)
+++ trunk/Source/WebKit2/ChangeLog	2017-03-21 21:08:21 UTC (rev 214230)
@@ -1,3 +1,22 @@
+2017-03-21  Chris Dumez  <cdu...@apple.com>
+
+        [WK2] Call processDidCrash() right away when terminating a process that exceeded background CPU limit
+        https://bugs.webkit.org/show_bug.cgi?id=169573
+        <rdar://problem/30960968>
+
+        Reviewed by Andreas Kling.
+
+        Call processDidCrash() right away when terminating a process that exceeded background CPU limit
+        and let the client decide when to reload the content.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::reattachToWebProcess):
+        (WebKit::WebPageProxy::dispatchActivityStateChange):
+        (WebKit::WebPageProxy::terminateProcess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::didExceedBackgroundCPULimit):
+
 2017-03-21  Aidan Holm  <aidanholm+web...@gmail.com>
 
         [GTK] Add function webkit_dom_element_get_bounding_client_rect

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (214229 => 214230)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-03-21 20:52:51 UTC (rev 214229)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-03-21 21:08:21 UTC (rev 214230)
@@ -709,7 +709,6 @@
     ASSERT(m_process->state() == WebProcessProxy::State::Terminated);
 
     m_isValid = true;
-    m_wasTerminatedDueToResourceExhaustionWhileInBackground = false;
     m_process->removeWebPage(m_pageID);
     m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
 
@@ -1522,13 +1521,8 @@
     m_activityStateChangeDispatcher->invalidate();
 #endif
 
-    if (!isValid()) {
-        if (m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible && m_wasTerminatedDueToResourceExhaustionWhileInBackground) {
-            m_wasTerminatedDueToResourceExhaustionWhileInBackground = false;
-            processDidCrash();
-        }
+    if (!isValid())
         return;
-    }
 
     // If the visibility state may have changed, then so may the visually idle & occluded agnostic state.
     if (m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible)
@@ -2391,7 +2385,7 @@
     m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
 }
 
-void WebPageProxy::terminateProcess(TerminationReason terminationReason)
+void WebPageProxy::terminateProcess()
 {
     // NOTE: This uses a check of m_isValid rather than calling isValid() since
     // we want this to run even for pages being closed or that already closed.
@@ -2400,7 +2394,6 @@
 
     m_process->requestTermination();
     resetStateAfterProcessExited();
-    m_wasTerminatedDueToResourceExhaustionWhileInBackground = terminationReason == TerminationReason::ResourceExhaustionWhileInBackground;
 }
 
 SessionState WebPageProxy::sessionState(const std::function<bool (WebBackForwardListItem&)>& filter) const

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (214229 => 214230)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-03-21 20:52:51 UTC (rev 214229)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-03-21 21:08:21 UTC (rev 214230)
@@ -680,8 +680,7 @@
 
     double estimatedProgress() const;
 
-    enum class TerminationReason { ResourceExhaustionWhileInBackground, Other };
-    void terminateProcess(TerminationReason = TerminationReason::Other);
+    void terminateProcess();
 
     SessionState sessionState(const std::function<bool (WebBackForwardListItem&)>& = nullptr) const;
     RefPtr<API::Navigation> restoreFromSessionState(SessionState, bool navigate);
@@ -1977,7 +1976,6 @@
 #endif
 
     bool m_isUsingHighPerformanceWebGL { false };
-    bool m_wasTerminatedDueToResourceExhaustionWhileInBackground { false };
         
     WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
 

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (214229 => 214230)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-03-21 20:52:51 UTC (rev 214229)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-03-21 21:08:21 UTC (rev 214230)
@@ -1141,9 +1141,10 @@
 
     RELEASE_LOG(PerformanceLogging, "%p - WebProcessProxy::didExceedBackgroundCPULimit() Terminating background WebProcess that has exceeded the background CPU limit", this);
 
-    // We only terminate the process here. We will call processDidCrash() once one of the pages becomes visible again (see WebPageProxy::dispatchActivityStateChange()).
-    for (auto& page : pagesCopy(pages()))
-        page->terminateProcess(WebPageProxy::TerminationReason::ResourceExhaustionWhileInBackground);
+    for (auto& page : pagesCopy(pages())) {
+        page->terminateProcess();
+        page->processDidCrash();
+    }
 }
 
 void WebProcessProxy::updateBackgroundResponsivenessTimer()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to