-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I did miss this PR among the other trackpad PRs!
4f0b40d
to
56f9e97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
56f9e97
to
4b5d311
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to me with some minor suggestions.
aa41020
to
55505af
Compare
I'd like to test this out on Monday, I have been working on animating discrete mouse wheel data in flutter/flutter#115314, and ran into the fact that we don't distinguish between trackpad and mouse on web. |
Gold has detected about 70 new digest(s) on patchset 9. |
fcbd2b7
to
59bb9f9
Compare
Gold has detected about 2 new digest(s) on patchset 9. |
Ah I think the PR's Gold is broken now, I had the issue before, will probably have to recreate it... |
I think you can resolve it by creating a new commit and not force pushing. Skia Gold is easily confused by force pushes unfortunately. |
Oh it looks like Gold is fine. 👍 |
Ok I have tested this out with 4 mice and 2 trackpads running web on Mac. 😁 I ran a simple flutter app with an infinite number of scrolling items in a list, and had (in the framework) the event data output to tell me:
For trackpads, every single one was correctly identified as a trackpad. 🎉 For the 4 mice, all of them were able to fool this into thinking it was a trackpad when I scrolled the wheel really fast. It was easier to do on some compared to others, and it would only occur once per occasion - the event before and after were correctly identified as mouse. The incoming delta was ~40 or ~320 in the instances I saw it occur. On one of the cheap mouses I have, it was really easy to hit the 40 delta, so it was easier to reproduce. On one of the gaming mice, it was harder to trigger it, and would happen with an input of 320. I am guessing these devices all have a different level of precision. Here is some of that output, let me know if it helps, or if I can gather more info for you. :)
|
I was able to reproduce it, looks like sometimes macOS scroll acceleration can by chance happen to line up with expected values for a trackpad. Should be solvable with by cross-checking with the previous event, since this shouldn't happen for more than one event in a row. |
@Piinks See if you have the same problems with the latest change |
Thanks! I will check it out today! |
Still able to trip it at ~40:
Let me know if there is more info I can gather. |
Can you capture the issue again with print('deltaX=${event.deltaX}, deltaY=${event.deltaY}, wheelDeltaX=${event.wheelDeltaX}, wheelDeltaY=${event.wheelDeltaY}, timeStamp=${event.timeStamp}'); at the beginning of |
Totally, whipping this up now. I was out for the holiday.
In the examples I shared, that is the whole event, from starting to ending the scroll on the stepped wheel. The incorrect one showed up on the second event. |
Here it is with one quick twirl on the mouse wheel:
|
f2ebf49
to
b3d1a27
Compare
Nice! I just tested it with all of the devices I have, it was correct every time. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yjbanov was also interested in this.. FYI
This LGTM!
Thanks @Piinks for jumping in and testing it thoroughly! Great to see progress made. I'm curious what failures would look and feel like if this logic fails. We can't enumerate all browser engines, and some browser engines may be customized to use different numbers. In that case, will we observe slight degradations in scrolling quality? Or could the issues be severe? |
This doesn't affect scrolling, it's only for custom interactions such as InteractiveViewer. If there was some problem you might see strangeness there where during a pan it might zoom by accident on one event in a series. We can gate it to only certain browser / OS combinations if you want. Already Firefox is ruled out. I personally have only verified it on macOS Chrome and Safari. |
Thanks for explaining @moffatman. I plan to use this in the framework to execute an animation when mouse wheel scroll input comes from a mouse, ignoring trackpad - as an additional example of how this will be used. From my understanding, this change will not necessarily change anything in the framework unless we make a change there based on the input device. |
Basically, bias towards choosing mouse, but if timestamps are available, we can check the previous event and ensure that false-mouses are avoided.
Apparently some high-precision mice use 120 instead of 240 as the wheelDelta per tick.
b3d1a27
to
426cac0
Compare
flutter/flutter#112171 needs to be approved and merged first due to the assertion changes |
Also fix setting of timeStamp in test.
@Piinks I updated the logic again, can you recheck with the various devices you have and see if there is a regression? Thanks 😄 |
Sure thing! I have even more mice now. 😳 |
Tested with 7 mice and 2 trackpads. I was not able to fool it. @justinmc had different luck last time with the magic mouse. On my magic mouse, I swiped and flung on it a bunch but did not see it come through as a mouse. 👍 |
@Piinks That's great! I'll try again with my magic mouse tonight and then plan to merge flutter/flutter#112171 if I can't reproduce that bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some last minute nits.
@@ -349,7 +350,7 @@ mixin _WheelEventListenerMixin on _BaseAdapter { | |||
return (wheelDelta - (-3 * delta)).abs() > 1; | |||
} | |||
|
|||
bool _isTrackpadEvent(DomWheelEvent event, DomWheelEvent? lastEvent) { | |||
bool _isTrackpadEvent(DomWheelEvent event, DomWheelEvent? lastEvent, bool? lastEventWasTrackpad) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use _lastWheelEventWasTrackpad directly instead of passing it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, now that _isTrackpadEvent doesn't call itself, maybe you don't need to pass in _lastWheelEvent either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, I'll change it to just use the members directly.
@@ -264,6 +264,7 @@ abstract class _BaseAdapter { | |||
final PointerDataConverter _pointerDataConverter; | |||
final KeyboardConverter _keyboardConverter; | |||
DomWheelEvent? _lastWheelEvent; | |||
bool? _lastWheelEventWasTrackpad; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: What do you think about making this non-nullable and initializing it to false? Currently it probably represents reality more accurately as-is, because a value of null
means that there was no last wheel event. However, that null state is not used anywhere.
Up to you what you think is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have it this way as in some previous iterations the null state did matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I left a review on the framework PR (flutter/flutter#112171) saying that I was unable to break this using the Magic Mouse this time. Thanks for fixing that and for cleaning up those last few comments!
Rerunning the Fuchsia test, it looked like an infrastructure flake.
The framework change landed, I am just waiting on a lean build from that in the framework and then we can land this. 🎉 |
…116939) * b97d3545f [Impeller] Speculatively attempt to fix Metal PSO construction errors on host targets. (flutter/engine#38229) * 99f3d1931 Web trackpad pan (flutter/engine#36346) * e144f81e9 [impeller] Fix typo in compiller help (flutter/engine#38214)
* Guess at trackpad pans on web * Add test * Update comment * Handle macOS accelerated scroll wheel * Fix test after last commit * Disable on firefox * Pull out _isTrackpadEvent and add doc links * Fix issue with floating point / integer conversion error. * Workaround for magic mouse events which happen to be divisible by 120. * Refactor to handle bad luck in accelerated mouse deltas. Basically, bias towards choosing mouse, but if timestamps are available, we can check the previous event and ensure that false-mouses are avoided. * Use 120 wheelDelta to identify mouse-accelerated events instead of 240 Apparently some high-precision mice use 120 instead of 240 as the wheelDelta per tick. * Handle multiple bad-luck events in a row. Also fix setting of timeStamp in test. * Cleanup parameters
* Guess at trackpad pans on web * Add test * Update comment * Handle macOS accelerated scroll wheel * Fix test after last commit * Disable on firefox * Pull out _isTrackpadEvent and add doc links * Fix issue with floating point / integer conversion error. * Workaround for magic mouse events which happen to be divisible by 120. * Refactor to handle bad luck in accelerated mouse deltas. Basically, bias towards choosing mouse, but if timestamps are available, we can check the previous event and ensure that false-mouses are avoided. * Use 120 wheelDelta to identify mouse-accelerated events instead of 240 Apparently some high-precision mice use 120 instead of 240 as the wheelDelta per tick. * Handle multiple bad-luck events in a row. Also fix setting of timeStamp in test. * Cleanup parameters
…lutter#116939) * b97d3545f [Impeller] Speculatively attempt to fix Metal PSO construction errors on host targets. (flutter/engine#38229) * 99f3d1931 Web trackpad pan (flutter/engine#36346) * e144f81e9 [impeller] Fix typo in compiller help (flutter/engine#38214)
// While not in any formal web standard, `blink` and `webkit` browsers use | ||
// a delta of 120 to represent one mouse wheel turn. If both dimensions of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a kind of heuristic to guess at whether an event is from mouse or trackpad.
Part of flutter/flutter#64210
Sequence
Pre-launch Checklist
writing and running engine tests.
///
).