Repository navigation
fix(android): keep UserLocation updating after the Activity is destroyed - #4407
Merged
Merged
Conversation
onHostDestroy fires on every Activity destroy, not only on React teardown, but it called LocationManager.destroy(), which pinned the process-wide start counter at -1000, so no later start() could re-enable the engine. Release the module's count in invalidate() instead. start() also counted twice while stop() released once, so the engine was never disposed after stop(). Fixes #4406
This branch was previously deployed
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.
Description
Fixes #4406, relates to #3965
On Android,
onHostDestroyfires on every Activity destroy, not just on React teardown. It calledLocationManager.destroy(), which set the process-wide start counter to -1000, so once the Activity was gone no laterstart()could re-enable the engine. This change removesdestroy()and releases the module's count ininvalidate()instead.start()also counted twice whilestop()released once, sostop()never disposed the engine. It now counts once.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp.Screenshot OR Video
Tested on an Android 14 emulator with "Don't keep activities" on, using the component below with
adb emu geo fixlocations. The app is backgrounded (Activity destroyed, same pid) and reopened, then 3 new locations are sent:ReactHost.onHostDestroy→ the engine's GPS registration is removed and never comes back;onUpdatecount 6 → 6.onUpdatecount 7 → 10.Also checked with
dumpsys location:Component to reproduce the issue you're fixing
Repro4406.tsx