Title: [262891] trunk/Source/WebKit
Revision
262891
Author
wenson_hs...@apple.com
Date
2020-06-10 19:40:43 -0700 (Wed, 10 Jun 2020)

Log Message

[iOS] editing/pasteboard/dom-paste tests consistently time out
https://bugs.webkit.org/show_bug.cgi?id=213061
<rdar://problem/64211161>

Reviewed by Darin Adler.

On recent versions of iOS, system changes have moved the timing of the call to
`-requestAutocorrectionContextWithCompletionHandler:` when focusing an editable element. This results in a
consistently reproducible deadlock between the UI process and web process if a page tries to request
programmatic clipboard access during the click event (importantly, in the same runloop as element focus).

What ends up happening is that the autocorrection context is requested by the UI process shortly after the
(unbounded) sync IPC message for the DOM paste arrives, so we end up waiting forever for the sync-IPC-blocked
web process to respond. Normally this just results in a 1 second hang, and the DOM paste proceeds as normal.
However these layout tests purposefully opt out of sync IPC timeouts (precisely so that we can catch bugs like
this). See below for more details.

* UIProcess/ios/WKContentViewInteraction.h:

Keep track of the most recent autocorrection context that arrived in the UI process.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanUpInteraction]):

Clear out the autocorrection context, in case the web process crashes.

(-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):

If the autocorrection context is requested while handling a DOM paste, we know that the latest autocorrection
context must be up to date, since the autocorrection context is computed and sent immediately before a DOM paste
request. Use this to immediately invoke the completion handler, without any sync IPC back to the web process.

(-[WKContentView _handleAutocorrectionContext:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (262890 => 262891)


--- trunk/Source/WebKit/ChangeLog	2020-06-11 02:20:47 UTC (rev 262890)
+++ trunk/Source/WebKit/ChangeLog	2020-06-11 02:40:43 UTC (rev 262891)
@@ -1,3 +1,39 @@
+2020-06-10  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] editing/pasteboard/dom-paste tests consistently time out
+        https://bugs.webkit.org/show_bug.cgi?id=213061
+        <rdar://problem/64211161>
+
+        Reviewed by Darin Adler.
+
+        On recent versions of iOS, system changes have moved the timing of the call to
+        `-requestAutocorrectionContextWithCompletionHandler:` when focusing an editable element. This results in a
+        consistently reproducible deadlock between the UI process and web process if a page tries to request
+        programmatic clipboard access during the click event (importantly, in the same runloop as element focus).
+
+        What ends up happening is that the autocorrection context is requested by the UI process shortly after the
+        (unbounded) sync IPC message for the DOM paste arrives, so we end up waiting forever for the sync-IPC-blocked
+        web process to respond. Normally this just results in a 1 second hang, and the DOM paste proceeds as normal.
+        However these layout tests purposefully opt out of sync IPC timeouts (precisely so that we can catch bugs like
+        this). See below for more details.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+
+        Keep track of the most recent autocorrection context that arrived in the UI process.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanUpInteraction]):
+
+        Clear out the autocorrection context, in case the web process crashes.
+
+        (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
+
+        If the autocorrection context is requested while handling a DOM paste, we know that the latest autocorrection
+        context must be up to date, since the autocorrection context is computed and sent immediately before a DOM paste
+        request. Use this to immediately invoke the completion handler, without any sync IPC back to the web process.
+
+        (-[WKContentView _handleAutocorrectionContext:]):
+
 2020-06-10  Hiro (mzp) Mizuno  <m...@apple.com>
 
         [iOS] Option + Forward Delete should delete next word

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (262890 => 262891)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-06-11 02:20:47 UTC (rev 262890)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-06-11 02:40:43 UTC (rev 262891)
@@ -50,6 +50,7 @@
 #import "WKShareSheet.h"
 #import "WKSyntheticTapGestureRecognizer.h"
 #import "WKTouchActionGestureRecognizer.h"
+#import "WebAutocorrectionContext.h"
 #import "_WKElementAction.h"
 #import "_WKFormInputSession.h"
 #import <UIKit/UIView.h>
@@ -95,7 +96,6 @@
 class SmartMagnificationController;
 class WebOpenPanelResultListenerProxy;
 class WebPageProxy;
-struct WebAutocorrectionContext;
 }
 
 @class WebEvent;
@@ -309,6 +309,7 @@
     };
     TapHighlightInformation _tapHighlightInformation;
 
+    WebKit::WebAutocorrectionContext _lastAutocorrectionContext;
     WebKit::WKAutoCorrectionData _autocorrectionData;
     WebKit::InteractionInformationAtPosition _positionInformation;
     WebKit::FocusedElementInformation _focusedElementInformation;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (262890 => 262891)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-11 02:20:47 UTC (rev 262890)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-11 02:40:43 UTC (rev 262891)
@@ -927,6 +927,8 @@
     _additionalContextForStrongPasswordAssistance = nil;
     _waitingForEditDragSnapshot = NO;
 
+    _lastAutocorrectionContext = { };
+
 #if USE(UIKIT_KEYBOARD_ADDITIONS)
     _candidateViewNeedsUpdate = NO;
     _seenHardwareKeyDownInNonEditableElement = NO;
@@ -4246,6 +4248,11 @@
         return;
     }
 
+    if (_domPasteRequestHandler) {
+        completionHandler([WKAutocorrectionContext autocorrectionContextWithWebContext:_lastAutocorrectionContext]);
+        return;
+    }
+
     // FIXME: Remove the synchronous call when <rdar://problem/16207002> is fixed.
     const bool useSyncRequest = true;
 
@@ -4265,6 +4272,7 @@
 
 - (void)_handleAutocorrectionContext:(const WebKit::WebAutocorrectionContext&)context
 {
+    _lastAutocorrectionContext = context;
     [self _invokePendingAutocorrectionContextHandler:[WKAutocorrectionContext autocorrectionContextWithWebContext:context]];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to