transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
660 stars 276 forks source link

No GeoFence event on startup #925

Closed brucejo75 closed 5 years ago

brucejo75 commented 5 years ago

I am not getting a geoFence event, I am expecting one on startup because I set geofenceInitialTriggerEntry: true

Your Environment

Plugin config:

``` debug: true desiredAccuracy: 10 distanceFilter: 40 geofenceInitialTriggerEntry: true geofenceModeHighAccuracy: true headers: X-Account-Id: "M9M1iuf0pizT-XMqT" X-Auth-Token: "FYzUppeONCmuS9N1nbSo4ztYT7XPf9nsCQpEcGTZpEk" X-Device-Id: "2a96f3b6e56447c1" X-Device-Name: "Galaxy Tab A (2017)" X-Device-Token: "rL454v8M3hqL6tMFf" X-User-Id: "M9M1jcf0pizT-XNJU" logLevel: 5 reset: true startOnBoot: true stopOnTerminate: false url: "https://admin.test.meris.xyz/api/location" ```

Plugin status returned from .start():

``` debug: true activityRecognitionInterval: 10000 allowIdenticalLocations: false autoSync: true autoSyncThreshold: 0 batchSync: false debug: true deferTime: 0 desiredAccuracy: 10 desiredOdometerAccuracy: 100 disableElasticity: false disableStopDetection: false distanceFilter: 40 elasticityMultiplier: 1 enableHeadless: false enableTimestampMeta: false enabled: true extras: {} fastestLocationUpdateInterval: -1 forceReloadOnBoot: false forceReloadOnGeofence: false forceReloadOnHeartbeat: false forceReloadOnLocationChange: false forceReloadOnMotionChange: false forceReloadOnSchedule: false foregroundService: true geofenceInitialTriggerEntry: true geofenceModeHighAccuracy: true geofenceProximityRadius: 1000 geofenceTemplate: "" headers: {X-Auth-Token: "FYzUppeONCmuS9N1nbSo4ztYT7XPf9nsCQpEcGTZpEk", X-User-Id: "M9M1jcf0pizT-XNJU", X-Account-Id: "M9M1iuf0pizT-XMqT", X-Device-Id: "2a96f3b6e56447c1", X-Device-Name: "Galaxy Tab A (2017)", …} headlessJobService: "com.transistorsoft.cordova.bggeo.BackgroundGeolocationHeadlessTask" heartbeatInterval: -1 httpRootProperty: "location" httpTimeout: 60000 isFirstBoot: false isMoving: false locationTemplate: "" locationTimeout: 60 locationUpdateInterval: 1000 locationsOrderDirection: "ASC" logLevel: 5 logMaxDays: 3 maxBatchSize: -1 maxDaysToPersist: 1 maxRecordsToPersist: -1 method: "POST" minimumActivityRecognitionConfidence: 75 notificationColor: "" notificationLargeIcon: "" notificationPriority: 0 notificationSmallIcon: "" notificationText: "Location Service activated" notificationTitle: "" odometer: 0 params: {} persist: true persistMode: 2 schedule: [] schedulerEnabled: false speedJumpFilter: 300 startOnBoot: true stationaryRadius: 25 stopAfterElapsedMinutes: 0 stopOnStationary: false stopOnTerminate: false stopTimeout: 5 trackingMode: 1 triggerActivities: "in_vehicle, on_bicycle, on_foot, running, walking" url: "https://admin.test.meris.xyz/api/location" useSignificantChangesOnly: false ```

Expected Behavior

Expected onGeofence to be called on startup because geofenceInitialTriggerEntry: true

Actual Behavior

onGeofence not called but onLocation is firing fine.

Steps to Reproduce

run startup code:

