react-native-background-geolocation: Deleted geofence is triggering events

Your Environment

  • Plugin version: 4.10.0
  • Platform: Android
  • OS version: 13
  • Device manufacturer / model: Samsung Galaxy A13 5G
  • React Native version (react-native -v): 0.71.8
  • Plugin config
╔═════════════════════════════════════════════
║ TSLocationManager version: 3.3.1 (418)
╠═════════════════════════════════════════════
╟─ samsung SM-A136W @ 13 (react-native)
{
  "activityRecognitionInterval": 10000,
  "allowIdenticalLocations": false,
  "authorization": {},
  "autoSync": true,
  "autoSyncThreshold": 0,
  "backgroundPermissionRationale": {
    "title": "Redacted",
    "message": "Redacted",
    "positiveAction": "Redacted",
    "negativeAction": "Redacted"
  },
  "batchSync": false,
  "configUrl": "",
  "debug": false,
  "deferTime": 0,
  "desiredAccuracy": 10,
  "desiredOdometerAccuracy": 100,
  "disableAutoSyncOnCellular": false,
  "disableElasticity": false,
  "disableLocationAuthorizationAlert": false,
  "disableMotionActivityUpdates": true,
  "disableProviderChangeRecord": false,
  "disableStopDetection": false,
  "distanceFilter": 10,
  "elasticityMultiplier": 1,
  "enableHeadless": true,
  "enableTimestampMeta": false,
  "extras": {},
  "fastestLocationUpdateInterval": -1,
  "foregroundService": true,
  "geofenceInitialTriggerEntry": false,
  "geofenceModeHighAccuracy": true,
  "geofenceProximityRadius": 20000,
  "geofenceTemplate": "",
  "headers": {},
  "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask",
  "heartbeatInterval": -1,
  "httpRootProperty": "location",
  "httpTimeout": 60000,
  "isMoving": false,
  "locationAuthorizationRequest": "Always",
  "locationTemplate": "",
  "locationTimeout": 60,
  "locationUpdateInterval": 1000,
  "locationsOrderDirection": "ASC",
  "logLevel": 5,
  "logMaxDays": 3,
  "maxBatchSize": -1,
  "maxDaysToPersist": 1,
  "maxRecordsToPersist": -1,
  "method": "POST",
  "minimumActivityRecognitionConfidence": 75,
  "motionTriggerDelay": 0,
  "notification": {
    "layout": "",
    "title": "Redacted",
    "text": "Redacted",
    "color": "",
    "channelName": "Redacted",
    "channelId": "",
    "smallIcon": "",
    "largeIcon": "",
    "priority": 0,
    "sticky": false,
    "strings": {},
    "actions": []
  },
  "params": {},
  "persist": true,
  "persistMode": 2,
  "schedule": [],
  "scheduleUseAlarmManager": false,
  "speedJumpFilter": 300,
  "startOnBoot": false,
  "stationaryRadius": 25,
  "stopAfterElapsedMinutes": 0,
  "stopOnStationary": false,
  "stopOnTerminate": false,
  "stopTimeout": 5,
  "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
  "url": "",
  "useSignificantChangesOnly": false,
  "enabled": true,
  "schedulerEnabled": false,
  "trackingMode": 0,
  "odometer": 0,
  "isFirstBoot": false,
  "didLaunchInBackground": false,
  "didDeviceReboot": false
}

Expected Behavior

When geofence “A” is removed and a new one “B” with a similar location but different ID is created, entering the location should trigger an event on geofence “B”, not “A”.

Actual Behavior

When geofence “A” is removed and a new one “B” with a similar location but different ID is created, entering the location sometimes triggers an event on geofence “A”. This event fails with the log message ERROR [GeofencingService handleGeofencingEvent] Failed to find geofence record in database:. No event is triggered on geofence “B”.

In the logs shared below, geofence “A” has an id ending in NQ== and geofence “B” has one ending in in NA==

I’ve noticed the following pattern in the logs that appears relevant:

08-04 15:12:41.467 INFO [GeofenceDAO destroy]
  ✅  MTE3MTA2MzIxNQ==
// ... a few lines later ...
08-04 15:12:41.479 DEBUG [TSGeofenceManager d] ℹ️  Persist monitored geofences: [MTE3MTA2MzIxNQ==]

Steps to Reproduce

  1. Create a geofence some distance away (e.g. 300 - 500m)
  2. Remove the geofence, and replace it with a new one having a similar location (< 100m away from the first)
  3. Enter the geofence

Context

In our product, when geofences overlap, we want to prompt the user as to which action to take rather than taking action automatically. This requires us to 1) track which fences overlap, and 2) replace overlapping pairs/groups of geofences with single geofences, using metadata to track which fences have been “combined” in this way.

Debug logs

Logs
08-04 15:12:15.695 INFO [TSLog log]
  🔵  Refetch todays visits because schedule changed
08-04 15:12:15.702 INFO [TSLog log]
  🔵  Fetch today's visits
