googlemaps / googlemaps/react-native-navigation-sdk

[Bug]: iOS crash during dev reload — NavModule event emitters called with invalid bridge

Abierto
#539 2 comentarios 0 reacciones 1 asignado Reclamado por @jokerttu Ver en GitHub
priority: p3 type: bug
Lenguaje dominante
TypeScript
Estrellas
227
Forks
38
Merge medio
4 d 8 h
PR fusionados (30 d)
16

Descripción

## Bug Description

During React Native development reloads (e.g. CMD+R or fast refresh), the app crashes on iOS because callback methods in `NavModule.mm` attempt to emit events through the React Native bridge after it has been invalidated/torn down.

The crash occurs because navigation callbacks (`onLocationChanged`, `onArrival`, `onRemainingTimeOrDistanceChanged`, `onRouteChanged`, `onReroutingRequestedByOffRoute`, `onStartGuidance`, `onTurnByTurn`) continue to fire after the bridge is destroyed during reload, and the `emit*` calls throw exceptions when the bridge is unavailable.

## Steps to Reproduce

1. Start a React Native app using `@googlemaps/react-native-navigation-sdk` on iOS
2. Begin an active navigation session (so callbacks are firing)
3. Trigger a development reload (CMD+R or save a file with fast refresh)
4. App crashes

## Expected Behavior

The app should gracefully handle the bridge being unavailable during reload without crashing.

## Suggested Fix

Wrap each `emit*` call in the `INavigationCallback` methods in `NavModule.mm` with a try-catch block to silently ignore exceptions when the bridge is invalid during reload. The affected methods are:

- `onLocationChanged:`
- `onArrival:`
- `onRemainingTimeOrDistanceChangedWithNavigator:`
- `onRouteChanged`
- `onReroutingRequestedByOffRoute`
- `onStartGuidance`
- `onTurnByTurn:`

Example fix for one method:

```objc
- (void)onLocationChanged:(NSDictionary *)mappedLocation {
try {
[self emitOnLocationChanged:@{@"location" : mappedLocation}];
} catch (...) {
// Bridge may be invalid during dev reload - ignore to prevent crash
}
}
```

The same pattern applies to all 7 callback methods listed above.

## Environment

- **SDK version**: 0.14.1
- **Platform**: iOS
- **React Native**: 0.76+

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.