```javascript BackgroundGeolocation.onLocation((location) => gpsLog.info({'obj': location}, 'gps: location Firing')); BackgroundGeolocation.onGeofence((geofence) => gpsLog.info({'obj': geofence}, 'gps: geofence Firing')); BackgroundGeolocation.onGeofencesChange((changeEvent) => gpsLog.info({'obj': { 'on': changeEvent.on, 'off': changeEvent.off }}, 'gps: geofenceChange Firing')); // BackgroundGeolocation.configure(settings.configure); await BackgroundGeolocation.stop(); await BackgroundGeolocation.setConfig(settings.configure); let status = await BackgroundGeolocation.start(); ```

Context

Verify onGeofence events are fired.

Debug logs

output from adb logcat -s TSLocationManagert:

```console 05-04 08:59:12.594 19215 19293 D TSLocationManager: $ addLocationListener() 05-04 08:59:12.599 19215 19293 D TSLocationManager: $ addGeofenceListener() 05-04 08:59:12.601 19215 19293 D TSLocationManager: $ addGeofencesChangeListener() 05-04 08:59:12.616 19215 19293 D TSLocationManager: [c.t.l.g.TSGeofenceManager a] 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:12.616 19215 19293 D TSLocationManager: ║ TSGeofenceManager found 3/4 within 1000 meters 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU8R 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU7R 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU9R 05-04 08:59:12.616 19215 19293 D TSLocationManager: ╚═════════════════════════════════════════════ 05-04 08:59:12.686 19215 19293 D TSLocationManager: $ stop() 05-04 08:59:12.710 19215 19293 D TSLocationManager: [c.t.l.g.TSGeofenceManager b] 05-04 08:59:12.710 19215 19293 D TSLocationManager: 🔴 Stop monitoring geofences 05-04 08:59:12.729 19215 19215 D TSLocationManager: [c.t.l.service.TrackingService onDestroy] 05-04 08:59:12.729 19215 19215 D TSLocationManager: 🔴 TrackingService destroyed 05-04 08:59:12.735 19215 19293 I TSLocationManager: [c.t.l.g.TSGeofenceManager stopMonitoringSignificantLocationChanges] 05-04 08:59:12.735 19215 19293 I TSLocationManager: 🔴 Stop monitoring significant location changes 05-04 08:59:12.753 19215 19293 D TSLocationManager: [c.t.l.g.TSGeofenceManager stopMonitoringStationaryRegion] 05-04 08:59:12.753 19215 19293 D TSLocationManager: 🔴 Stop monitoring stationary region 05-04 08:59:12.763 19215 19293 I TSLocationManager: [c.t.l.s.ActivityRecognitionService b] 05-04 08:59:12.763 19215 19293 I TSLocationManager: 🔴 Stop motion-activity updates 05-04 08:59:12.781 19215 19293 I TSLocationManager: [c.t.l.service.HeartbeatService a] 05-04 08:59:12.781 19215 19293 I TSLocationManager: 🔴 Stop heartbeat 05-04 08:59:12.792 19215 19215 D TSLocationManager: [c.t.l.s.ActivityRecognitionService onDestroy] 05-04 08:59:12.792 19215 19215 D TSLocationManager: 🔴 ActivityRecognitionService destroyed 05-04 08:59:12.795 19215 19293 D TSLocationManager: [c.t.l.http.HttpService stopMonitoringConnectivityChanges] 05-04 08:59:12.795 19215 19293 D TSLocationManager: 🔴 Stop monitoring connectivity changes 05-04 08:59:12.813 19215 19293 D TSLocationManager: [c.t.locationmanager.device.a d] 05-04 08:59:12.813 19215 19293 D TSLocationManager: 🔴 Stop monitoring powersave changes 05-04 08:59:12.874 19215 19293 D TSLocationManager: $ setConfig() 05-04 08:59:12.883 19215 19293 D TSLocationManager: [c.t.l.adapter.TSConfig c] ℹ️ Persist config 05-04 08:59:12.909 19215 32094 I TSLocationManager: [c.t.l.http.HttpService flush] 05-04 08:59:12.909 19215 32094 I TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:12.909 19215 32094 I TSLocationManager: ║ HTTP Service (count: 13) 05-04 08:59:12.909 19215 32094 I TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:12.914 19215 19293 D TSLocationManager: $ start() 05-04 08:59:12.918 19215 19293 D TSLocationManager: [c.t.locationmanager.util.b a] 05-04 08:59:12.918 19215 19293 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted 05-04 08:59:12.944 19215 19215 I TSLocationManager: [c.t.l.u.BackgroundTaskManager onStartJob] ⏳ startBackgroundTask: 9 05-04 08:59:12.960 19215 32097 I TSLocationManager: - Enable: false → true, trackingMode: 1 05-04 08:59:12.974 19215 19215 D TSLocationManager: [c.t.locationmanager.data.a.c first] 05-04 08:59:12.974 19215 19215 D TSLocationManager: ✅ Locked 1 records 05-04 08:59:12.978 19215 32097 I TSLocationManager: [c.t.l.g.TSGeofenceManager stopMonitoringSignificantLocationChanges] 05-04 08:59:12.978 19215 32097 I TSLocationManager: 🔴 Stop monitoring significant location changes 05-04 08:59:12.991 19215 19215 I TSLocationManager: [c.t.l.http.HttpService a] 05-04 08:59:12.991 19215 19215 I TSLocationManager: 🔵 HTTP POST: 8089ab6a-2ce2-4695-a05f-46c207b92445 05-04 08:59:13.000 19215 32097 I TSLocationManager: [c.t.l.service.HeartbeatService a] 05-04 08:59:13.000 19215 32097 I TSLocationManager: 🔴 Stop heartbeat 05-04 08:59:13.031 19215 32097 I TSLocationManager: [c.t.l.service.TrackingService a] 05-04 08:59:13.031 19215 32097 I TSLocationManager: 🔵 setPace: false → false 05-04 08:59:13.044 19215 32097 D TSLocationManager: [c.t.locationmanager.util.b a] 05-04 08:59:13.044 19215 32097 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted 05-04 08:59:13.064 19215 32097 I TSLocationManager: [c.t.l.s.ActivityRecognitionService a] 05-04 08:59:13.064 19215 32097 I TSLocationManager: 🎾 Start motion-activity updates 05-04 08:59:13.096 19215 32097 I TSLocationManager: [c.t.l.g.TSGeofenceManager start] 05-04 08:59:13.096 19215 32097 I TSLocationManager: 🎾 Start monitoring geofences 05-04 08:59:13.111 19215 32097 D TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges] 05-04 08:59:13.111 19215 32097 D TSLocationManager: 🎾 Start monitoring connectivity changes 05-04 08:59:13.138 19215 19316 D TSLocationManager: [c.t.l.http.HttpService a] 05-04 08:59:13.138 19215 19316 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:13.138 19215 19316 D TSLocationManager: ║ 📶 Connectivity change: connected? true 05-04 08:59:13.138 19215 19316 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:13.142 19215 32097 D TSLocationManager: [c.t.locationmanager.device.a c] 05-04 08:59:13.142 19215 32097 D TSLocationManager: 🎾 Start monitoring powersave changes 05-04 08:59:13.162 19215 19316 I TSLocationManager: [c.t.l.http.HttpService flush] 05-04 08:59:13.162 19215 19316 I TSLocationManager: ℹ️ HttpService is busy 05-04 08:59:13.874 19215 19215 D TSLocationManager: [c.t.l.s.ActivityRecognitionService a] 05-04 08:59:13.874 19215 19215 D TSLocationManager: 🚘 ️DetectedActivity [type=STILL, confidence=100] 05-04 08:59:13.907 19215 19215 D TSLocationManager: [c.t.l.s.ActivityRecognitionService onDestroy] 05-04 08:59:13.907 19215 19215 D TSLocationManager: 🔴 ActivityRecognitionService destroyed 05-04 08:59:15.741 19215 19293 D TSLocationManager: $ getGeofences() 05-04 08:59:15.791 19215 19293 D TSLocationManager: $ removeGeofence() 05-04 08:59:15.802 19215 19293 D TSLocationManager: $ removeGeofence() 05-04 08:59:15.820 19215 32122 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.820 19215 32122 I TSLocationManager: ✅ M9nrq9qgUGrq0hU7R 05-04 08:59:15.841 19215 32123 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.841 19215 32123 I TSLocationManager: ✅ M9nrq9qgUGrq0hU8R 05-04 08:59:15.861 19215 32124 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.861 19215 32124 I TSLocationManager: ✅ M9nrq9qgUGrq0hU9R 05-04 08:59:15.881 19215 32122 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.881 19215 32122 I TSLocationManager: ✅ M9nrq9qgUGrq0hUAR 05-04 08:59:15.908 19215 19293 D TSLocationManager: $ addGeofences() 05-04 08:59:15.922 19215 32123 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.922 19215 32123 I TSLocationManager: ✅ M9nrq9qgUGrq0hU7R 05-04 08:59:15.952 19215 32123 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.952 19215 32123 I TSLocationManager: ✅ M9nrq9qgUGrq0hU8R 05-04 08:59:15.973 19215 32123 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.973 19215 32123 I TSLocationManager: ✅ M9nrq9qgUGrq0hU9R 05-04 08:59:15.984 19215 32123 I TSLocationManager: [c.t.locationmanager.data.a.a a] 05-04 08:59:15.984 19215 32123 I TSLocationManager: ✅ M9nrq9qgUGrq0hUAR 05-04 08:59:16.155 19215 19215 D TSLocationManager: [c.t.l.service.TrackingService b] 05-04 08:59:16.155 19215 19215 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:16.155 19215 19215 D TSLocationManager: ║ TrackingService: MotionChangeRequest #9 05-04 08:59:16.155 19215 19215 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:16.155 19215 19215 D TSLocationManager: ╟─ 📍 Location[fused 47.735829,-122.118587 hAcc=50 et=+9d18h56m8s807ms vAcc=??? sAcc=??? bAcc=???], age: 78ms, time: 1556985556073 05-04 08:59:16.197 19215 19215 D TSLocationManager: [c.t.l.g.TSGeofenceManager a] 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:16.197 19215 19215 D TSLocationManager: ║ TSGeofenceManager found 3/4 within 1000 meters 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU8R 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU7R 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU9R 05-04 08:59:16.197 19215 19215 D TSLocationManager: ╚═════════════════════════════════════════════ 05-04 08:59:16.324 19215 19215 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 41.598 05-04 08:59:16.362 19215 19215 D TSLocationManager: [c.t.l.g.TSGeofenceManager$b run] evaluation buffer timer elapsed 05-04 08:59:16.385 19215 32097 D TSLocationManager: [c.t.l.g.TSGeofenceManager a] 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:16.385 19215 32097 D TSLocationManager: ║ TSGeofenceManager found 3/4 within 1000 meters 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU8R 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU7R 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╟─ 🎾 M9nrq9qgUGrq0hU9R 05-04 08:59:16.385 19215 32097 D TSLocationManager: ╚═════════════════════════════════════════════ 05-04 08:59:18.449 19215 19215 D TSLocationManager: [c.t.l.service.TrackingService b] 05-04 08:59:18.449 19215 19215 D TSLocationManager: ╔═════════════════════════════════════════════ 05-04 08:59:18.449 19215 19215 D TSLocationManager: ║ TrackingService: MotionChangeRequest #9 05-04 08:59:18.449 19215 19215 D TSLocationManager: ╠═════════════════════════════════════════════ 05-04 08:59:18.449 19215 19215 D TSLocationManager: ╟─ 📍 Location[fused 47.735865,-122.118572 hAcc=15 et=+9d18h56m11s151ms alt=161.4921875 vel=0.29 bear=106.0 vAcc=32 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}], age: 25ms, time: 1556985558052 05-04 08:59:18.468 19215 19215 D TSLocationManager: [c.t.l.g.TSGeofenceManager setLocation] *** isMoving: false | stateChanged: false | timerExpired: false | elapsed: 1979 05-04 08:59:18.480 19215 19215 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 05-04 08:59:18.480 19215 19215 I TSLocationManager: 🔵 Acquired motionchange position, isMoving: false 05-04 08:59:18.492 19215 19215 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 41.598 05-04 08:59:18.568 19215 32097 I TSLocationManager: [c.t.locationmanager.data.a.c persist] 05-04 08:59:18.568 19215 32097 I TSLocationManager: ✅ INSERT: d96cd7ab-cc0f-4395-9244-bd31dbc1e0e7 05-04 08:59:18.585 19215 32097 I TSLocationManager: [c.t.l.http.HttpService flush] 05-04 08:59:18.585 19215 32097 I TSLocationManager: ℹ️ HttpService is busy 05-04 08:59:18.590 19215 19215 D TSLocationManager: [c.t.l.g.TSGeofenceManager setLocation] *** isMoving: false | stateChanged: false | timerExpired: false | elapsed: 1979 05-04 08:59:18.609 19215 19215 D TSLocationManager: [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion] 05-04 08:59:18.609 19215 19215 D TSLocationManager: 🎾 Start monitoring stationary region (radius: 150.0 meters) 05-04 08:59:18.637 19215 19215 I TSLocationManager: [c.t.l.s.ActivityRecognitionService a] 05-04 08:59:18.637 19215 19215 I TSLocationManager: 🎾 Start motion-activity updates 05-04 08:59:18.667 19215 19215 D TSLocationManager: [c.t.l.service.TrackingService onDestroy] 05-04 08:59:18.667 19215 19215 D TSLocationManager: 🔴 TrackingService destroyed 05-04 08:59:19.282 19215 19215 D TSLocationManager: [c.t.l.s.ActivityRecognitionService a] 05-04 08:59:19.282 19215 19215 D TSLocationManager: 🚘 ️DetectedActivity [type=STILL, confidence=100] 05-04 08:59:19.321 19215 19215 D TSLocationManager: [c.t.l.s.ActivityRecognitionService onDestroy] 05-04 08:59:19.321 19215 19215 D TSLocationManager: 🔴 ActivityRecognitionService destroyed 05-04 08:59:23.247 19215 32102 W TSLocationManager: [c.t.l.http.HttpService$b onFailure] 05-04 08:59:23.247 19215 32102 W TSLocationManager: ⚠️ Response: 0, timeout 05-04 08:59:23.270 19215 32102 D TSLocationManager: [c.t.locationmanager.data.a.c unlock] 05-04 08:59:23.270 19215 32102 D TSLocationManager: ✅ UNLOCKED: 8089ab6a-2ce2-4695-a05f-46c207b92445 05-04 08:59:23.283 19215 32102 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 9 05-04 08:59:23.296 19215 19215 D TSLocationManager: [c.t.l.s.BackgroundTaskService onDestroy] ```
christocracy commented 5 years ago

Have you been messing around with a mock location app? Restart your device.

brucejo75 commented 5 years ago

D'oh: restart brought it back. I have been debugging on the device for at least 2-3 weeks without any restarts. I assume I got it into some sort of weird wedged state?

I had been uninstalling / reinstalling the app thinking it would clear weird state out. Can you tell me what extra things a device restart resolves?

Thanks! Been pounding on this for a day.

christocracy commented 5 years ago

I don't know. The geofencing service gets confused sometimes. Moving out of then back into the geofence would work too.

brucejo75 commented 5 years ago

Thanks again!