Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@moffatman
Copy link
Contributor

Send a PointerScrollInertiaCancel event 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

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@jmagman
Copy link
Member

jmagman commented Jul 27, 2022

@hellohuanlin would you mind taking a look?

Copy link
Contributor

@hellohuanlin hellohuanlin left a 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.

@jmagman
Copy link
Member

jmagman commented Aug 10, 2022

@moffatman thanks for the contribution, looks like there's still a few minor updates needed (mostly comments and clarifications) to get this through.

@moffatman
Copy link
Contributor Author

@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.

@chinmaygarde chinmaygarde added the Work in progress (WIP) Not ready (yet) for review! label Aug 18, 2022
@moffatman
Copy link
Contributor Author

@hellohuanlin

image

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.

@hellohuanlin
Copy link
Contributor

@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?

@moffatman moffatman removed the Work in progress (WIP) Not ready (yet) for review! label Aug 23, 2022
@moffatman
Copy link
Contributor Author

@hellohuanlin
The other PR is kind of related, they both need to estimate the macOS scrolling curve, and improve scroll experience on Mac. But they don't depend on each other in any way. This one is now ready for review, if you want you can look at the other one as well, but not necessary.

Copy link
Contributor

@hellohuanlin hellohuanlin left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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"?

Copy link
Contributor Author

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.

@chinmaygarde
Copy link
Member

Can we land this please? Looks like all presubs are green.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants