Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [android] Bound the IrisMethodChannel lifecycle with the FlutterEngine #75

Merged
merged 8 commits into from
Aug 10, 2023

Conversation

littleGnAl
Copy link
Collaborator

At this time, if the IrisMethodChannel.dispose not be called explicitly, the native resources created (created via NativeBindingDelegate.createNativeApiEngine) by the IrisMethodChannel can not be cleaned. So the native resources only be cleaned when the APP process is killed.

But by default, the FlutterEngine lifecycle is bound to the android Activity lifecycle. In the single Flutter APP, the FlutterEngine is killed when the whole APP exit(the Activity.onDestory has been called), at this time, the whole APP exit, and the APP process has been killed, so the native resources created by the IrisMethodChannel can be cleaned depending on the process lifecycle.

But in some scenarios, say that start a foreground service in android, when you try to remove the APP from the recent list, the Activity has been removed, the FlutterEngine has been destroyed, but the APP still running (the process not be killed), which will cause the memory leak, and unexpected behavior.

So we need to notify the IrisMethodChannel(dart side) to clean the native resources when the FlutterEngine is destroyed.

@littleGnAl littleGnAl merged commit 7249bf0 into main Aug 10, 2023
40 checks passed
@littleGnAl littleGnAl deleted the littlegnal/detect-isolate-kill branch August 10, 2023 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant