-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
We are building a real-time multiplayer game that uses Rive animations with audio event synchronization. When players perform actions remotely, the game continues running in the background, and animations must maintain their timeline to ensure audio plays at the correct positions. However, when the app window is hidden (e.g., minimized, covered by other windows, or in mission control on macOS), frame rendering stops, causing animations to freeze and audio to not play.
Proposal
Proposed Solution
Add a forceFramesEnabled property to SchedulerBinding that allows developers to explicitly opt-in to continuous frame rendering when the app is hidden. This would be particularly useful for:
- Real-time games that continue running in the background
- Applications with animation-driven audio (like Rive)
- Multiplayer applications where game logic continues server-side
I have already implemented this feature in PR #173862.
Current Workaround
We've implemented a hacky solution by intercepting the AppLifecycleState.hidden state and replacing it with AppLifecycleState.inactive in a custom DesktopWidgetsFlutterBinding:
@override
void handleAppLifecycleStateChanged(AppLifecycleState state) {
if (state == AppLifecycleState.hidden) {
_isHidden = true;
super.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
} else {
if (state == AppLifecycleState.resumed) {
_isHidden = false;
}
super.handleAppLifecycleStateChanged(state);
}
}