Skip to content

[Desktop] Allow applications to continue frame rendering when hidden for real-time games and animation-driven audio #174356

@tguerin

Description

@tguerin

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);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: animationAnimation APIsa: desktopRunning on desktopc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions