<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213824] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213824">213824</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-03-13 04:16:29 -0700 (Mon, 13 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
https://bugs.webkit.org/show_bug.cgi?id=169425
<rdar://problem/30954003>
Reviewed by Andreas Kling.
Source/WebKit2:
The background responsiveness checking was previously relying on the
isResponsive(std::function<void(bool)>) API which uses the ResponsivenessTimer
and has a timeout of 3 seconds. We believe this is too aggressive for background
tabs. Update BackgroundResponsiveTimer to stop relying on ResponsivenessTimer
and have its own timeout Timer which a delay of 90 seconds instead.
* UIProcess/API/C/mac/WKPagePrivateMac.mm:
(-[WKObservablePageState _webProcessIsResponsive]):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController _webProcessIsResponsive]):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _webProcessIsResponsive]):
* UIProcess/BackgroundProcessResponsivenessTimer.cpp:
(WebKit::BackgroundProcessResponsivenessTimer::BackgroundProcessResponsivenessTimer):
(WebKit::BackgroundProcessResponsivenessTimer::~BackgroundProcessResponsivenessTimer):
(WebKit::BackgroundProcessResponsivenessTimer::updateState):
(WebKit::BackgroundProcessResponsivenessTimer::didReceiveBackgroundResponsivenessPong):
(WebKit::BackgroundProcessResponsivenessTimer::invalidate):
(WebKit::BackgroundProcessResponsivenessTimer::processTerminated):
(WebKit::BackgroundProcessResponsivenessTimer::responsivenessCheckTimerFired):
(WebKit::BackgroundProcessResponsivenessTimer::timeoutTimerFired):
(WebKit::BackgroundProcessResponsivenessTimer::setResponsive):
(WebKit::BackgroundProcessResponsivenessTimer::shouldBeActive):
(WebKit::BackgroundProcessResponsivenessTimer::scheduleNextResponsivenessCheck):
(WebKit::BackgroundProcessResponsivenessTimer::client):
* UIProcess/BackgroundProcessResponsivenessTimer.h:
(WebKit::BackgroundProcessResponsivenessTimer::isResponsive):
* UIProcess/ResponsivenessTimer.h:
(WebKit::ResponsivenessTimer::isResponsive):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessExited):
(WebKit::WebPageProxy::updateBackingStoreDiscardableState):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::shutDown):
(WebKit::WebProcessProxy::isResponsive):
(WebKit::WebProcessProxy::didReceiveBackgroundResponsivenessPing):
(WebKit::WebProcessProxy::processTerminated):
(WebKit::WebProcessProxy::updateBackgroundResponsivenessTimer):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::backgroundResponsivenessPing):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
Source/WTF:
* wtf/RunLoop.h:
(WTF::RunLoop::TimerBase::startRepeating):
(WTF::RunLoop::TimerBase::startOneShot):
Add overloads to RunLoop::Timer that take Seconds in parameter,
for convenience.
* wtf/Seconds.h:
(WTF::Seconds::fromHours):
(WTF::seconds_literals::operator _h):
Allow _h suffix for initializing Seconds type to hours.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfRunLooph">trunk/Source/WTF/wtf/RunLoop.h</a></li>
<li><a href="#trunkSourceWTFwtfSecondsh">trunk/Source/WTF/wtf/Seconds.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICmacWKPagePrivateMacmm">trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllermm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessBackgroundProcessResponsivenessTimercpp">trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessBackgroundProcessResponsivenessTimerh">trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessResponsivenessTimerh">trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxycpp">trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxyh">trunk/Source/WebKit2/UIProcess/WebProcessProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxymessagesin">trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcessh">trunk/Source/WebKit2/WebProcess/WebProcess.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcessmessagesin">trunk/Source/WebKit2/WebProcess/WebProcess.messages.in</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WTF/ChangeLog        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-03-13 Chris Dumez <cdumez@apple.com>
+
+ [WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
+ https://bugs.webkit.org/show_bug.cgi?id=169425
+ <rdar://problem/30954003>
+
+ Reviewed by Andreas Kling.
+
+ * wtf/RunLoop.h:
+ (WTF::RunLoop::TimerBase::startRepeating):
+ (WTF::RunLoop::TimerBase::startOneShot):
+ Add overloads to RunLoop::Timer that take Seconds in parameter,
+ for convenience.
+
+ * wtf/Seconds.h:
+ (WTF::Seconds::fromHours):
+ (WTF::seconds_literals::operator _h):
+ Allow _h suffix for initializing Seconds type to hours.
+
</ins><span class="cx"> 2017-03-11 Csaba Osztrogonác <ossy@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r213645): It made JSC tests super slow and timeout on AArch64 Linux
</span></span></pre></div>
<a id="trunkSourceWTFwtfRunLooph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/RunLoop.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RunLoop.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WTF/wtf/RunLoop.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -85,8 +85,10 @@
</span><span class="cx">
</span><span class="cx"> void startRepeating(double repeatInterval) { start(repeatInterval, true); }
</span><span class="cx"> void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(repeatInterval.count() * 0.001); }
</span><ins>+ void startRepeating(Seconds repeatInterval) { startRepeating(repeatInterval.value()); }
</ins><span class="cx"> void startOneShot(double interval) { start(interval, false); }
</span><span class="cx"> void startOneShot(std::chrono::milliseconds interval) { start(interval.count() * 0.001, false); }
</span><ins>+ void startOneShot(Seconds interval) { start(interval.value(), false); }
</ins><span class="cx">
</span><span class="cx"> WTF_EXPORT_PRIVATE void stop();
</span><span class="cx"> WTF_EXPORT_PRIVATE bool isActive() const;
</span></span></pre></div>
<a id="trunkSourceWTFwtfSecondsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Seconds.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Seconds.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WTF/wtf/Seconds.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -57,6 +57,11 @@
</span><span class="cx"> return Seconds(minutes * 60);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ static constexpr Seconds fromHours(double hours)
+ {
+ return Seconds(hours * 3600);
+ }
+
</ins><span class="cx"> static constexpr Seconds fromMilliseconds(double milliseconds)
</span><span class="cx"> {
</span><span class="cx"> return Seconds(milliseconds / 1000);
</span><span class="lines">@@ -208,6 +213,11 @@
</span><span class="cx"> return Seconds::fromMinutes(minutes);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+constexpr Seconds operator"" _h(long double hours)
+{
+ return Seconds::fromHours(hours);
+}
+
</ins><span class="cx"> constexpr Seconds operator"" _s(long double seconds)
</span><span class="cx"> {
</span><span class="cx"> return Seconds(seconds);
</span><span class="lines">@@ -233,6 +243,11 @@
</span><span class="cx"> return Seconds::fromMinutes(minutes);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+constexpr Seconds operator"" _h(unsigned long long hours)
+{
+ return Seconds::fromHours(hours);
+}
+
</ins><span class="cx"> constexpr Seconds operator"" _s(unsigned long long seconds)
</span><span class="cx"> {
</span><span class="cx"> return Seconds(seconds);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2017-03-13 Chris Dumez <cdumez@apple.com>
+
+ [WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
+ https://bugs.webkit.org/show_bug.cgi?id=169425
+ <rdar://problem/30954003>
+
+ Reviewed by Andreas Kling.
+
+ The background responsiveness checking was previously relying on the
+ isResponsive(std::function<void(bool)>) API which uses the ResponsivenessTimer
+ and has a timeout of 3 seconds. We believe this is too aggressive for background
+ tabs. Update BackgroundResponsiveTimer to stop relying on ResponsivenessTimer
+ and have its own timeout Timer which a delay of 90 seconds instead.
+
+ * UIProcess/API/C/mac/WKPagePrivateMac.mm:
+ (-[WKObservablePageState _webProcessIsResponsive]):
+ * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+ (-[WKBrowsingContextController _webProcessIsResponsive]):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _webProcessIsResponsive]):
+ * UIProcess/BackgroundProcessResponsivenessTimer.cpp:
+ (WebKit::BackgroundProcessResponsivenessTimer::BackgroundProcessResponsivenessTimer):
+ (WebKit::BackgroundProcessResponsivenessTimer::~BackgroundProcessResponsivenessTimer):
+ (WebKit::BackgroundProcessResponsivenessTimer::updateState):
+ (WebKit::BackgroundProcessResponsivenessTimer::didReceiveBackgroundResponsivenessPong):
+ (WebKit::BackgroundProcessResponsivenessTimer::invalidate):
+ (WebKit::BackgroundProcessResponsivenessTimer::processTerminated):
+ (WebKit::BackgroundProcessResponsivenessTimer::responsivenessCheckTimerFired):
+ (WebKit::BackgroundProcessResponsivenessTimer::timeoutTimerFired):
+ (WebKit::BackgroundProcessResponsivenessTimer::setResponsive):
+ (WebKit::BackgroundProcessResponsivenessTimer::shouldBeActive):
+ (WebKit::BackgroundProcessResponsivenessTimer::scheduleNextResponsivenessCheck):
+ (WebKit::BackgroundProcessResponsivenessTimer::client):
+ * UIProcess/BackgroundProcessResponsivenessTimer.h:
+ (WebKit::BackgroundProcessResponsivenessTimer::isResponsive):
+ * UIProcess/ResponsivenessTimer.h:
+ (WebKit::ResponsivenessTimer::isResponsive):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::resetStateAfterProcessExited):
+ (WebKit::WebPageProxy::updateBackingStoreDiscardableState):
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::WebProcessProxy):
+ (WebKit::WebProcessProxy::shutDown):
+ (WebKit::WebProcessProxy::isResponsive):
+ (WebKit::WebProcessProxy::didReceiveBackgroundResponsivenessPing):
+ (WebKit::WebProcessProxy::processTerminated):
+ (WebKit::WebProcessProxy::updateBackgroundResponsivenessTimer):
+ * UIProcess/WebProcessProxy.h:
+ * UIProcess/WebProcessProxy.messages.in:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::backgroundResponsivenessPing):
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
</ins><span class="cx"> 2017-03-13 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> Web Automation: automation commands hang when trying to navigate go/back and it's not possible
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICmacWKPagePrivateMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.mm (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.mm        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.mm        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">
</span><span class="cx"> - (BOOL)_webProcessIsResponsive
</span><span class="cx"> {
</span><del>- return _page->process().responsivenessTimer().isResponsive();
</del><ins>+ return _page->process().isResponsive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (double)estimatedProgress
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -779,7 +779,7 @@
</span><span class="cx">
</span><span class="cx"> - (BOOL)_webProcessIsResponsive
</span><span class="cx"> {
</span><del>- return _page->process().responsivenessTimer().isResponsive();
</del><ins>+ return _page->process().isResponsive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -4357,7 +4357,7 @@
</span><span class="cx">
</span><span class="cx"> - (BOOL)_webProcessIsResponsive
</span><span class="cx"> {
</span><del>- return _page->process().responsivenessTimer().isResponsive();
</del><ins>+ return _page->process().isResponsive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_setFullscreenDelegate:(id<_WKFullscreenDelegate>)delegate
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessBackgroundProcessResponsivenessTimercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.cpp (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.cpp        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.cpp        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -27,48 +27,123 @@
</span><span class="cx"> #include "BackgroundProcessResponsivenessTimer.h"
</span><span class="cx">
</span><span class="cx"> #include "Logging.h"
</span><ins>+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><del>-static const std::chrono::seconds initialInterval { 20s };
-static const std::chrono::seconds maximumInterval { 8h };
</del><ins>+static const Seconds initialCheckingInterval { 20_s };
+static const Seconds maximumCheckingInterval { 8_h };
+static const Seconds responsivenessTimeout { 90_s };
</ins><span class="cx">
</span><span class="cx"> BackgroundProcessResponsivenessTimer::BackgroundProcessResponsivenessTimer(WebProcessProxy& webProcessProxy)
</span><span class="cx"> : m_webProcessProxy(webProcessProxy)
</span><del>- , m_interval(initialInterval)
- , m_timer(RunLoop::main(), this, &BackgroundProcessResponsivenessTimer::timerFired)
</del><ins>+ , m_checkingInterval(initialCheckingInterval)
+ , m_responsivenessCheckTimer(RunLoop::main(), this, &BackgroundProcessResponsivenessTimer::responsivenessCheckTimerFired)
+ , m_timeoutTimer(RunLoop::main(), this, &BackgroundProcessResponsivenessTimer::timeoutTimerFired)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+BackgroundProcessResponsivenessTimer::~BackgroundProcessResponsivenessTimer()
+{
+}
+
</ins><span class="cx"> void BackgroundProcessResponsivenessTimer::updateState()
</span><span class="cx"> {
</span><span class="cx"> if (!shouldBeActive()) {
</span><del>- if (m_timer.isActive()) {
- m_interval = initialInterval;
- m_timer.stop();
</del><ins>+ if (m_responsivenessCheckTimer.isActive()) {
+ m_checkingInterval = initialCheckingInterval;
+ m_responsivenessCheckTimer.stop();
</ins><span class="cx"> }
</span><ins>+ m_timeoutTimer.stop();
+ m_isResponsive = true;
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!m_timer.isActive())
- m_timer.startOneShot(m_interval);
</del><ins>+ if (!m_responsivenessCheckTimer.isActive())
+ m_responsivenessCheckTimer.startOneShot(m_checkingInterval);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void BackgroundProcessResponsivenessTimer::timerFired()
</del><ins>+void BackgroundProcessResponsivenessTimer::didReceiveBackgroundResponsivenessPong()
</ins><span class="cx"> {
</span><ins>+ if (!m_timeoutTimer.isActive())
+ return;
+
+ m_timeoutTimer.stop();
+ scheduleNextResponsivenessCheck();
+
+ setResponsive(true);
+}
+
+void BackgroundProcessResponsivenessTimer::invalidate()
+{
+ m_timeoutTimer.stop();
+ m_responsivenessCheckTimer.stop();
+}
+
+void BackgroundProcessResponsivenessTimer::processTerminated()
+{
+ invalidate();
+ setResponsive(true);
+}
+
+void BackgroundProcessResponsivenessTimer::responsivenessCheckTimerFired()
+{
</ins><span class="cx"> ASSERT(shouldBeActive());
</span><del>- // WebProcessProxy::responsive() takes care of calling processDidBecomeUnresponsive for us.
- m_webProcessProxy.isResponsive([this](bool processIsResponsive) {
- if (processIsResponsive) {
- // Exponential backoff to avoid waking up the process too often.
- m_interval = std::min(m_interval * 2, maximumInterval);
- m_timer.startOneShot(m_interval);
- return;
- }
</del><ins>+ ASSERT(!m_timeoutTimer.isActive());
</ins><span class="cx">
</span><del>- RELEASE_LOG_ERROR(PerformanceLogging, "Notified the client that a background WebProcess has become unresponsive");
- m_interval = initialInterval;
- });
</del><ins>+ m_timeoutTimer.startOneShot(responsivenessTimeout);
+ m_webProcessProxy.send(Messages::WebProcess::BackgroundResponsivenessPing(), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void BackgroundProcessResponsivenessTimer::timeoutTimerFired()
+{
+ ASSERT(shouldBeActive());
+
+ scheduleNextResponsivenessCheck();
+
+ if (!m_isResponsive)
+ return;
+
+ if (!client().mayBecomeUnresponsive())
+ return;
+
+ setResponsive(false);
+}
+
+void BackgroundProcessResponsivenessTimer::setResponsive(bool isResponsive)
+{
+ if (m_isResponsive == isResponsive)
+ return;
+
+ client().willChangeIsResponsive();
+ m_isResponsive = isResponsive;
+ client().didChangeIsResponsive();
+
+ if (m_isResponsive) {
+ RELEASE_LOG_ERROR(PerformanceLogging, "Notifying the client that a background WebProcess has become responsive again");
+ client().didBecomeResponsive();
+ } else {
+ RELEASE_LOG_ERROR(PerformanceLogging, "Notifying the client that a background WebProcess has become unresponsive");
+ client().didBecomeUnresponsive();
+ }
+}
+
+bool BackgroundProcessResponsivenessTimer::shouldBeActive() const
+{
+ return !m_webProcessProxy.visiblePageCount() && m_webProcessProxy.pageCount();
+}
+
+void BackgroundProcessResponsivenessTimer::scheduleNextResponsivenessCheck()
+{
+ // Exponential backoff to avoid waking up the process too often.
+ m_checkingInterval = std::min(m_checkingInterval * 2, maximumCheckingInterval);
+ m_responsivenessCheckTimer.startOneShot(m_checkingInterval);
+}
+
+ResponsivenessTimer::Client& BackgroundProcessResponsivenessTimer::client() const
+{
+ return m_webProcessProxy;
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessBackgroundProcessResponsivenessTimerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/BackgroundProcessResponsivenessTimer.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -25,23 +25,39 @@
</span><span class="cx">
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><del>-#include "WebProcessProxy.h"
</del><ins>+#include "ResponsivenessTimer.h"
</ins><span class="cx"> #include <wtf/RunLoop.h>
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><ins>+class WebProcessProxy;
+
</ins><span class="cx"> class BackgroundProcessResponsivenessTimer {
</span><span class="cx"> public:
</span><span class="cx"> explicit BackgroundProcessResponsivenessTimer(WebProcessProxy&);
</span><ins>+ ~BackgroundProcessResponsivenessTimer();
</ins><span class="cx"> void updateState();
</span><span class="cx">
</span><ins>+ void didReceiveBackgroundResponsivenessPong();
+ bool isResponsive() const { return m_isResponsive; }
+
+ void invalidate();
+ void processTerminated();
+
</ins><span class="cx"> private:
</span><del>- void timerFired();
- bool shouldBeActive() const { return !m_webProcessProxy.visiblePageCount() && m_webProcessProxy.pageCount(); }
</del><ins>+ void responsivenessCheckTimerFired();
+ void timeoutTimerFired();
+ void setResponsive(bool);
</ins><span class="cx">
</span><ins>+ bool shouldBeActive() const;
+ void scheduleNextResponsivenessCheck();
+ ResponsivenessTimer::Client& client() const;
+
</ins><span class="cx"> WebProcessProxy& m_webProcessProxy;
</span><del>- std::chrono::seconds m_interval;
- RunLoop::Timer<BackgroundProcessResponsivenessTimer> m_timer;
</del><ins>+ Seconds m_checkingInterval;
+ RunLoop::Timer<BackgroundProcessResponsivenessTimer> m_responsivenessCheckTimer;
+ RunLoop::Timer<BackgroundProcessResponsivenessTimer> m_timeoutTimer;
+ bool m_isResponsive { true };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessResponsivenessTimerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">
</span><span class="cx"> void invalidate();
</span><span class="cx">
</span><del>- bool isResponsive() { return m_isResponsive; }
</del><ins>+ bool isResponsive() const { return m_isResponsive; }
</ins><span class="cx">
</span><span class="cx"> void processTerminated();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -5514,7 +5514,7 @@
</span><span class="cx"> PageLoadState::Transaction transaction = m_pageLoadState.transaction();
</span><span class="cx"> m_pageLoadState.reset(transaction);
</span><span class="cx">
</span><del>- m_process->responsivenessTimer().processTerminated();
</del><ins>+ m_process->processTerminated();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebPageCreationParameters WebPageProxy::creationParameters()
</span><span class="lines">@@ -6027,7 +6027,7 @@
</span><span class="cx">
</span><span class="cx"> bool isDiscardable;
</span><span class="cx">
</span><del>- if (!m_process->responsivenessTimer().isResponsive())
</del><ins>+ if (!m_process->isResponsive())
</ins><span class="cx"> isDiscardable = false;
</span><span class="cx"> else
</span><span class="cx"> isDiscardable = !m_pageClient.isViewWindowActive() || !isViewVisible();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #include "APIFrameHandle.h"
</span><span class="cx"> #include "APIPageGroupHandle.h"
</span><span class="cx"> #include "APIPageHandle.h"
</span><del>-#include "BackgroundProcessResponsivenessTimer.h"
</del><span class="cx"> #include "DataReference.h"
</span><span class="cx"> #include "DownloadProxyMap.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="lines">@@ -97,6 +96,7 @@
</span><span class="cx"> WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore)
</span><span class="cx"> : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
</span><span class="cx"> , m_responsivenessTimer(*this)
</span><ins>+ , m_backgroundResponsivenessTimer(*this)
</ins><span class="cx"> , m_processPool(processPool)
</span><span class="cx"> , m_mayHaveUniversalFileReadSandboxExtension(false)
</span><span class="cx"> , m_numberOfTimesSuddenTerminationWasDisabled(0)
</span><span class="lines">@@ -103,7 +103,6 @@
</span><span class="cx"> , m_throttler(*this)
</span><span class="cx"> , m_isResponsive(NoOrMaybe::Maybe)
</span><span class="cx"> , m_visiblePageCounter([this](RefCounterEvent) { updateBackgroundResponsivenessTimer(); })
</span><del>- , m_backgroundResponsivenessTimer(std::make_unique<BackgroundProcessResponsivenessTimer>(*this))
</del><span class="cx"> , m_websiteDataStore(websiteDataStore)
</span><span class="cx"> {
</span><span class="cx"> WebPasteboardProxy::singleton().addWebProcessProxy(*this);
</span><span class="lines">@@ -177,6 +176,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> m_responsivenessTimer.invalidate();
</span><ins>+ m_backgroundResponsivenessTimer.invalidate();
</ins><span class="cx"> m_tokenForHoldingLockedFiles = nullptr;
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<WebFrameProxy>> frames;
</span><span class="lines">@@ -741,6 +741,11 @@
</span><span class="cx"> return result.iterator->value;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool WebProcessProxy::isResponsive() const
+{
+ return m_responsivenessTimer.isResponsive() && m_backgroundResponsivenessTimer.isResponsive();
+}
+
</ins><span class="cx"> void WebProcessProxy::didDestroyUserGestureToken(uint64_t identifier)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(UserInitiatedActionMap::isValidKey(identifier));
</span><span class="lines">@@ -1097,10 +1102,20 @@
</span><span class="cx"> callback(isWebProcessResponsive);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebProcessProxy::didReceiveBackgroundResponsivenessPing()
+{
+ m_backgroundResponsivenessTimer.didReceiveBackgroundResponsivenessPong();
+}
+
+void WebProcessProxy::processTerminated()
+{
+ m_responsivenessTimer.processTerminated();
+ m_backgroundResponsivenessTimer.processTerminated();
+}
+
</ins><span class="cx"> void WebProcessProxy::updateBackgroundResponsivenessTimer()
</span><span class="cx"> {
</span><del>- if (m_backgroundResponsivenessTimer)
- m_backgroundResponsivenessTimer->updateState();
</del><ins>+ m_backgroundResponsivenessTimer.updateState();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><span class="cx"> #include "APIUserInitiatedAction.h"
</span><ins>+#include "BackgroundProcessResponsivenessTimer.h"
</ins><span class="cx"> #include "ChildProcessProxy.h"
</span><span class="cx"> #include "MessageReceiverMap.h"
</span><span class="cx"> #include "PluginInfoStore.h"
</span><span class="lines">@@ -54,7 +55,6 @@
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><del>-class BackgroundProcessResponsivenessTimer;
</del><span class="cx"> class NetworkProcessProxy;
</span><span class="cx"> class WebBackForwardListItem;
</span><span class="cx"> class WebPageGroup;
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> struct WebNavigationDataStore;
</span><span class="cx"> struct WebsiteData;
</span><span class="cx">
</span><del>-class WebProcessProxy : public ChildProcessProxy, ResponsivenessTimer::Client, private ProcessThrottlerClient {
</del><ins>+class WebProcessProxy : public ChildProcessProxy, public ResponsivenessTimer::Client, private ProcessThrottlerClient {
</ins><span class="cx"> public:
</span><span class="cx"> typedef HashMap<uint64_t, RefPtr<WebBackForwardListItem>> WebBackForwardListItemMap;
</span><span class="cx"> typedef HashMap<uint64_t, RefPtr<WebFrameProxy>> WebFrameProxyMap;
</span><span class="lines">@@ -99,6 +99,7 @@
</span><span class="cx"> RefPtr<API::UserInitiatedAction> userInitiatedActivity(uint64_t);
</span><span class="cx">
</span><span class="cx"> ResponsivenessTimer& responsivenessTimer() { return m_responsivenessTimer; }
</span><ins>+ bool isResponsive() const;
</ins><span class="cx">
</span><span class="cx"> WebFrameProxy* webFrame(uint64_t) const;
</span><span class="cx"> bool canCreateFrame(uint64_t frameID) const;
</span><span class="lines">@@ -157,10 +158,13 @@
</span><span class="cx">
</span><span class="cx"> void isResponsive(std::function<void(bool isWebProcessResponsive)>);
</span><span class="cx"> void didReceiveMainThreadPing();
</span><ins>+ void didReceiveBackgroundResponsivenessPing();
</ins><span class="cx">
</span><span class="cx"> void memoryPressureStatusChanged(bool isUnderMemoryPressure) { m_isUnderMemoryPressure = isUnderMemoryPressure; }
</span><span class="cx"> bool isUnderMemoryPressure() const { return m_isUnderMemoryPressure; }
</span><span class="cx">
</span><ins>+ void processTerminated();
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit WebProcessProxy(WebProcessPool&, WebsiteDataStore*);
</span><span class="cx">
</span><span class="lines">@@ -233,6 +237,7 @@
</span><span class="cx"> bool canTerminateChildProcess();
</span><span class="cx">
</span><span class="cx"> ResponsivenessTimer m_responsivenessTimer;
</span><ins>+ BackgroundProcessResponsivenessTimer m_backgroundResponsivenessTimer;
</ins><span class="cx">
</span><span class="cx"> RefPtr<WebConnectionToWebProcess> m_webConnection;
</span><span class="cx"> Ref<WebProcessPool> m_processPool;
</span><span class="lines">@@ -262,7 +267,6 @@
</span><span class="cx"> Vector<std::function<void(bool webProcessIsResponsive)>> m_isResponsiveCallbacks;
</span><span class="cx">
</span><span class="cx"> VisibleWebPageCounter m_visiblePageCounter;
</span><del>- std::unique_ptr<BackgroundProcessResponsivenessTimer> m_backgroundResponsivenessTimer;
</del><span class="cx">
</span><span class="cx"> // FIXME: WebsiteDataStores should be made per-WebPageProxy throughout WebKit2. Get rid of this member.
</span><span class="cx"> RefPtr<WebsiteDataStore> m_websiteDataStore;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> ReleaseIconForPageURL(String pageURL)
</span><span class="cx">
</span><span class="cx"> DidReceiveMainThreadPing()
</span><ins>+ DidReceiveBackgroundResponsivenessPing()
</ins><span class="cx">
</span><span class="cx"> MemoryPressureStatusChanged(bool isUnderMemoryPressure)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -1020,6 +1020,11 @@
</span><span class="cx"> parentProcessConnection()->send(Messages::WebProcessProxy::DidReceiveMainThreadPing(), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebProcess::backgroundResponsivenessPing()
+{
+ parentProcessConnection()->send(Messages::WebProcessProxy::DidReceiveBackgroundResponsivenessPing(), 0);
+}
+
</ins><span class="cx"> #if ENABLE(GAMEPAD)
</span><span class="cx">
</span><span class="cx"> void WebProcess::setInitialGamepads(const Vector<WebKit::GamepadData>& gamepadDatas)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.h        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -283,6 +283,7 @@
</span><span class="cx"> void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
</span><span class="cx">
</span><span class="cx"> void mainThreadPing();
</span><ins>+ void backgroundResponsivenessPing();
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(GAMEPAD)
</span><span class="cx"> void setInitialGamepads(const Vector<GamepadData>&);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (213823 => 213824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in        2017-03-13 11:12:47 UTC (rev 213823)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in        2017-03-13 11:16:29 UTC (rev 213824)
</span><span class="lines">@@ -100,6 +100,7 @@
</span><span class="cx"> ProcessDidResume()
</span><span class="cx">
</span><span class="cx"> MainThreadPing()
</span><ins>+ BackgroundResponsivenessPing()
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(GAMEPAD)
</span><span class="cx"> SetInitialGamepads(Vector<WebKit::GamepadData> gamepadDatas)
</span></span></pre>
</div>
</div>
</body>
</html>