A hung webpage pretends to be responsive if you scroll
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Nov 2015 23:10:02 +0000 (23:10 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Nov 2015 23:10:02 +0000 (23:10 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192702 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/UIProcess/WebProcessProxy.messages.in
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index ac359c84d8f39c529a9353f5ae0bbfc841dfcc2f..892640b241d6f89f8d0cee5f52a7749c34910a9f 100644 (file)
@@ -1,3 +1,34 @@
+2015-11-20  Geoffrey Garen  <ggaren@apple.com>
+
+        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.
+
 2015-11-20  Simon Fraser  <simon.fraser@apple.com>
 
         Allow more buffer formats in the IOSurface pool
 2015-11-20  Simon Fraser  <simon.fraser@apple.com>
 
         Allow more buffer formats in the IOSurface pool
index 70d8989f17b8adb0089fcce7cb17a7937ca89098..a37e0ed4c43f2f1dfeba81bc7f58918c7dc00a6a 100644 (file)
@@ -1797,8 +1797,6 @@ void WebPageProxy::processNextQueuedWheelEvent()
 
 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
 {
 
 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
 {
-    m_process->responsivenessTimer().start();
-
     m_process->send(
         Messages::EventDispatcher::WheelEvent(
             m_pageID,
     m_process->send(
         Messages::EventDispatcher::WheelEvent(
             m_pageID,
@@ -1808,6 +1806,8 @@ void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
             rubberBandsAtTop(),
             rubberBandsAtBottom()
         ), 0);
             rubberBandsAtTop(),
             rubberBandsAtBottom()
         ), 0);
+
+    m_process->sendMainThreadPing();
 }
 
 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
 }
 
 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
@@ -4500,6 +4500,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
     switch (type) {
     case WebEvent::NoType:
     case WebEvent::MouseMove:
     switch (type) {
     case WebEvent::NoType:
     case WebEvent::MouseMove:
+    case WebEvent::Wheel:
         break;
 
     case WebEvent::MouseDown:
         break;
 
     case WebEvent::MouseDown:
@@ -4507,7 +4508,6 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
     case WebEvent::MouseForceChanged:
     case WebEvent::MouseForceDown:
     case WebEvent::MouseForceUp:
     case WebEvent::MouseForceChanged:
     case WebEvent::MouseForceDown:
     case WebEvent::MouseForceUp:
-    case WebEvent::Wheel:
     case WebEvent::KeyDown:
     case WebEvent::KeyUp:
     case WebEvent::RawKeyDown:
     case WebEvent::KeyDown:
     case WebEvent::KeyUp:
     case WebEvent::RawKeyDown:
index 0b8c29ed25254644cec051c089efc98e71e5033c..cd1de9d758e65cb263b016f6a99409c2b3942fb9 100644 (file)
@@ -1002,4 +1002,15 @@ void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
         m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
 }
 
         m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
 }
 
+void WebProcessProxy::sendMainThreadPing()
+{
+    responsivenessTimer().start();
+    send(Messages::WebProcess::MainThreadPing(), 0);
+}
+
+void WebProcessProxy::didReceiveMainThreadPing()
+{
+    responsivenessTimer().stop();
+}
+
 } // namespace WebKit
 } // namespace WebKit
index 5ab438b711859b9ef83690dff1b78e6f66a70bea..9f3d7d35ae840bcabd8aa8ae82f875abd5010ad7 100644 (file)
@@ -154,6 +154,9 @@ public:
 
     void reinstateNetworkProcessAssertionState(NetworkProcessProxy&);
 
 
     void reinstateNetworkProcessAssertionState(NetworkProcessProxy&);
 
+    void sendMainThreadPing();
+    void didReceiveMainThreadPing();
+
 private:
     explicit WebProcessProxy(WebProcessPool&);
 
 private:
     explicit WebProcessProxy(WebProcessPool&);
 
index 21dbfd4b52d335a2b09405c44738b62a50e62c40..3fa6362730cf2e4493348f21edccab6cab18864d 100644 (file)
@@ -49,4 +49,6 @@ messages -> WebProcessProxy LegacyReceiver {
 
     RetainIconForPageURL(String pageURL)
     ReleaseIconForPageURL(String pageURL)
 
     RetainIconForPageURL(String pageURL)
     ReleaseIconForPageURL(String pageURL)
+
+    DidReceiveMainThreadPing()
 }
 }
index bf140f81ec5c6ccf0215ffc2fd8ac417ae3b42b2..dae928301bf5ea550936484d5bc63a895f35b52a 100644 (file)
@@ -980,6 +980,11 @@ void WebProcess::garbageCollectJavaScriptObjects()
     GCController::singleton().garbageCollectNow();
 }
 
     GCController::singleton().garbageCollectNow();
 }
 
+void WebProcess::mainThreadPing()
+{
+    parentProcessConnection()->send(Messages::WebProcessProxy::DidReceiveMainThreadPing(), 0);
+}
+
 void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
 {
     GCController::singleton().setJavaScriptGarbageCollectorTimerEnabled(flag);
 void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
 {
     GCController::singleton().setJavaScriptGarbageCollectorTimerEnabled(flag);
index 2200ca4ee9ed07c3f2e816a6cd6e4aaca0728b14..614340bfbbffa020941a75217212547b98b155e5 100644 (file)
@@ -268,6 +268,8 @@ private:
     void garbageCollectJavaScriptObjects();
     void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
 
     void garbageCollectJavaScriptObjects();
     void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
 
+    void mainThreadPing();
+
     void releasePageCache();
 
     void fetchWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, uint64_t callbackID);
     void releasePageCache();
 
     void fetchWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, uint64_t callbackID);
index d4372ce90c9e795abdde5e77b76bf0f5d278b00a..087831724b32634090bd6517ced447c5574d8cc6 100644 (file)
@@ -105,4 +105,6 @@ messages -> WebProcess LegacyReceiver {
     PrepareToSuspend()
     CancelPrepareToSuspend()
     ProcessDidResume()
     PrepareToSuspend()
     CancelPrepareToSuspend()
     ProcessDidResume()
+
+    MainThreadPing()
 }
 }