react-native-background-geolocation
react-native-background-geolocation copied to clipboard
App is crashing - NullPointerException com.transistorsoft.locationmanager.geofence.TSGeofenceManager in startMonitoringPolygone
Hello Chris,
we got the error "Attempt to invoke virtual method 'java.lang.String com.transistorsoft.locationmanager.geofence.TSGeofence.getIdentifier()' on a null object reference"
Stack trace: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.transistorsoft.locationmanager.geofence.TSGeofence.getIdentifier()' on a null object reference
at com.transistorsoft.locationmanager.geofence.TSGeofenceManager.startMonitoringPolygon at com.transistorsoft.locationmanager.geofence.TSGeofenceManager.start at com.transistorsoft.locationmanager.service.TrackingService.start at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$z0.run at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012)
We have tried to investigate this issue on our end. We tried to add corrupted/invalid/empty/undefined/null... geofences in BackgroundGeolocation.addGeofences method, but we were not able to reproduce this error in debug build.
Could you please look at this in the native code? We would really appreciate it. Or what do you suggest to do on our end? Do you have some idea?
Your Environment
- Plugin version: 4.17.1
- Platform: Android
- OS version: Android 11 and 14
- Device manufacturer / model: Pixel 7a (AP2A.240905.003)
- React Native version (
react-native -v): 0.73.7 - Plugin config
const state:State = await BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_MEDIUM,
distanceFilter: 20,
reset: true,
debug: false,
stopOnTerminate: false,
stopOnStationary: false,
startOnBoot: true,
enableHeadless: true,
maxDaysToPersist: 2,
geofenceProximityRadius: 50000,
geofenceInitialTriggerEntry: true,
preventSuspend: true,
disableLocationAuthorizationAlert: true,
locationAuthorizationRequest: 'Always',
useSignificantChangesOnly: false,
geofenceModeHighAccuracy: false,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
});
Expected Behavior
App is not crashing after startMonitoringPolygone is called
Actual Behavior
App is crashing on some devices after startMonitoringPolygone is called
Steps to Reproduce
- Add some valid geofences to BackgroundGeolocation.addGeofences(geofences)
- Start monitore polygone
- App crash
Context
We have tried to investigate this issue on our end. We tried to add corrupted/invalid/empty/undefined/null... geofences in BackgroundGeolocation.addGeofences method, but we were not able to reproduce this error in debug build. Our geofences look like this:
{
identifier: `tour_${activeTourRouteInterface.id}`,
notifyOnEntry: true,
notifyOnExit: true,
notifyOnDwell: true,
vertices: [
[50.064842285635024, 14.411941808263784],
[50.06480937893958, 14.41194482235038],
[50.064721379239934, 14.411954828724795],
[50.064551304826175, 14.41198433993442],
],
extras: {
kind: TOUR_GEOFENCE,
id: activeTourRouteInterface.id,
},
}
Debug logs
Logs
PASTE_YOUR_LOGS_HERE
It seems that a Geofence has been removed from the database but the plugin still contains a reference to its identifier in a list of monitoredPolygons.
I will add a null check for this case.
Perfect, when can we expect that update with fix? We had to halt the release. Thank you!
v4.17.2 is released.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.