08-04 15:12:16.567 INFO [TSLog log]
  🔵  ["Monitoring 2 geofences [MTE3MTA2MzIxNQ== multipleVisits: [] overlappingGeofences:[\"MTE2Mzg1ODQ2MA==\"] ,MTE2Mzg1ODQ2MA== multipleVisits: [] overlappingGeofences:[\"MTE3MTA2MzIxNQ==\"] ]"]
08-04 15:12:16.568 INFO [TSLog log]
  🔵  ["Monitoring 2 geofences [MTE3MTA2MzIxNQ== multipleVisits: [] overlappingGeofences:[\"MTE2Mzg1ODQ2MA==\"] ,MTE2Mzg1ODQ2MA== multipleVisits: [] overlappingGeofences:[\"MTE3MTA2MzIxNQ==\"] ]"]
08-04 15:12:39.797 INFO [TSLog log]
  🔵  Refetch todays visits because schedule changed
08-04 15:12:39.803 INFO [TSLog log]
  🔵  Fetch today's visits
08-04 15:12:41.461 INFO [TSLog log]
  🔵  ["Monitoring 2 geofences [MTE3MTA2MzIxNQ== multipleVisits: [] overlappingGeofences:[\"MTE2Mzg1ODQ2MA==\"] ,MTE2Mzg1ODQ2MA== multipleVisits: [] overlappingGeofences:[\"MTE3MTA2MzIxNQ==\"] ]"]
08-04 15:12:41.462 INFO [TSLog log]
  🔵  ["Remove geofence: MTE3MTA2MzIxNQ=="]
08-04 15:12:41.464 INFO [TSLog log]
  🔵  ["Remove geofence: MTE2Mzg1ODQ2MA=="]
08-04 15:12:41.464 INFO [TSLog log]
  🔵  ["Add geofences: MTE2Mzg1ODQ2MA=="]
08-04 15:12:41.467 INFO [GeofenceDAO destroy]
  ✅  MTE3MTA2MzIxNQ==
08-04 15:12:41.471 INFO [GeofenceDAO destroy]
  ✅  MTE2Mzg1ODQ2MA==
08-04 15:12:41.477 INFO [GeofenceDAO create]
  ✅  MTE2Mzg1ODQ2MA==
08-04 15:12:41.479 DEBUG [TSGeofenceManager d] ℹ️  Persist monitored geofences: [MTE3MTA2MzIxNQ==]
08-04 15:12:41.732 DEBUG [TSGeofenceManager$e run] evaluation buffer timer elapsed
08-04 15:12:41.840 INFO [TSLog log]
  🔵  Removed geofences: ["MTE3MTA2MzIxNQ=="]
08-04 15:12:41.857 INFO [TSLog log]
  🔵  Removed geofences: ["MTE2Mzg1ODQ2MA=="]
08-04 15:12:41.873 INFO [TSLog log]
  🔵  Added geofences: ["MTE2Mzg1ODQ2MA=="]
08-04 15:12:41.874 INFO [TSLog log]
  🔵  ["Monitoring 1 geofences [MTE2Mzg1ODQ2MA== multipleVisits: [] overlappingGeofences:[] ]"]
08-04 15:13:34.800 INFO [TSScheduleManager oneShot]
  ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
08-04 15:13:35.497 DEBUG [LifecycleManager onPause] ☯️  onPause
08-04 15:13:35.503 DEBUG [LifecycleManager onStop] ☯️  onStop
08-04 15:13:40.087 DEBUG [LifecycleManager onStart] ☯️  onStart
08-04 15:13:40.097 DEBUG [LifecycleManager onResume] ☯️  onResume
08-04 15:13:40.103 INFO [TSLog log]
  🔵  Refetch todays visits because schedule changed
08-04 15:13:40.103 INFO [TSLog log]
  🔵  Fetch today's visits
08-04 15:13:40.850 INFO [TSLog log]
  🔵  ["Monitoring 1 geofences [MTE2Mzg1ODQ2MA== multipleVisits: [] overlappingGeofences:[] ]"]
08-04 15:13:40.850 INFO [TSLog log]
  🔵  ["Remove geofence: MTE2Mzg1ODQ2MA=="]
08-04 15:13:40.851 INFO [TSLog log]
  🔵  ["Add geofences: MTE3MTE5OTE5NA=="]
08-04 15:13:40.852 INFO [GeofenceDAO destroy]
  ✅  MTE2Mzg1ODQ2MA==
08-04 15:13:40.855 INFO [GeofenceDAO create]
  ✅  MTE3MTE5OTE5NA==
08-04 15:13:40.857 DEBUG [TSGeofenceManager d] ℹ️  Persist monitored geofences: [MTE3MTA2MzIxNQ==]
08-04 15:13:40.878 INFO [TSLog log]
  🔵  Removed geofences: ["MTE2Mzg1ODQ2MA=="]
08-04 15:13:40.891 INFO [TSLog log]
  🔵  Added geofences: ["MTE3MTE5OTE5NA=="]
08-04 15:13:40.891 INFO [TSLog log]
  🔵  ["Monitoring 1 geofences [MTE3MTE5OTE5NA== multipleVisits: [\"MTE2Mzg1ODQ2MA==\"] overlappingGeofences:[] ]"]
08-04 15:13:41.082 INFO [TSScheduleManager oneShot]
  ⏰ Oneshot TERMINATE_EVENT is already pending
08-04 15:13:41.113 DEBUG [TSGeofenceManager$e run] evaluation buffer timer elapsed
08-04 15:13:41.268 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:13:41.270 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 897ms, time: 1691183620373

08-04 15:13:41.271 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:13:41.780 DEBUG [LifecycleManager onPause] ☯️  onPause
08-04 15:13:41.782 DEBUG [LifecycleManager onStop] ☯️  onStop
08-04 15:13:44.821 INFO [ScheduleEvent onOneShot]
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: TERMINATE_EVENT
╠═════════════════════════════════════════════

08-04 15:13:44.822 DEBUG [TerminateEvent$a a]
  ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
08-04 15:13:46.350 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:13:46.352 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 968ms, time: 1691183625384

08-04 15:13:46.353 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:13:51.441 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:13:51.443 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 938ms, time: 1691183630505

08-04 15:13:51.445 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:13:56.613 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:13:56.616 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 993ms, time: 1691183635621

08-04 15:13:56.617 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:01.606 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:01.608 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 827ms, time: 1691183640780

08-04 15:14:01.609 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:06.716 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:06.719 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1092ms, time: 1691183645626

08-04 15:14:06.721 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:11.730 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:11.732 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1062ms, time: 1691183650668

08-04 15:14:11.732 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:16.705 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:16.707 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1030ms, time: 1691183655676

08-04 15:14:16.707 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:21.615 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:21.617 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 916ms, time: 1691183660701

08-04 15:14:21.618 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:28.567 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:28.569 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 963ms, time: 1691183667605

08-04 15:14:28.570 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:33.585 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:33.589 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 962ms, time: 1691183672627

08-04 15:14:33.590 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:39.558 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:39.560 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 936ms, time: 1691183678623

08-04 15:14:39.561 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:44.615 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:44.617 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 971ms, time: 1691183683645

08-04 15:14:44.617 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:49.721 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:49.724 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1070ms, time: 1691183688652

08-04 15:14:49.725 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:55.699 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:55.701 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1038ms, time: 1691183694661

08-04 15:14:55.702 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:14:55.706 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:14:55.708 INFO [GeofencingService handleGeofencingEvent]
╔═════════════════════════════════════════════
║ Geofencing Event: ENTER
╠═════════════════════════════════════════════
╟─ MTE3MTA2MzIxNQ==
╚═════════════════════════════════════════════
08-04 15:14:55.715 ERROR [GeofencingService handleGeofencingEvent] Failed to find geofence record in database: MTE3MTA2MzIxNQ==
08-04 15:14:55.716 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:00.710 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:00.712 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1015ms, time: 1691183699696

08-04 15:15:00.713 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:00.777 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:00.780 INFO [GeofencingService handleGeofencingEvent]
╔═════════════════════════════════════════════
║ Geofencing Event: DWELL
╠═════════════════════════════════════════════
╟─ MTE3MTA2MzIxNQ==
╚═════════════════════════════════════════════
08-04 15:15:00.788 ERROR [GeofencingService handleGeofencingEvent] Failed to find geofence record in database: MTE3MTA2MzIxNQ==
08-04 15:15:00.789 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:05.763 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:05.765 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 899ms, time: 1691183704866

08-04 15:15:05.766 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:10.793 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:10.796 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 1015ms, time: 1691183709779

08-04 15:15:10.798 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:21.655 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:21.659 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 804ms, time: 1691183720854

08-04 15:15:21.660 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:27.646 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:27.649 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 941ms, time: 1691183726707

08-04 15:15:27.650 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:32.538 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:32.539 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 889ms, time: 1691183731651

08-04 15:15:32.540 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:42.519 DEBUG [AbstractService start]
  🎾  GeofencingService [eventCount: 1]
08-04 15:15:42.520 INFO [GeofencingService handleLocationResult]
╔═════════════════════════════════════════════
║ GeofencingService: Proximity evaluator
╠═════════════════════════════════════════════
╟─ 📍  Location[fused REDACTED], age: 501ms, time: 1691183742019

08-04 15:15:42.521 DEBUG [AbstractService finish] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: true]
08-04 15:15:42.607 DEBUG [LifecycleManager onStart] ☯️  onStart
08-04 15:15:42.618 DEBUG [LifecycleManager onResume] ☯️  onResume

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I’m putting the finishing touches on a release of this branch very soon.

iMyFone AnyTo

I do not like this app. I use Lockito.