Title: [293980] trunk
Revision
293980
Author
wenson_hs...@apple.com
Date
2022-05-09 10:32:36 -0700 (Mon, 09 May 2022)

Log Message

[iOS] Double tapping on YouTube video causes playback to pause instead of seek
https://bugs.webkit.org/show_bug.cgi?id=240222
rdar://92637636

Reviewed by Aditya Keerthi and Kate Cheney.

Add a new layout test. See WebKit/ChangeLog for more details.

* fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text-expected.txt: Added.
* fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html: Added.
[iOS] Double tapping on YouTube video causes playback to pause instead of seek
https://bugs.webkit.org/show_bug.cgi?id=240222
rdar://92637636

Reviewed by Aditya Keerthi and Kate Cheney.

Add a new compile-time flag to guard the presence of `-[UITextInteractionAssistant contextMenuInteraction]`. See
WebKit/ChangeLog for more details.

* wtf/PlatformHave.h:
[iOS] Double tapping on YouTube video causes playback to pause instead of seek
https://bugs.webkit.org/show_bug.cgi?id=240222
rdar://92637636

Reviewed by Aditya Keerthi and Kate Cheney.

On some recent versions of iOS, `UITextInteractionAssistant` installs its own context menu interaction by
default. This makes UIKit introduce a `_UIRelationshipGestureRecognizer` to the gesture recognizer graph when
using WKWebView when the text interaction assistant has been activated in order to implement the asynchronous
context menu configuration API.

Currently, we add a direct failure requirement from the immediately resettable deferring gesture to this new
UIKit relationship gesture. This is problematic, since the context menu interaction will automatically add
failure requirements to other long press gestures on the web view, such as the image analysis gestures that
trigger Live Text analysis when long pressing on images with text. As a result, the set of immediately
resettable gestures is now connected to the set of delayed resettable gestures after the first tap when
performing a double tap gesture. Since the `UIWebTouchEventsGestureRecognizer` is a part of this immediate reset
subgraph, this means that the touch event gesture recognizer doesn't get reset until about 320 ms after a tap
when the text interaction assistant has been activated, due to this new context menu interaction.

On YouTube.com, this manifests in a double-tap on the main video player being broken since a double tap gesture
only dispatches `touchstart` and `touchend` on the first tap, and YouTube's script only seeks forwards or
backwards if it observes two `touchstart` events that are close to each other within 350 ms.

To fix this, we simply teach the deferring gesture subgraph partitioning logic in
`-deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:` to funnel the relationship gesture (i.e.
`-gestureRecognizerForFailureRelationships`) of the text interaction assistant's context menu interaction into
the delayed reset subgraph instead of the immediate reset subgraph.

Test: fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
* UIProcess/ios/WKDeferringGestureRecognizer.mm:
(-[WKDeferringGestureRecognizer shouldDeferGestureRecognizer:]):

Canonical link: https://commits.webkit.org/250418@main

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293979 => 293980)


--- trunk/LayoutTests/ChangeLog	2022-05-09 16:52:10 UTC (rev 293979)
+++ trunk/LayoutTests/ChangeLog	2022-05-09 17:32:36 UTC (rev 293980)
@@ -1,3 +1,16 @@
+2022-05-08  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Double tapping on YouTube video causes playback to pause instead of seek
+        https://bugs.webkit.org/show_bug.cgi?id=240222
+        rdar://92637636
+
+        Reviewed by Aditya Keerthi and Kate Cheney.
+
+        Add a new layout test. See WebKit/ChangeLog for more details.
+
+        * fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text-expected.txt: Added.
+        * fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html: Added.
+
 2022-05-09  Kate Cheney  <katherine_che...@apple.com>
 
         Image controls menu button is not appearing for multi-page PDFs

Added: trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text-expected.txt (0 => 293980)


--- trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text-expected.txt	2022-05-09 17:32:36 UTC (rev 293980)
@@ -0,0 +1,11 @@
+PASS touchEventCount became 4
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Select me
+Then double tap here
+Handled touchstart
+Handled touchend
+Handled touchstart
+Handled touchend
+

Added: trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html (0 => 293980)


--- trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html	2022-05-09 17:32:36 UTC (rev 293980)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+jsTestIsAsync = true;
+touchEventCount = 0;
+
+function logTouch(event) {
+    document.getElementById("output").textContent += `Handled ${event.type}\n`;
+    touchEventCount++;
+}
+
+addEventListener("load", async () => {
+    let target = document.getElementById("target");
+    target.addEventListener("touchstart", logTouch);
+    target.addEventListener("touchend", logTouch);
+
+    await UIHelper.longPressElement(document.getElementById("text"));
+    await UIHelper.doubleTapElement(target);
+    await shouldBecomeEqual("touchEventCount", "4");
+
+    finishJSTest();
+});
+</script>
+<style>
+body, html {
+    margin: 0;
+}
+
+#text {
+    display: inline-block;
+    font-size: 24px;
+}
+
+#target {
+    width: 100%;
+    height: 200px;
+    color: white;
+    background-color: tomato;
+    margin-top: 50px;
+    font-size: 16px;
+}
+</style>
+</head>
+<body>
+<p id="text">Select me</p>
+<div id="target">Then double tap here</div>
+<pre id="output"></pre>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WTF/ChangeLog (293979 => 293980)


