-
Notifications
You must be signed in to change notification settings - Fork 6k
Scroll inertia cancel for iPadOS #34929
Conversation
|
@hellohuanlin would you mind taking a look? |
hellohuanlin
left a comment
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.
Thanks for the contribution! This is not a complete review since I'm still trying to understand the logic here. Left a few questions.
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
|
@moffatman thanks for the contribution, looks like there's still a few minor updates needed (mostly comments and clarifications) to get this through. |
Yep, will be addressing it soon. I was looking into a way to avoid having to guess with magic numbers at all, but it hasn't panned out. |
f2bca5a to
5cffdcb
Compare
|
I updated the numbers after some further data collection. I took the excel line-of-best-fit and subtracted an additional 200ms to account for all outlier data points (we want to bias towards reducing "false positives"/unwanted scroll-cancel events). I think the reason that the numbers are not a direct relationship is because I am using the UIGestureRecognizer velocity, whereas a proper UIScrollView would have a different velocity tracking formula. This is quite an edge case (flutter-based app running on iPad emulation in a Mac), so this is best-effort basis. |
|
@moffatman what's the relation between this PR and flutter/flutter#108298? Is this PR ready for another review? And do you need my review on the other PR? |
|
@hellohuanlin |
hellohuanlin
left a comment
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.
Much easier to understand with the comments
| MouseState _mouseState; | ||
| // Timestamp after which a scroll inertia cancel event should be inferred. | ||
| NSTimeInterval _scrollInertiaEventStartline; | ||
| // When an iOS app is running in emulation on an Apple Silicon Mac, trackpad input goes through |
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.
what do you mean by emulation? I assume you mean catalyst and not simulator?
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.
It's not catalyst, since the app isn't recompiled. I don't think there is an official name for this runtime, it's exposed by this property: https://developer.apple.com/documentation/foundation/nsprocessinfo/3608556-iosapponmac
| // Timestamp after which a scroll inertia cancel event should be inferred. | ||
| NSTimeInterval _scrollInertiaEventStartline; | ||
| // When an iOS app is running in emulation on an Apple Silicon Mac, trackpad input goes through | ||
| // a translation layer, and events are not received with precise deltas. Due to this, we can't |
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.
can you explain what is "translation layer"?
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.
When running unmodified iOS app on Mac, events which would usually be CGEvent or NSEvent are turned into UIEvent. Since the iOS code can't be modified, there is some layer (which I believe is called UINSMouseEventTranslator based on debug data), that acts as a bridge between UIKit and AppKit. This is an apple private implementation detail and not documented.
|
Can we land this please? Looks like all presubs are green. |

Send a
PointerScrollInertiaCancelevent when the user touches the trackpad. Done in two ways, as one only works on real iPad devices, and the other only works when in emulation on an Apple Silicon Mac.Part of flutter/flutter#106979
Pre-launch Checklist
writing and running engine tests.
///).