Skip to content

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

Merged
illuminati1911 merged 2 commits into
googlemaps:mainfrom
miguelmiesion:patch-1
Sep 7, 2026
Merged

fix: call Navigator#cleanup() during cleanup on Android to release location updates#635
illuminati1911 merged 2 commits into
googlemaps:mainfrom
miguelmiesion:patch-1

Conversation

@miguelmiesion

@miguelmiesion miguelmiesion commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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.

@illuminati1911 illuminati1911 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

The cleanup call was accidentally removed during a larger new architecture update we merged earlier this year. This looks good to me.

@illuminati1911
illuminati1911 merged commit 036c83e into googlemaps:main Sep 7, 2026
17 checks passed
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

3 participants