fix: call Navigator#cleanup() during cleanup on Android to release location updates - #635
Open
miguelmiesion wants to merge 1 commit into
Open
fix: call Navigator#cleanup() during cleanup on Android to release location updates#635miguelmiesion wants to merge 1 commit into
miguelmiesion wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Android,
NavModule.cleanup()removes listeners, stops guidance, clearsdestinations, and nulls out the module's
mNavigatorreference, but neverinvokes the native
Navigator#cleanup(). Since the Navigator is a singletonheld by
NavigationApi, dropping the module's reference doesn't destroy it:its internal location listener keeps running for the lifetime of the app
process, so the system location-in-use indicator stays on after the
navigation session has ended and only clears when the process is killed.
Google's instance cleanup best practices
recommend calling
Navigator#cleanupwhen the navigation session iscompleted. This PR adds the missing
navigator.cleanup()call at the end ofthe teardown block, after guidance is stopped and destinations are cleared.
The method already captures a local
final Navigator navigatorreferencebefore nulling out
mNavigator, so the call fits the existing pattern.Tested on a physical Android device: with this change the location indicator
turns off immediately when
cleanup()resolves, and subsequentinit()→ set destination →startGuidance()→cleanup()cycles workcorrectly, including backgrounding/foregrounding between cycles.
If
Navigator#cleanup()was omitted intentionally (e.g. to work around aknown race condition on re-initialization), happy to hear the context and
adjust the approach.
Fixes #634
Pre-launch Checklist