Skip to content

Conversation

@MxSoul
Copy link

@MxSoul MxSoul commented Mar 15, 2022

Same as #96512

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, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the a: animation Animation APIs label Mar 15, 2022
@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 (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels Mar 15, 2022
@MxSoul MxSoul changed the title 【WIP】fix restart animation Fix restart ballistic animation while child size change when update simulation Mar 15, 2022
@MxSoul MxSoul changed the title Fix restart ballistic animation while child size change when update simulation Fix restart ballistic animation while child size change By update simulation Mar 15, 2022
@MxSoul MxSoul changed the title Fix restart ballistic animation while child size change By update simulation Update animation simulation to fix restart ballistic animation Mar 15, 2022
@MxSoul
Copy link
Author

MxSoul commented Mar 15, 2022

@Piinks
I tried a new method to solve the problem.
I don't know if this is the right plan, Maybe you could take a look. If you think this solution is feasible, I will complete the documentation and fix the test.

Here's what I think:

In the previous method:

  1. I need to update the BouncingSimulator/ClampingSimulator properties.
  2. I need to call a specific method in ClampingSimulator/BouncingSimulator.
  3. I have to use type checking to get me to call this method.

In the new method:

  1. My purpose is to not restart the sliding animation
  2. Maybe we can use the new Simulator, just make sure it is generated with the initial position and initial velocity.
  3. Then we update the new Simulator to the animation.

@goderbauer goderbauer requested a review from Piinks March 16, 2022 21:38
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hey @MxSoul thanks for re-working this! This looks like a really nice approach. Do you have tests that validate the expected behavior?

@MxSoul MxSoul force-pushed the update_ballistic_animation branch from 03b1d51 to 790997f Compare March 25, 2022 07:39
@MxSoul
Copy link
Author

MxSoul commented Mar 25, 2022

@Piinks
Yes, Everything is as expected. I record a video and add test. Docs also update.
Please let me know if need me to do anything else. 😄
I record clamping performance only. Bouncing performs consistently before and after modification(validate the expected)

Before After
android  snap
Record By Pixel 3a XL

We could see sliding damping is not as great as before. The animation of clamping is same as without size change.
Although the problem of excessive damping has been fixed, there is still a certain gap between the sliding of Clamping and the native curve of Android. The "snap" which described in #77497 has reappeared. So I will try to reland it after this PR merge

@MxSoul MxSoul requested a review from Piinks March 25, 2022 08:49
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

This is looking good.
@goderbauer can you give a second review?


/// Update the simulation without restarting the animation.
///
/// The current simulation will be replaced with the provided [Simulation].
Copy link
Member

Choose a reason for hiding this comment

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

This could mean that the animation is making a jump if the simulations are very different at the current point in time? Since there is no smooth transition from one simulation to the next one, we should probably document that here.


/// Update the simulation without restarting the animation.
///
/// The current simulation will be replaced with the provided [Simulation].
Copy link
Member

Choose a reason for hiding this comment

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

Also, it may be useful to add a little color to this doc describing when this API could be useful (and when not - with links to other API methods that may be more appropriate).

Comment on lines +551 to +553
late double _initVelocity;

late double _initPosition;
Copy link
Member

Choose a reason for hiding this comment

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

change late to final for both of these?

Comment on lines +535 to +536
double initVelocity = 0.0,
double initPosition = 0.0,
Copy link
Member

Choose a reason for hiding this comment

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

Somewhere we need to document what these parameters mean. Either in the constructor doc, or - if we can make them final as suggested below - you could make them public and document on there what they mean.

Copy link
Member

Choose a reason for hiding this comment

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

I am especially curious to learn why these have the "init" prefix...

/// Update the ballistic animation instead of restarting it, for example as the result of a layout change after a flinging gesture.
///
/// The [initVelocity] and [initPosition] refer to the starting values of the new ballistic animation.
Simulation? updateBallisticAnimation(double initVelocity, double initPosition);
Copy link
Member

Choose a reason for hiding this comment

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

document: when does this return null? What does that mean?

Copy link
Author

Choose a reason for hiding this comment

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

added

_initPosition,
);
if (newSimulation != null) {
_controller.updateSimulation(newSimulation);
Copy link
Member

Choose a reason for hiding this comment

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

How is it guaranteed that this doesn't give as a discontinued animation with a big jump when we switch simulations? (see my other comment about this above)

@goderbauer
Copy link
Member

Same as #96512

Can you please update the PR description with an actual description of what this is fixing? I tried to follow the chain of links, but it is not clear to me. Is this fixing a perf regression? A fidelity problem? A bit of both?

@goderbauer
Copy link
Member

@MxSoul Do you still have plans to come back to this PR?

@goderbauer
Copy link
Member

@MxSoul I saw that you responded to some of the comments, did you maybe forget to push your updated code to this PR?

@goderbauer
Copy link
Member

Since there hasn't been a response, I am going to close this one for now. If you find the time to work on this again, feel free to reopen this with the feedback from above addressed.

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

Labels

a: animation Animation APIs a: text input Entering text in a text field or keyboard related problems f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants