Baseflow / flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
https://baseflow.com
MIT License
52 stars 33 forks source link

Fixed broadcast receiver leaking when FlutterNativeView is destroyed. #14

Closed splangi closed 5 years ago

splangi commented 5 years ago

:sparkles: Bug Fix

:arrow_heading_down: Currently, when the FlutterNativeView is destroyed and there is a registration to the LocationManagerMODE_CHANGED_ACTION broadcast receiver, then the broadcast receiver is leaked (a warning is printed as well to the logs by Android system)

:new: What is the new behavior (if this is a feature change)?

A PluginRegistry.ViewDestroyListener is implemented and registered. If the FlutterNativeView is destroyed, then the broadcast receiver is unregistered.

:boom: Does this PR introduce a breaking change?

No.

:bug: Recommendations for testing

This is Android only change. Try situations where the FlutterNativeView is destroyed and a listener attached to the serviceStatus stream. This is my first Pull request ever, so I would advise extra caution.

:memo: Links to relevant issues/docs

Did not create an issue, but should have done.

:thinking: Checklist before submitting

splangi commented 5 years ago

I'm going to close this myself, because in fact my issue still persists and the IntentReceiver is leaked. Im using the plugin in a background isolate (aka a background FlutterNativeView) and there the broadcast receiver is leaked despite me calling FlutterNativeView.destroy() in Service.onDestroy().