Skip to content

move resampler to handlePointerEvent and fix complex_layout_android__scroll_smoothness with PointerEvent#66745

Merged
fluttergithubbot merged 4 commits intoflutter:masterfrom
CareF:relocate_resampler
Oct 6, 2020
Merged

move resampler to handlePointerEvent and fix complex_layout_android__scroll_smoothness with PointerEvent#66745
fluttergithubbot merged 4 commits intoflutter:masterfrom
CareF:relocate_resampler

Conversation

@CareF
Copy link
Contributor

@CareF CareF commented Sep 26, 2020

Description

This is to move the resampling logic to handlePointerEvent, so that it's accessible to WidgetTester, as enabled by #64846. This also fixes #66608 and closes #66612 .

In terms of fixing #66608, this is an alternative to #66611. #66611 is more close to the solution before #64846, so I suggest to land #66611 and observe for a couple of runs before merge this PR to see if the change makes some difference to the test result.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Sep 26, 2020
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Sep 26, 2020
@CareF
Copy link
Contributor Author

CareF commented Sep 26, 2020

No extra test is necessary because we already prepared the test that fits both current solution and this one in #64424

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still feeling this is a workaround, see also #60558 (comment)
This is a public method because it's needed in WidgetTester.

Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed in WidgetTester? If needed then maybe this is find but ideally the name would just be "sample()" instead of triggerResample.

Copy link
Contributor Author

@CareF CareF Sep 29, 2020

Choose a reason for hiding this comment

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

why is this needed in WidgetTester? If needed then maybe this is find but ideally the name would just be "sample()" instead of triggerResample.

Because triggerResample is called in _flushPointerEventQueue, which is before the input injection in WidgetTester. triggerResample is in _flushPointerEventQueue because otherwise sample is not properly called: when _pendingPointerEvents is empty, we still need to call _resampler.sample for updated resampled event (see #60558 (comment)) @dreveman

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for the name, I'm feeling binding.sample is confusing because binding is not the subject of sample...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank to @liyuqian 's comment I realize this triggerResample is kind of duplicate with _handleSampleTimeChanged. triggerResample is removed in the new commit.

void _handleSampleTimeChanged() {
if (!locked) {
_flushPointerEventQueue();
_resampler.sample(samplingOffset);
Copy link
Contributor

Choose a reason for hiding this comment

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

What if resamplingEnabled is false here? Should we stop the resampler instead then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can happen when resample was on but is turned off, and the logic should be to just discard the remaining events queued in the resampler? @dreveman

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. PTAL.

Copy link
Contributor

@dreveman dreveman left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 277a72e into flutter:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

complex_layout_android__scroll_smoothness generates unexpected numbers

5 participants