Bug 204664 - [iOS] WKWebView touch event gesture recognition should not block the application process main thread when possible
Summary: [iOS] WKWebView touch event gesture recognition should not block the applicat...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-11-27 22:35 PST by Wenson Hsieh
Modified: 2020-05-07 03:39 PDT (History)
9 users (show)

See Also:


Attachments
First pass (59.12 KB, patch)
2019-12-05 14:23 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix iOS tests on non-internal builds (61.96 KB, patch)
2019-12-06 11:21 PST, Wenson Hsieh
thorton: review+
Details | Formatted Diff | Diff
For EWS (62.53 KB, patch)
2019-12-07 17:18 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2019-11-27 22:35:23 PST
<rdar://problem/38670692>
Comment 1 Wenson Hsieh 2019-11-27 22:36:59 PST
...the hope is to eliminate all hangs under -[WKContentView(WKInteraction) _webTouchEventsRecognized:].
Comment 2 Wenson Hsieh 2019-12-05 14:23:17 PST Comment hidden (obsolete)
Comment 3 Wenson Hsieh 2019-12-06 11:21:36 PST
Created attachment 385027 [details]
Fix iOS tests on non-internal builds
Comment 4 Tim Horton 2019-12-06 17:08:38 PST
Comment on attachment 385027 [details]
Fix iOS tests on non-internal builds

View in context: https://bugs.webkit.org/attachment.cgi?id=385027&action=review

> Source/WebKit/UIProcess/WebPageProxy.cpp:2818
> +            --m_handlingPreventableTouchStartCount;

This needs some sort of care in the underflow case. Also, it's possible we don't want to do all this work in the error case (at least on crash?)? I'm not really sure.

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:168
> +#define USE_DEFERRING_GESTURE_RECOGNIZERS ENABLE(IOS_TOUCH_EVENTS)

This is fairly surprising to me. I don't usually like it when a USE() or ENABLE() is in a header that you can possibly not have (so prefix header or Platform.h/FeatureDefines.h and friends are OK, but here would not be), but 🤷‍♂️

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4211
> +    [_twoFingerDoubleTapGestureRecognizer setEnabled:NO];
> +    [_twoFingerDoubleTapGestureRecognizer setEnabled:YES];

Wonder if we should just add a _wk_cancel category method on UIGR :) this comes up enough
Comment 5 Tim Horton 2019-12-06 17:08:55 PST
Prediction: this will not be the last patch in this series :)
Comment 6 Wenson Hsieh 2019-12-06 17:12:57 PST
(In reply to Tim Horton from comment #5)
> Prediction: this will not be the last patch in this series :)

Quite likely :(
Comment 7 Wenson Hsieh 2019-12-06 21:31:59 PST
Comment on attachment 385027 [details]
Fix iOS tests on non-internal builds

View in context: https://bugs.webkit.org/attachment.cgi?id=385027&action=review

>> Source/WebKit/UIProcess/WebPageProxy.cpp:2818
>> +            --m_handlingPreventableTouchStartCount;
> 
> This needs some sort of care in the underflow case. Also, it's possible we don't want to do all this work in the error case (at least on crash?)? I'm not really sure.

I’ll assert that it should never be zero here, and also avoid incrementing past 0 for the underflow case.

It also looks like the work here is not necessary in the case where the web process terminates, since the gestures should be reset anyways by -cleanupInteraction in WKContentView. I’ll double check by forcing the web process to crash while handling a touchstart.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:168
>> +#define USE_DEFERRING_GESTURE_RECOGNIZERS ENABLE(IOS_TOUCH_EVENTS)
> 
> This is fairly surprising to me. I don't usually like it when a USE() or ENABLE() is in a header that you can possibly not have (so prefix header or Platform.h/FeatureDefines.h and friends are OK, but here would not be), but 🤷‍♂️

Good point! I’ll change these to just be ENABLE(IOS_TOUCH_EVENTS) instead.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4211
>> +    [_twoFingerDoubleTapGestureRecognizer setEnabled:YES];
> 
> Wonder if we should just add a _wk_cancel category method on UIGR :) this comes up enough

Sounds good — I’ll add a -_wk_cancel category method on UIGestureRecognizer in this file.
Comment 8 Wenson Hsieh 2019-12-07 17:18:32 PST
Created attachment 385109 [details]
For EWS
Comment 9 WebKit Commit Bot 2019-12-07 19:57:31 PST
Comment on attachment 385109 [details]
For EWS

Clearing flags on attachment: 385109

Committed r253267: <https://trac.webkit.org/changeset/253267>
Comment 10 Antoine Quint 2020-04-29 07:37:48 PDT
This caused bug 211179.
Comment 11 Antoine Quint 2020-05-07 03:39:54 PDT
This also caused bug 211521.