<!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>[192702] trunk/Source/WebKit2</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/192702">192702</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2015-11-20 15:10:02 -0800 (Fri, 20 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>A hung webpage pretends to be responsive if you scroll
https://bugs.webkit.org/show_bug.cgi?id=151518

Reviewed by Sam Weinig.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::sendWheelEvent):
(WebKit::WebPageProxy::didReceiveEvent): Don't treat wheel events as
starting or stopping the responsiveness timer. Wheel events usually
process on the event dispatch thread, which responds even if the main
thread is hung.

Instead, send an out-of-band ping to the main thread to verify that
it is still responsive and we'll be able to paint and respond to clicks
after scrolling.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::sendMainThreadPing):
(WebKit::WebProcessProxy::didReceiveMainThreadPing):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in: UI process support for pinging
the main thread in the web process.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::mainThreadPing):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in: Web process support for responding
to pings.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/ChangeLog        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2015-11-20  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        A hung webpage pretends to be responsive if you scroll
+        https://bugs.webkit.org/show_bug.cgi?id=151518
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::sendWheelEvent):
+        (WebKit::WebPageProxy::didReceiveEvent): Don't treat wheel events as
+        starting or stopping the responsiveness timer. Wheel events usually
+        process on the event dispatch thread, which responds even if the main
+        thread is hung.
+
+        Instead, send an out-of-band ping to the main thread to verify that
+        it is still responsive and we'll be able to paint and respond to clicks
+        after scrolling.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::sendMainThreadPing):
+        (WebKit::WebProcessProxy::didReceiveMainThreadPing):
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.messages.in: UI process support for pinging
+        the main thread in the web process.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::mainThreadPing):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in: Web process support for responding
+        to pings.
+
</ins><span class="cx"> 2015-11-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Allow more buffer formats in the IOSurface pool
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -1797,8 +1797,6 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::sendWheelEvent(const WebWheelEvent&amp; event)
</span><span class="cx"> {
</span><del>-    m_process-&gt;responsivenessTimer().start();
-
</del><span class="cx">     m_process-&gt;send(
</span><span class="cx">         Messages::EventDispatcher::WheelEvent(
</span><span class="cx">             m_pageID,
</span><span class="lines">@@ -1808,6 +1806,8 @@
</span><span class="cx">             rubberBandsAtTop(),
</span><span class="cx">             rubberBandsAtBottom()
</span><span class="cx">         ), 0);
</span><ins>+
+    m_process-&gt;sendMainThreadPing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent&amp; event)
</span><span class="lines">@@ -4500,6 +4500,7 @@
</span><span class="cx">     switch (type) {
</span><span class="cx">     case WebEvent::NoType:
</span><span class="cx">     case WebEvent::MouseMove:
</span><ins>+    case WebEvent::Wheel:
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case WebEvent::MouseDown:
</span><span class="lines">@@ -4507,7 +4508,6 @@
</span><span class="cx">     case WebEvent::MouseForceChanged:
</span><span class="cx">     case WebEvent::MouseForceDown:
</span><span class="cx">     case WebEvent::MouseForceUp:
</span><del>-    case WebEvent::Wheel:
</del><span class="cx">     case WebEvent::KeyDown:
</span><span class="cx">     case WebEvent::KeyUp:
</span><span class="cx">     case WebEvent::RawKeyDown:
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -1002,4 +1002,15 @@
</span><span class="cx">         m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebProcessProxy::sendMainThreadPing()
+{
+    responsivenessTimer().start();
+    send(Messages::WebProcess::MainThreadPing(), 0);
+}
+
+void WebProcessProxy::didReceiveMainThreadPing()
+{
+    responsivenessTimer().stop();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -154,6 +154,9 @@
</span><span class="cx"> 
</span><span class="cx">     void reinstateNetworkProcessAssertionState(NetworkProcessProxy&amp;);
</span><span class="cx"> 
</span><ins>+    void sendMainThreadPing();
+    void didReceiveMainThreadPing();
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit WebProcessProxy(WebProcessPool&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -49,4 +49,6 @@
</span><span class="cx"> 
</span><span class="cx">     RetainIconForPageURL(String pageURL)
</span><span class="cx">     ReleaseIconForPageURL(String pageURL)
</span><ins>+
+    DidReceiveMainThreadPing()
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -980,6 +980,11 @@
</span><span class="cx">     GCController::singleton().garbageCollectNow();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebProcess::mainThreadPing()
+{
+    parentProcessConnection()-&gt;send(Messages::WebProcessProxy::DidReceiveMainThreadPing(), 0);
+}
+
</ins><span class="cx"> void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
</span><span class="cx"> {
</span><span class="cx">     GCController::singleton().setJavaScriptGarbageCollectorTimerEnabled(flag);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.h        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -268,6 +268,8 @@
</span><span class="cx">     void garbageCollectJavaScriptObjects();
</span><span class="cx">     void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
</span><span class="cx"> 
</span><ins>+    void mainThreadPing();
+
</ins><span class="cx">     void releasePageCache();
</span><span class="cx"> 
</span><span class="cx">     void fetchWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, uint64_t callbackID);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (192701 => 192702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in        2015-11-20 22:55:56 UTC (rev 192701)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in        2015-11-20 23:10:02 UTC (rev 192702)
</span><span class="lines">@@ -105,4 +105,6 @@
</span><span class="cx">     PrepareToSuspend()
</span><span class="cx">     CancelPrepareToSuspend()
</span><span class="cx">     ProcessDidResume()
</span><ins>+
+    MainThreadPing()
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>