Skip to content

Conversation

@liyuqian
Copy link
Contributor

@liyuqian liyuqian commented Jul 20, 2019

Fix janky scrolls on iPhone X/XS

Fixes #31086

Tests added:

  • Miss at most one frame for irregular scroll drag events
  • Delay at most one event for faster-than-vsync events
  • Handles iPhone XS irregular events with different base delays

Many await tester.pump() are added to existing unit tests that use gesture.moveBy to declare that those input events aren't faster than VSYNC (and the tests shall pass).

@fluttergithubbot fluttergithubbot added d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. labels Jul 20, 2019
@yunyu
Copy link

yunyu commented Jul 22, 2019

I tried this with #28113 (comment), and it looks to have fixed scroll performance after startup (#31086) but not at startup (#28113).

@tvolkert tvolkert requested review from Hixie and goderbauer July 22, 2019 18:32
@liyuqian liyuqian added c: performance Relates to speed or footprint issues (see "perf:" labels) platform-ios iOS applications specifically and removed d: examples Sample code and demos customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. labels Jul 22, 2019
@liyuqian
Copy link
Contributor Author

@yunyu : that's expected. The startup problem is tracked in a separate issue #32170 which requires a different (and probably more sophisticated) solution than this one.

@liyuqian liyuqian added customer: crowd Affects or could affect many people, though not necessarily a specific customer. and removed c: contributor-productivity Team-specific productivity, code health, technical debt. labels Jul 22, 2019
liyuqian added 2 commits July 23, 2019 13:46
Fixes flutter#31086

Tests added:
* Miss at most one frame for irregular scroll drag events
* Delay at most one event for faster-than-vsync events
* Handles iPhone XS irregular events with different base delays
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me, but since scrolling is somewhat delicate, I'd like @Hixie to take a look as well.

@liyuqian
Copy link
Contributor Author

Ping @Hixie ...

@liyuqian liyuqian added customer: marketplace e: device-specific Only manifests on certain devices f: scrolling Viewports, list views, slivers, etc. labels Jul 26, 2019
// That's because `_isScrollFrameInProgress` will always be false at this
// point since it will be cleared by the end of a frame (VSYNC) through
// `_checkPendingDragCallback`. This is the case for all Android/iOS devices
// before iPhone X/XS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta note: this is a commit message, not a comment. The comment should talk about what we do now, not what we used to do. Similarly it shouldn't link to a GitHub comment to explain the situation, it should just explain it inline.

@Hixie
Copy link
Contributor

Hixie commented Jul 29, 2019

This seems like it's fixing an iOS-specific problem (at least the comments are very iOS-specific). Would it make more sense to solve this on the iOS embedder side?

I'm not a huge fan of intentionally delaying input messages. This seems like it could be really bad for games, in particular.

@liyuqian liyuqian requested a review from chinmaygarde July 29, 2019 22:29
@liyuqian
Copy link
Contributor Author

I'm discussing with Chinmay to see how to do this on the iOS embedder.

BTW, the approach that we'll do on the iOS embedder is probably going to be similar to this. The delay won't happen to any input events that are delivered to us regularly at 60Hz (even with this framework patch). For events that are delivered at a faster rate (currently that's probably only iPad Pro at 120Hz), I think we (either the embedder or the framework) need to send that frequency information to the embedder/framework in order to handle all cases.

@genert
Copy link

genert commented Aug 7, 2019

@liyuqian Any updates?

@liyuqian
Copy link
Contributor Author

liyuqian commented Aug 7, 2019 via email

@goderbauer
Copy link
Member

@liyuqian I am closing this one since it sounds like we agreed to take a different approach. Feel free to re-open if this is not true.

@goderbauer goderbauer closed this Aug 7, 2019
@nullxx
Copy link

nullxx commented Aug 24, 2019

Hello. Is this pull request merged to master?

@liyuqian
Copy link
Contributor Author

@nullxx0 : please see #31086 (comment)

liyuqian added a commit to liyuqian/engine that referenced this pull request Sep 1, 2019
Fixes flutter/flutter#31086

This patch is a lower level implementation of
flutter/flutter#36616 that would only impact iOS
engine, and host unittests.
liyuqian added a commit to liyuqian/engine that referenced this pull request Sep 1, 2019
Fixes flutter/flutter#31086

This patch is a lower level implementation of
flutter/flutter#36616 that would only impact iOS
engine, and host unittests.
liyuqian added a commit to flutter/engine that referenced this pull request Sep 10, 2019
Fixes flutter/flutter#31086

This patch is a lower level implementation of
flutter/flutter#36616 that would only impact iOS
engine, and host unittests.
liyuqian added a commit to flutter/engine that referenced this pull request Sep 30, 2019
)

This reverts commit c2879ca.

Additionally, we fix flutter/flutter#40863 by adding a secondary VSYNC callback.

Unit tests are updated to provide VSYNC mocking and check the fix of flutter/flutter#40863.

The root cause of having flutter/flutter#40863 is the false assumption that each input event must trigger a new frame. That was true in the framework PR flutter/flutter#36616 because the input events there are all scrolling move events. When the PR was ported to the engine, we can no longer distinguish different types of events, and tap events may no longer trigger a new frame.

Therefore, this PR directly hooks into the `VsyncWaiter` and uses its (newly added) secondary callback to dispatch the pending input event.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: performance Relates to speed or footprint issues (see "perf:" labels) customer: crowd Affects or could affect many people, though not necessarily a specific customer. e: device-specific Only manifests on certain devices f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scroll performance significantly degraded on iPhone X, Xs devices due to irregular input events delivery.

8 participants