Skip to content

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

@gmackall

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.

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