Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move resampler to handlePointerEvent and fix complex_layout_android__scroll_smoothness with PointerEvent #66745

Merged
merged 4 commits into from Oct 6, 2020

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

@flutter-dashboard flutter-dashboard bot commented Sep 26, 2020

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.

@CareF
Copy link
Contributor Author

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

@CareF CareF force-pushed the relocate_resampler branch from ab8e2d0 to 6b45413 Sep 29, 2020
/// to force resampler for triggering a resample operation.
///
/// This should only be called when resampling is enabled.
void triggerResample() {
Copy link
Contributor Author

@CareF CareF Sep 29, 2020

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

@dreveman dreveman Sep 29, 2020

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

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

@CareF CareF Sep 30, 2020

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

Copy link
Contributor Author

@CareF CareF Oct 2, 2020

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

@CareF CareF force-pushed the relocate_resampler branch 2 times, most recently from db0585d to 2a94311 Oct 2, 2020
@CareF CareF force-pushed the relocate_resampler branch from 2a94311 to fa27319 Oct 2, 2020
@@ -389,14 +388,14 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H

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

@dreveman dreveman Oct 2, 2020

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

Copy link
Contributor Author

@CareF CareF Oct 2, 2020

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

@CareF CareF Oct 2, 2020

Updated. PTAL.

Copy link
Contributor

@dreveman dreveman left a comment

lgtm

Copy link
Contributor

@liyuqian liyuqian left a comment

LGTM

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

Successfully merging this pull request may close these issues.

5 participants