--- trunk/Source/WTF/ChangeLog	2022-05-09 16:52:10 UTC (rev 293979)
+++ trunk/Source/WTF/ChangeLog	2022-05-09 17:32:36 UTC (rev 293980)
@@ -1,3 +1,16 @@
+2022-05-08  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Double tapping on YouTube video causes playback to pause instead of seek
+        https://bugs.webkit.org/show_bug.cgi?id=240222
+        rdar://92637636
+
+        Reviewed by Aditya Keerthi and Kate Cheney.
+
+        Add a new compile-time flag to guard the presence of `-[UITextInteractionAssistant contextMenuInteraction]`. See
+        WebKit/ChangeLog for more details.
+
+        * wtf/PlatformHave.h:
+
 2022-05-09  Diego Pino Garcia  <dp...@igalia.com>
 
         Unreviewed, non-unified build fixes after r293562

Modified: trunk/Source/WTF/wtf/PlatformHave.h (293979 => 293980)


--- trunk/Source/WTF/wtf/PlatformHave.h	2022-05-09 16:52:10 UTC (rev 293979)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2022-05-09 17:32:36 UTC (rev 293980)
@@ -1084,6 +1084,11 @@
 #define HAVE_CORE_LOCATION_WEBSITE_IDENTIFIERS 1
 #endif
 
+#if !defined(HAVE_TEXT_INTERACTION_WITH_CONTEXT_MENU_INTERACTION) \
+    && PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000
+#define HAVE_TEXT_INTERACTION_WITH_CONTEXT_MENU_INTERACTION 1
+#endif
+
 #if PLATFORM(COCOA)
 #define HAVE_CORE_LOCATION 1
 // kCLAuthorizationStatusAuthorizedWhenInUse is only available on macOS as part of the internal SDK.

Modified: trunk/Source/WebKit/ChangeLog (293979 => 293980)


--- trunk/Source/WebKit/ChangeLog	2022-05-09 16:52:10 UTC (rev 293979)
+++ trunk/Source/WebKit/ChangeLog	2022-05-09 17:32:36 UTC (rev 293980)
@@ -1,3 +1,41 @@
+2022-05-08  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Double tapping on YouTube video causes playback to pause instead of seek
+        https://bugs.webkit.org/show_bug.cgi?id=240222
+        rdar://92637636
+
+        Reviewed by Aditya Keerthi and Kate Cheney.
+
+        On some recent versions of iOS, `UITextInteractionAssistant` installs its own context menu interaction by
+        default. This makes UIKit introduce a `_UIRelationshipGestureRecognizer` to the gesture recognizer graph when
+        using WKWebView when the text interaction assistant has been activated in order to implement the asynchronous
+        context menu configuration API.
+
+        Currently, we add a direct failure requirement from the immediately resettable deferring gesture to this new
+        UIKit relationship gesture. This is problematic, since the context menu interaction will automatically add
+        failure requirements to other long press gestures on the web view, such as the image analysis gestures that
+        trigger Live Text analysis when long pressing on images with text. As a result, the set of immediately
+        resettable gestures is now connected to the set of delayed resettable gestures after the first tap when
+        performing a double tap gesture. Since the `UIWebTouchEventsGestureRecognizer` is a part of this immediate reset
+        subgraph, this means that the touch event gesture recognizer doesn't get reset until about 320 ms after a tap
+        when the text interaction assistant has been activated, due to this new context menu interaction.
+
+        On YouTube.com, this manifests in a double-tap on the main video player being broken since a double tap gesture
+        only dispatches `touchstart` and `touchend` on the first tap, and YouTube's script only seeks forwards or
+        backwards if it observes two `touchstart` events that are close to each other within 350 ms.
+
+        To fix this, we simply teach the deferring gesture subgraph partitioning logic in
+        `-deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:` to funnel the relationship gesture (i.e.
+        `-gestureRecognizerForFailureRelationships`) of the text interaction assistant's context menu interaction into
+        the delayed reset subgraph instead of the immediate reset subgraph.
+
+        Test: fast/events/touch/ios/touch-events-when-double-tapping-after-selecting-text.html
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+        * UIProcess/ios/WKDeferringGestureRecognizer.mm:
+        (-[WKDeferringGestureRecognizer shouldDeferGestureRecognizer:]):
+
 2022-05-09  Per Arne Vollan  <pvol...@apple.com>
 
         Create reports for long process launch times

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (293979 => 293980)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-05-09 16:52:10 UTC (rev 293979)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-05-09 17:32:36 UTC (rev 293980)
@@ -8491,6 +8491,11 @@
             return YES;
 #endif
 
+#if HAVE(TEXT_INTERACTION_WITH_CONTEXT_MENU_INTERACTION)
+        if (gesture == [_textInteractionAssistant contextMenuInteraction].gestureRecognizerForFailureRelationships)
+            return YES;
+#endif
+
 #if ENABLE(DRAG_SUPPORT)
         if (gesture.delegate == [_dragInteraction _initiationDriver])
             return YES;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to