Repository navigation
Conversation
NavModule is a process-wide singleton that outlives the React Native instance. On a reload (CMD+R, fast refresh) it stayed registered as the navigator and road-snapped location listener, and the next callback emitted through an event emitter bound to the torn-down runtime, crashing the app. Implement invalidate to detach both listeners and drop the emitter, and skip emitting while no emitter is set. initializeSession re-adds the listeners and setEventEmitterCallback restores the emitter on the next initialization. Fixes googlemaps#539
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.
Fixes #539
Problem
NavModuleis a process-wide singleton (allocWithZone+dispatch_once) that outlives the React Native instance. On a reload (CMD+R, fast refresh) nothing detaches it from the navigator / road-snapped location provider, so the next navigator callback emits through the event emitter of the torn-down runtime and the app aborts.Reproduced on
main(v0.18.0), example app, iPhone 16 Pro simulator (iOS 18.6): start guidance + route simulation, then reload:Fix
invalidate(called by React Native on reload) to remove the navigator and road-snapped location listeners and drop the event emitter, on the main queue.INavigationCallbackmethods while no emitter is set (same checkNavAutoModulealready uses).initializeSessionre-adds the listeners andsetEventEmitterCallbackrestores the emitter, so events keep working after a reload.Testing
Example app, iPhone 16 Pro simulator, iOS 18.6, Navigation SDK 11.1.0:
onStartGuidance/ remaining-time updates reach JS again.Not tested on Android (change is iOS-only).