Skip to content

Back handling state is lost on activity recreation when using a cached engine #159158

Closed
flutter-team-archive/engine
#56715

Description

@gmackall

Predictive back support was recently added, and included changes that maintain a state of whether the framework should handle back events or not
https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java#L724
(and similar for FlutterFragment).

This state is lost when the activity (or activity hosting the fragment) is destroyed and recreated. This is fine when the engine is also destroyed, but if a cached engine is being used then the Flutter routes are not destroyed, so the two get out of sync.

We can fix this by overriding to save this state in onSaveInstanceState (conditionally), and then using the state when recreating the Activity/Fragment, though we will have to be careful to ensure the conditions match exactly when the engine is going to stay around.

Activity

  1. self-assigned this
    on Nov 19, 2024
  2. github-actions commented on Dec 18, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions