react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

App is crashing - NullPointerException com.transistorsoft.locationmanager.geofence.TSGeofenceManager in startMonitoringPolygone

Open jakub-oone opened this issue 1 year ago • 3 comments

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

  1. Add some valid geofences to BackgroundGeolocation.addGeofences(geofences)
  2. Start monitore polygone
  3. 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

jakub-oone avatar Sep 30 '24 15:09 jakub-oone

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.

christocracy avatar Sep 30 '24 16:09 christocracy

Perfect, when can we expect that update with fix? We had to halt the release. Thank you!

jakub-oone avatar Oct 01 '24 08:10 jakub-oone

v4.17.2 is released.

christocracy avatar Oct 01 '24 17:10 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 01 '24 02:11 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Nov 16 '24 02:11 github-actions[bot]