Title: [121113] trunk/Source/WebKit2
Revision
121113
Author
[email protected]
Date
2012-06-24 01:15:08 -0700 (Sun, 24 Jun 2012)

Log Message

REGRESSION(r120329): Intermittent WebProcess shutdowns due to out-of-line DidReceiveEvent messages.
<rdar://problem/11686974>
<http://webkit.org/b/89659>

Reviewed by Sam Weinig.

Instead of sending DidReceiveEvent for key events as DispatchMessageEvenWhenWaitingForSyncReply,
use proper synchronous messages. This makes the WebProcess block while the UIProcess handles
the event but prevents a weird race condition where DidReceiveEvent gets dispatched just before
a synchronous DecidePolicyForNavigationAction and something happens below DidReceiveEvent that
invalidates the frame ID passed to DecidePolicyForNavigationAction.

This is a speculative fire-fighting fix.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveKeyEvent):
(WebKit::WebPageProxy::didReceiveEvent):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::keyEvent):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (121112 => 121113)


--- trunk/Source/WebKit2/ChangeLog	2012-06-24 07:27:03 UTC (rev 121112)
+++ trunk/Source/WebKit2/ChangeLog	2012-06-24 08:15:08 UTC (rev 121113)
@@ -1,3 +1,27 @@
+2012-06-24  Andreas Kling  <[email protected]>
+
+        REGRESSION(r120329): Intermittent WebProcess shutdowns due to out-of-line DidReceiveEvent messages.
+        <rdar://problem/11686974>
+        <http://webkit.org/b/89659>
+
+        Reviewed by Sam Weinig.
+
+        Instead of sending DidReceiveEvent for key events as DispatchMessageEvenWhenWaitingForSyncReply,
+        use proper synchronous messages. This makes the WebProcess block while the UIProcess handles
+        the event but prevents a weird race condition where DidReceiveEvent gets dispatched just before
+        a synchronous DecidePolicyForNavigationAction and something happens below DidReceiveEvent that
+        invalidates the frame ID passed to DecidePolicyForNavigationAction.
+
+        This is a speculative fire-fighting fix.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didReceiveKeyEvent):
+        (WebKit::WebPageProxy::didReceiveEvent):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::keyEvent):
+
 2012-06-23  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r121058.

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (121112 => 121113)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-06-24 07:27:03 UTC (rev 121112)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-06-24 08:15:08 UTC (rev 121113)
@@ -3149,6 +3149,42 @@
     m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
 }
 
+void WebPageProxy::didReceiveKeyEvent(uint32_t opaqueType, bool handled)
+{
+    process()->responsivenessTimer()->stop();
+
+    WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
+
+    switch (type) {
+    case WebEvent::KeyDown:
+    case WebEvent::KeyUp:
+    case WebEvent::RawKeyDown:
+    case WebEvent::Char: {
+        LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
+
+        NativeWebKeyboardEvent event = m_keyEventQueue.first();
+        MESSAGE_CHECK(type == event.type());
+
+        m_keyEventQueue.removeFirst();
+
+        m_pageClient->doneWithKeyEvent(event, handled);
+
+        if (handled)
+            break;
+
+        if (m_uiClient.implementsDidNotHandleKeyEvent())
+            m_uiClient.didNotHandleKeyEvent(this, event);
+#if PLATFORM(WIN)
+        else
+            ::TranslateMessage(event.nativeEvent());
+#endif
+        break;
+    }
+    default:
+        ASSERT_NOT_REACHED();
+    }
+}
+
 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
 {
     WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
@@ -3161,10 +3197,6 @@
     case WebEvent::MouseDown:
     case WebEvent::MouseUp:
     case WebEvent::Wheel:
-    case WebEvent::KeyDown:
-    case WebEvent::KeyUp:
-    case WebEvent::RawKeyDown:
-    case WebEvent::Char:
 #if ENABLE(GESTURE_EVENTS)
     case WebEvent::GestureScrollBegin:
     case WebEvent::GestureScrollEnd:
@@ -3178,6 +3210,8 @@
 #endif
         process()->responsivenessTimer()->stop();
         break;
+    default:
+        ASSERT_NOT_REACHED();
     }
 
     switch (type) {
@@ -3222,30 +3256,6 @@
         break;
     }
 
-    case WebEvent::KeyDown:
-    case WebEvent::KeyUp:
-    case WebEvent::RawKeyDown:
-    case WebEvent::Char: {
-        LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
-
-        NativeWebKeyboardEvent event = m_keyEventQueue.first();
-        MESSAGE_CHECK(type == event.type());
-
-        m_keyEventQueue.removeFirst();
-
-        m_pageClient->doneWithKeyEvent(event, handled);
-
-        if (handled)
-            break;
-
-        if (m_uiClient.implementsDidNotHandleKeyEvent())
-            m_uiClient.didNotHandleKeyEvent(this, event);
-#if PLATFORM(WIN)
-        else
-            ::TranslateMessage(event.nativeEvent());
-#endif
-        break;
-    }
 #if ENABLE(TOUCH_EVENTS)
     case WebEvent::TouchStart:
     case WebEvent::TouchMove:
@@ -3263,6 +3273,8 @@
         break;
     }
 #endif
+    default:
+        ASSERT_NOT_REACHED();
     }
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (121112 => 121113)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-06-24 07:27:03 UTC (rev 121112)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-06-24 08:15:08 UTC (rev 121113)
@@ -909,6 +909,7 @@
     void setCursorHiddenUntilMouseMoves(bool);
 
     void didReceiveEvent(uint32_t opaqueType, bool handled);
+    void didReceiveKeyEvent(uint32_t opaqueType, bool handled);
     void stopResponsivenessTimer();
 
     void voidCallback(uint64_t);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (121112 => 121113)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2012-06-24 07:27:03 UTC (rev 121112)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2012-06-24 08:15:08 UTC (rev 121113)
@@ -33,6 +33,7 @@
     UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, WTF::String mimeType, WTF::String url, WTF::String pluginsPageURL)
     DidChangeViewportProperties(WebCore::ViewportAttributes attributes)
     DidReceiveEvent(uint32_t type, bool handled)
+    DidReceiveKeyEvent(uint32_t type, bool handled) -> ()
     StopResponsivenessTimer()
     SetCursor(WebCore::Cursor cursor)
     SetCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (121112 => 121113)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-06-24 07:27:03 UTC (rev 121112)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-06-24 08:15:08 UTC (rev 121113)
@@ -1439,9 +1439,7 @@
     if (!handled)
         handled = performDefaultBehaviorForKeyEvent(keyboardEvent);
 
-    // The receiving end relies on DidReceiveEvent and InterpretQueuedKeyEvent arriving in the same order they are sent
-    // (for keyboard events.) We set the DispatchMessageEvenWhenWaitingForSyncReply flag to ensure consistent ordering.
-    connection()->send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(keyboardEvent.type()), handled), m_pageID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+    sendSync(Messages::WebPageProxy::DidReceiveKeyEvent(static_cast<uint32_t>(keyboardEvent.type()), handled), Messages::WebPageProxy::DidReceiveKeyEvent::Reply());
 }
 
 void WebPage::keyEventSyncForTesting(const WebKeyboardEvent& keyboardEvent, bool& handled)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to