Skip to content

Conversation

@tguerin
Copy link
Contributor

@tguerin tguerin commented Aug 15, 2025

This change adds opt-in, subtree-scoped frame forcing for Flutter animations as described in #174356 (comment)

Fixes #174356

This change could help fix #133533.

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].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces forceFramesEnabled to SchedulerBinding, allowing apps to continue rendering when hidden or paused. The implementation is clear, well-documented, and includes a comprehensive set of tests. The logic for enabling/disabling frames and scheduling a new frame when needed appears correct.

I've found a small improvement opportunity in the new tests to ensure better test isolation by using the corresponding change that resets the _rootElement. Additionally, the change to WidgetsBinding.resetInternalState is not mentioned in the PR description, which would be good to add for clarity.

Overall, this is a great addition that addresses a valid use case.

@tguerin tguerin force-pushed the allow_rendering_when_hidden branch 5 times, most recently from 01bfbc5 to 2dc92da Compare August 15, 2025 21:39
@tguerin tguerin marked this pull request as draft August 15, 2025 21:42
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

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

@tguerin tguerin force-pushed the allow_rendering_when_hidden branch 4 times, most recently from 7e77bb3 to a81175b Compare August 16, 2025 07:40
@tguerin tguerin marked this pull request as ready for review August 16, 2025 08:02
@tguerin tguerin force-pushed the allow_rendering_when_hidden branch from a81175b to 174e9ef Compare August 16, 2025 08:12
@justinmc
Copy link
Contributor

We should make sure we are very certain that we want to support this use case before we add something like this due to the ability to shoot yourself in the foot here. @loic-sharma do you know if this is a valid concern for multiwindow/desktop apps?

@loic-sharma
Copy link
Member

@loic-sharma do you know if this is a valid concern for multiwindow/desktop apps?

I don't know, however, I suspect that there's a better fix for #133533.

@chinmaygarde Would you have any thoughts on this change for this use case:

Some desktop applications, such as games or apps with animation-driven audio (e.g., Rive) rely on continuous frame rendering to maintain smooth animation timing and audio playback.
The current lifecycle behavior stops scheduling frames when the app is hidden or paused (e.g., mission control on MacOS), which can interrupt these use cases.

@tguerin
Copy link
Contributor Author

tguerin commented Aug 20, 2025

The fix was not originally made for this specific issue, but to address a problem we’re facing in our app. We are building a Desktop game, and when the window is completely covered, frame rendering stops, which prevents our animations from running.

To work around this, we currently have to intercept the hidden state and replace it with inactive, which is really hacky. The key requirement for us is to keep animations running even when the window is not visible.

I’m open to different approaches to achieve this, as long as we can meet that requirement.

@dkwingsmt
Copy link
Contributor

dkwingsmt commented Aug 22, 2025

@tguerin Can you explain why you'd like the animation to keep running at background? What is broken by missing these animation frames? It would be great if you can open a new issue for this so we can discuss it and track it more clearly.

@tguerin
Copy link
Contributor Author

tguerin commented Aug 25, 2025

Here is the issue #174356

@Piinks
Copy link
Contributor

Piinks commented Sep 26, 2025

Does this comment in the linked issue provide what is needed here? #174356 (comment)

@tguerin
Copy link
Contributor Author

tguerin commented Sep 30, 2025

I will rework the PR to include the suggested approach.

@tguerin tguerin force-pushed the allow_rendering_when_hidden branch from 174e9ef to 0a731ca Compare October 6, 2025 22:56
@tguerin tguerin changed the title [SchedulerBinding] Add forceFramesEnabled to allow rendering when app is hidden or paused [Animation] Add granular frame forcing to animations: Ticker.forceFrames, TickerMode.forceFrames, and TickerMode.merge Oct 6, 2025
@tguerin tguerin changed the title [Animation] Add granular frame forcing to animations: Ticker.forceFrames, TickerMode.forceFrames, and TickerMode.merge [Animation] Add granular frame forcing to animations Oct 6, 2025
@tguerin tguerin force-pushed the allow_rendering_when_hidden branch 3 times, most recently from 244f1af to 639b7ff Compare October 7, 2025 05:43
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
This change adds opt-in, subtree-scoped frame forcing for Flutter
animations as described in
flutter#174356 (comment)

Fixes flutter#174356

This change could help fix flutter#133533. 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
This change adds opt-in, subtree-scoped frame forcing for Flutter
animations as described in
flutter#174356 (comment)

Fixes flutter#174356

This change could help fix flutter#133533. 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
This rolls the latest DevTools in customer tests, and rolls the latest
customer tests in Flutter. This unblocks:
flutter#173862.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
This change adds opt-in, subtree-scoped frame forcing for Flutter
animations as described in
flutter#174356 (comment)

Fixes flutter#174356

This change could help fix flutter#133533. 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

5 participants