Bug 184567 - Add timeout for ensurePositionInformationIsUpToDate
Summary: Add timeout for ensurePositionInformationIsUpToDate
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-12 16:20 PDT by Megan Gardner
Modified: 2018-04-26 16:27 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.98 KB, patch)
2018-04-12 19:40 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (9.04 KB, patch)
2018-04-12 20:29 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews200 for win-future (12.67 MB, application/zip)
2018-04-12 23:35 PDT, EWS Watchlist
no flags Details
Patch (6.50 KB, patch)
2018-04-26 15:18 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (9.78 KB, patch)
2018-04-26 15:21 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2018-04-12 16:20:29 PDT
Add timout for ensurePositionInformationIsUpToDate
Comment 1 Megan Gardner 2018-04-12 19:40:46 PDT
Created attachment 337857 [details]
Patch
Comment 2 Megan Gardner 2018-04-12 19:41:28 PDT
<rdar://problem/38729231>
Comment 3 Alexey Proskuryakov 2018-04-12 19:51:52 PDT
Comment on attachment 337857 [details]
Patch

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

> Source/WebKit/ChangeLog:10
> +        so as to not hang the UI.

What kinds of correctness bugs will this introduce?
Comment 4 Megan Gardner 2018-04-12 19:55:04 PDT
Basically sometimes longPresses will fail to bring up action sheets, or text will fail to be selected. But only if the process would have taken over one second past the already lengthy time for a long press. We believe that it's a better user experience to fail on some long presses that are already taking a long time, but allow the UI to still function rather than waiting all the time, no matter what, for positionInformation to be gathered and returned.
Comment 5 Wenson Hsieh 2018-04-12 20:25:45 PDT
Comment on attachment 337857 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:-1442
> -    _hasValidPositionInformation = YES;

_hasValidPositionInformation needs to be set to YES before calling -_invokeAndRemovePendingHandlersValidForCurrentPositionInformation, otherwise -_currentPositionInformationIsValidForRequest: will return NO, and we'll never invoke the pending handlers in -_invokeAndRemovePendingHandlersValidForCurrentPositionInformation, even in the case where the IPC message came back in a timely manner.
Comment 6 Megan Gardner 2018-04-12 20:29:41 PDT
Created attachment 337860 [details]
Patch
Comment 7 EWS Watchlist 2018-04-12 23:34:50 PDT
Comment on attachment 337860 [details]
Patch

Attachment 337860 [details] did not pass win-ews (win):
Output: http://webkit-queues.webkit.org/results/7301781

New failing tests:
http/tests/security/contentSecurityPolicy/userAgentShadowDOM/allow-audio.html
Comment 8 EWS Watchlist 2018-04-12 23:35:00 PDT
Created attachment 337869 [details]
Archive of layout-test-results from ews200 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews200  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 9 Wenson Hsieh 2018-04-13 20:35:02 PDT
Comment on attachment 337860 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1437
> +        return connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidReceivePositionInformation>(_page->pageID(), Seconds(1), IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);

Nit - this can be 1_s

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1439
> +    _page->process().sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(_positionInformation), _page->pageID(), Seconds(1));

Nit - 1_s here too.

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1444
> +        _hasValidPositionInformation = YES;

It seems like we should set `_hasValidPositionInformation = NO;` when the request times out...perhaps something like:

_hasValidPositionInformation = _page->process().sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(_positionInformation), _page->pageID(), 1_s);

...and then you don't need the isValidForRequest() check down here, because we have valid position info iff. the IPC message came back without timing out.

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1448
> +    // FIXME: We need to clean up these handlers in the event that we are not able to collect data, or if the WebProcess crashes.

This is something we should really fix :(

I filed https://bugs.webkit.org/show_bug.cgi?id=184622 to track this.

> Tools/TestWebKitAPI/Tests/ios/SynchronousTimeoutTests.mm:45
> +    [webView _simulateLongPressActionAtLocation:CGPointMake(100, 100)];

Does this test time out before your change? The implementation of -_simulateLongPressActionAtLocation: is this:

- (void)_simulateLongPressActionAtLocation:(CGPoint)location
{
    RetainPtr<WKContentView> protectedSelf = self;
    [self doAfterPositionInformationUpdate:[protectedSelf] (InteractionInformationAtPosition) {
        if (SEL action = [protectedSelf _actionForLongPress])
            [protectedSelf performSelector:action];
    } forRequest:InteractionInformationRequest(roundedIntPoint(location))];
}

...which would suggest that even with an IPC timeout of ∞ (before your change), we'd still finish the test after calling -_simulateLongPressActionAtLocation:, because -doAfterPositionInformationUpdate: does not block. Instead, I think we need to call into one of the private UITextInput methods that will then call into -ensurePositionInformationIsUpToDate:. One such codepath is -hasSelectablePositionAtPoint:. An example of an existing iOS API test that exercises this is WebKit.InteractionDeadlockAfterCrash.
Comment 10 Megan Gardner 2018-04-26 15:18:10 PDT
Created attachment 338922 [details]
Patch
Comment 11 Megan Gardner 2018-04-26 15:21:55 PDT
Created attachment 338924 [details]
Patch
Comment 12 EWS Watchlist 2018-04-26 15:23:14 PDT
Attachment 338924 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/ios/SynchronousTimeoutTests.mm:29:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Andy Estes 2018-04-26 15:58:16 PDT
Comment on attachment 338924 [details]
Patch

r=me too
Comment 14 WebKit Commit Bot 2018-04-26 16:27:23 PDT
Comment on attachment 338924 [details]
Patch

Clearing flags on attachment: 338924

Committed r231080: <https://trac.webkit.org/changeset/231080>
Comment 15 WebKit Commit Bot 2018-04-26 16:27:25 PDT
All reviewed patches have been landed.  Closing bug.