maps: [Bug]: Usage of `UserLocation` causes app crash on Android when new arch is disabled
Mapbox Implementation
Mapbox
Mapbox Version
default
React Native Version
0.76.7
Platform
Android
@rnmapbox/maps version
10.1.37
Standalone component to reproduce
import React, { useEffect, useState } from "react";
import { StyleSheet, View } from "react-native";
import Mapbox from "@rnmapbox/maps";
const App = () => {
const [ready, setReady] = useState(false);
useEffect(() => {
Mapbox.requestAndroidLocationPermissions()
.then((isGranted) => {
setReady(isGranted);
})
.catch(console.error);
}, [setReady]);
return (
<View style={styles.page}>
<View style={styles.container}>
{ready ? (
<Mapbox.MapView style={styles.map}>
{/* ๐ Issue goes away when removing this line. */}
<Mapbox.UserLocation />
</Mapbox.MapView>
) : null}
</View>
</View>
);
};
export default App;
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
container: {
height: 300,
width: 300,
},
map: {
flex: 1,
},
});
Observed behavior and steps to reproduce
The app completely crashes, with the following error message (seen via adb logs):
03-03 16:29:09.956 17182 17182 E AndroidRuntime: FATAL EXCEPTION: main
03-03 16:29:09.956 17182 17182 E AndroidRuntime: Process: com.andrewchou.rnmapsissuerepro, PID: 17182
03-03 16:29:09.956 17182 17182 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.bridge.CxxCallbackImpl.invoke(java.lang.Object[])' on a null object reference
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.NativeRNMBXLocationModuleSpec.emitOnLocationUpdate(NativeRNMBXLocationModuleSpec.java:38)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.modules.RNMBXLocationModule.access$emitOnLocationUpdate(RNMBXLocationModule.kt:18)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.modules.RNMBXLocationModule$onUserLocationChangeCallback$1.onLocationChange(RNMBXLocationModule.kt:62)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.location.LocationManager.onLocationChanged(LocationManager.kt:251)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.location.LocationManager.onSuccess(LocationManager.kt:260)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.rnmapbox.rnmbx.location.LocationManager.onSuccess(LocationManager.kt:93)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.mapbox.android.core.location.LocationEngineCommonCompatKt$toCommonCompat$1.onSuccess(LocationEngineCommonCompat.kt:99)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.mapbox.android.core.location.LocationEngineCommonCompatKt$toCommonCompat$1.onSuccess(LocationEngineCommonCompat.kt:93)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.mapbox.common.location.compat.LocationEngineImpl$liveTrackingObserver$1$onLocationUpdateReceived$lambda-2$lambda-1$$inlined$postOrCall$1.run(LocationEngineImpl.kt:361)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7656)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
03-03 16:29:09.956 17182 17182 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Expected behavior
App should not crash when using a component that subscribes to location updates.
Notes / preliminary analysis
Itโs important to note that this seems to only be an issue when:
- The new arch is disabled. The issue is not present when the new arch is enabled
- Using
10.1.37of this library.10.1.36does NOT have this issue. - Using the
UserLocationcomponent. Guessing itโs not necessarily only tied to that component but anything that may subscribe to location updates.
I can create a test repo if helpful, but hopefully this is enough to work with.
Additional links and references
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 20 (2 by maintainers)
Commits related to this issue
- update @rnmapbox/maps have to pin to 10.1.36 instead of 10.1.37 because of this issue: https://github.com/rnmapbox/maps/issues/3796 — committed to digidem/comapeo-mobile by achou11 2 years ago
- update @rnmapbox/maps have to pin to 10.1.36 instead of 10.1.37 because of this issue: https://github.com/rnmapbox/maps/issues/3796 — committed to digidem/comapeo-mobile by achou11 2 years ago
- update @rnmapbox/maps have to pin to 10.1.36 instead of 10.1.37 because of this issue: https://github.com/rnmapbox/maps/issues/3796 — committed to digidem/comapeo-mobile by achou11 2 years ago
Same issue on 10.1.39
@seyedmostafahasani Iโm just a mere user ๐ Up to the maintainers to figure out how to address this.
Only thing I can suggest is pinning the version to a working version, which in my case was using 10.1.36
I just downgraded to 10.1.36 as well, and it fixed the issue for me.
Same issue for me, downgrading to 10.1.36 made it working back