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

Animation delays cause renders #105

Open
esDotDev opened this issue Sep 13, 2023 · 0 comments
Open

Animation delays cause renders #105

esDotDev opened this issue Sep 13, 2023 · 0 comments

Comments

@esDotDev
Copy link
Contributor

This may not be actionable but logging this just so we can track it and potentially chat about workarounds.

Issue

When animations are delayed they force flutter to re-render at 60fps even though nothing on screen is changing.

This is due to behavior built into Flutters Ticker object, which drives AnimationController, and flutter_animates implementation of delays which rely on a long-running AnimationController that incorporates the duration of the delay into the total duration of an animation.

Each time Ticker ticks it schedules a new frame to be rendered.

Reproduction

This can be reproduced with a repeating distractor like this, which will put the app into a state of constant endless re-rendering.

  Widget build(BuildContext context) => MaterialApp(
        home: Center(
          child: FlutterLogo(size: 200)
              .animate(
                onPlay: (c) => c.repeat(),
              )
              .shimmer(delay: 2.seconds, duration: 1.seconds),
        ),
      );

You can observe the app in a state of constant re-render here:

studio64_zlS9c46icl.mp4

Solution

One possible idea is to create a sub-class of Ticker that exposes a bool scheduleFrame param and can switch between a Timer based tick and a Sheduler based tick. Not sure how feasible this is, I can try and work on a proof of concept to prove viability, and then potentially we can request some tweaks to the Flutter SDK if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant