Skip to content

fix: call Navigator#cleanup() during cleanup on Android to release location updates - #635

Open
miguelmiesion wants to merge 1 commit into
googlemaps:mainfrom
miguelmiesion:patch-1
Open

fix: call Navigator#cleanup() during cleanup on Android to release location updates#635
miguelmiesion wants to merge 1 commit into
googlemaps:mainfrom
miguelmiesion:patch-1

Conversation

@miguelmiesion

@miguelmiesion miguelmiesion commented Aug 19, 2026

Copy link
Copy Markdown

On Android, NavModule.cleanup() removes listeners, stops guidance, clears
destinations, and nulls out the module's mNavigator reference, but never
invokes the native Navigator#cleanup(). Since the Navigator is a singleton
held 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#cleanup when the navigation session is
completed. This PR adds the missing navigator.cleanup() call at the end of
the teardown block, after guidance is stopped and destinations are cleared.
The method already captures a local final Navigator navigator reference
before 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 subsequent
init() → set destination → startGuidance()cleanup() cycles work
correctly, including backgrounding/foregrounding between cycles.

If Navigator#cleanup() was omitted intentionally (e.g. to work around a
known race condition on re-initialization), happy to hear the context and
adjust the approach.

Fixes #634

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation
  • I added new tests to check the change I am making
  • All existing and new tests are passing.

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.

[Bug]: Android: cleanup() never calls Navigator#cleanup(), leaving a 1Hz location request active for the app process lifetime

2 participants