Bug 213763

Summary: Swipe snapshot is removed too early when swiping away from a page that is still loading
Product: WebKit Reporter: Tim Horton <thorton>
Component: New BugsAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, berto, cdumez, cgarcia, darin, ews-watchlist, gustavo, hi, megan_gardner, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Tim Horton 2020-06-29 16:44:42 PDT
Swipe snapshot is removed too early when swiping away from a page that is still loading
Comment 1 Tim Horton 2020-06-29 16:45:39 PDT
Created attachment 403138 [details]
Patch
Comment 2 Tim Horton 2020-06-29 16:45:42 PDT
<rdar://problem/64576811>
Comment 3 Tim Horton 2020-06-29 16:47:19 PDT
swipe-test.js has some extra unused stuff in it, but it's a copy of the one from the non-HTTP tests directory, so I think it's preferable this way.
Comment 4 Tim Horton 2020-06-29 17:06:58 PDT
Created attachment 403142 [details]
Patch
Comment 5 Devin Rousso 2020-06-29 18:16:57 PDT
Comment on attachment 403142 [details]
Patch

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

it looks like GTK and WPE some love :(

> Source/WebKit/UIProcess/PageClient.h:467
> +    virtual void didFinishNavigation(API::Navigation*) = 0;
> +    virtual void didFailNavigation(API::Navigation*) = 0;
> +    virtual void didSameDocumentNavigationForMainFrame(API::Navigation*, SameDocumentNavigationType) = 0;

Can we use `API::Navigation&` for all of this plumbing instead so we know that it's providing something that exists?  It seems less-than-ideal to me to have the possibility of a function called `_didFinishNavigation` that passes a `nullptr` instead of an `API::Navigation` šŸ˜…

> Source/WebKit/UIProcess/WebPageProxy.cpp:4875
> +        pageClient().didFinishNavigation(navigation.get());

Should we still include some mention to "main frame" in these renamed function names since they're only called if `isMainFrame`?  i.e. `didFinishMainFrameNavigation`

> Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm:647
> +    m_pendingNavigation = nullptr;

I think we should also do this inside `ViewGestureController::removeSwipeSnapshot` for GTK (`ViewGestureControllerGtk.cpp`)

> LayoutTests/http/tests/swipe/resources/swipe-test.js:42
> +    var duration = Date.now() - window.localStorage[key + "swipeStartTime"];

NIT: `let`
Comment 6 Tim Horton 2020-06-29 18:26:04 PDT
(In reply to Devin Rousso from comment #5)
> Comment on attachment 403142 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=403142&action=review
> 
> it looks like GTK and WPE some love :(

Yep, uploading a new patch.

> > Source/WebKit/UIProcess/PageClient.h:467
> > +    virtual void didFinishNavigation(API::Navigation*) = 0;
> > +    virtual void didFailNavigation(API::Navigation*) = 0;
> > +    virtual void didSameDocumentNavigationForMainFrame(API::Navigation*, SameDocumentNavigationType) = 0;
> 
> Can we use `API::Navigation&` for all of this plumbing instead so we know
> that it's providing something that exists?  It seems less-than-ideal to me
> to have the possibility of a function called `_didFinishNavigation` that
> passes a `nullptr` instead of an `API::Navigation` šŸ˜…

Sadly, it is currently possible to get a null here.

> > Source/WebKit/UIProcess/WebPageProxy.cpp:4875
> > +        pageClient().didFinishNavigation(navigation.get());
> 
> Should we still include some mention to "main frame" in these renamed
> function names since they're only called if `isMainFrame`?  i.e.
> `didFinishMainFrameNavigation`

Nope, Navigation is a main-frame thing in the WebKit2 API (see e.g. WKNavigationDelegate); these names are a holdover from the olden days.

(Possible we should *remove* it from the SameDocument one, really, but I am much too lazy).

> > Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm:647
> > +    m_pendingNavigation = nullptr;
> 
> I think we should also do this inside
> `ViewGestureController::removeSwipeSnapshot` for GTK
> (`ViewGestureControllerGtk.cpp`)

Quite!

> > LayoutTests/http/tests/swipe/resources/swipe-test.js:42
> > +    var duration = Date.now() - window.localStorage[key + "swipeStartTime"];
> 
> NIT: `let`

You JavaScript people :) 

Thank you for your eyes!
Comment 7 Tim Horton 2020-06-29 18:31:11 PDT
Created attachment 403153 [details]
Patch
Comment 8 EWS Watchlist 2020-06-29 18:32:07 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 9 Tim Horton 2020-06-29 19:33:39 PDT
Created attachment 403162 [details]
Patch
Comment 10 Tim Horton 2020-06-30 00:03:36 PDT
Test failures look legit.
Comment 11 Tim Horton 2020-07-01 16:23:34 PDT
Created attachment 403331 [details]
Patch
Comment 12 Darin Adler 2020-07-01 16:28:48 PDT
Comment on attachment 403331 [details]
Patch

Looks great. Iā€™m going to say review+ even before EWS tells us what we should really think.
Comment 13 Tim Horton 2020-07-01 16:50:15 PDT
Just gotta skip the test on WK1!
Comment 14 Tim Horton 2020-07-01 16:53:04 PDT
Created attachment 403334 [details]
Patch
Comment 15 EWS 2020-07-01 17:32:12 PDT
Committed r263825: <https://trac.webkit.org/changeset/263825>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403334 [details].