RESOLVED FIXED 235436
[GTK] REGRESSION: Touch scrolling is broken
https://bugs.webkit.org/show_bug.cgi?id=235436
Summary [GTK] REGRESSION: Touch scrolling is broken
Alice Mikhaylenko
Reported 2022-01-21 06:41:45 PST
There are 2 issues, I'm not sure whether they are symptoms of the same thing or not. 1. Scrolling is very very slow and delayed - I've investigated this and it's caused by unwanted smooth scroll animations 2. Kinetic scrolling is too fast With a quick hack: ```diff diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp index 559a89bfc027..c940e565bea8 100644 --- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -3017,7 +3017,7 @@ void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase* webViewBase, const delta.scale(static_cast<float>(Scrollbar::pixelsPerLineStep())); priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(const_cast<GdkEvent*>(event), { x, y }, widgetRootCoords(GTK_WIDGET(webViewBase), x, y), - delta, wheelTicks, toWebKitWheelEventPhase(phase), toWebKitWheelEventPhase(momentumPhase), priv->wheelHasPreciseDeltas)); + delta, wheelTicks, toWebKitWheelEventPhase(phase), toWebKitWheelEventPhase(momentumPhase), priv->wheelHasPreciseDeltas || TRUE)); } void webkitWebViewBaseSetWheelHasPreciseDeltas(WebKitWebViewBase* webViewBase, bool hasPreciseDeltas) ``` the lag indeed goes away, but kinetic scrolling just stops working altogether. Without that hack and with smooth scrolling disabled, kinetic scrolling seems like it immediately jumps at the position where it would end up if it was animating. With it enabled I can't tell if it's smooth or kinetic scrolling animating.
Attachments
Patch (2.42 KB, patch)
2022-01-24 01:40 PST, Alice Mikhaylenko
no flags
Patch (15.66 KB, patch)
2022-01-24 04:30 PST, Alice Mikhaylenko
no flags
Patch (16.75 KB, patch)
2022-01-24 05:55 PST, Alice Mikhaylenko
no flags
Alice Mikhaylenko
Comment 1 2022-01-21 06:43:07 PST
Clarification: this is all only on touchscreen; touchpad scrolling works as expected. Seems to happen with both GTK3 and GTK4 builds too.
Alice Mikhaylenko
Comment 2 2022-01-24 01:22:40 PST
Ok, and no kinetic scrolling boils down to simply: ```diff --- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -2011,7 +2011,7 @@ static void webkitWebViewBaseTouchSwipe(WebKitWebViewBase* webViewBase, gdouble return; } - webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -velocityX / Scrollbar::pixelsPerLineStep(), velocityY / Scrollbar::pixelsPerLineStep(), x, y, WheelEventPhase::NoPhase, WheelEventPhase::Began); + webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Ended, WheelEventPhase::NoPhase); } } ``` Since the kinetic scroll handling currently handles event history and everything, we don't care about the velocity we get from GtkGestureSwipe. On the contrary, it messes things up as the event is no longer a scroll stop event as the deltas are non-0. Makign the event look same as the equivalent touchpad event fixes everything.
Alice Mikhaylenko
Comment 3 2022-01-24 01:40:04 PST
EWS Watchlist
Comment 4 2022-01-24 01:41:29 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Chris Lord
Comment 5 2022-01-24 02:12:52 PST
Comment on attachment 449789 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=449789&action=review > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:2014 > + webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Ended, WheelEventPhase::NoPhase); Great that this is so simple - I don't know if this will affect test results anywhere, but EWS ought to tell us soon I suppose. Looks fine to me though. > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:3020 > + delta, wheelTicks, toWebKitWheelEventPhase(phase), toWebKitWheelEventPhase(momentumPhase), true)); This will definitely cause many tests to fail - precise deltas will need to be conditionally enabled for wheel events synthesised by touch events.
Alice Mikhaylenko
Comment 6 2022-01-24 02:15:02 PST
That codepath is only used for touch events though. :)
Chris Lord
Comment 7 2022-01-24 02:18:53 PST
(In reply to Alexander Mikhaylenko from comment #6) > That codepath is only used for touch events though. :) Is the patch view annotation tripping me up here? webkitWebViewBaseSynthesizeWheelEvent is used by WebKitTestRunner/gtk/EventSenderProxyGtk.cpp for synthesising wheel events in layout tests.
Alice Mikhaylenko
Comment 8 2022-01-24 02:24:26 PST
Ah ok, nevermind then. Once again I've only looked in Source/ but not Tools/.
Alice Mikhaylenko
Comment 9 2022-01-24 04:30:14 PST
Actually I have another idea.
Alice Mikhaylenko
Comment 10 2022-01-24 04:30:37 PST
Chris Lord
Comment 11 2022-01-24 04:37:46 PST
Comment on attachment 449799 [details] Patch LGTM :)
Alice Mikhaylenko
Comment 12 2022-01-24 05:55:54 PST
Chris Lord
Comment 13 2022-01-25 09:42:54 PST
Comment on attachment 449804 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=449804&action=review LGTM. Wondering about that sign, but I assume you've tested it :) > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:2013 > + webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -velocityX, -velocityY, x, y, WheelEventPhase::NoPhase, WheelEventPhase::Began, true); Is flipping the sign of velocityY here intentional?
Alice Mikhaylenko
Comment 14 2022-01-25 10:05:05 PST
> but I assume you've tested it :) I had. The path that broke was tests, not touch scrolling - hence adjustments in the new patch. > Is flipping the sign of velocityY here intentional? Yes, it was wrong.
EWS
Comment 15 2022-01-26 00:12:01 PST
Committed r288609 (246428@main): <https://commits.webkit.org/246428@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 449804 [details].
Note You need to log in before you can comment on or make changes to this bug.