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
655 stars 277 forks source link

Android stops backgroundtracking after a while #717

Closed GinJus closed 4 years ago

GinJus commented 5 years ago

On the most IOS en Android phones the app continues tracking on the background. Now I get reactions of users that after a while (after closing the app) it stops tracking coordinates. When you open the app and close it again it will track for a while but keeps going to sleep (app still runs on the background but does nothing)

Your Environment

Expected Behavior

The app has to keep running on the background at all times, sending location data to the server.

Actual Behavior

On several Android phones (all kind of brands) the application stops tracking in the background. It doesn't send data after a while. Not even after a few days with all kinds of moving and tracking. After opening the app or rebooting the phone it works for a while and then the same problem appears.

Steps to Reproduce

  1. Open the app on android or reboot the phone
  2. Close the app and let it run on the background
  3. After a while (days or hours) it stops tracking
  4. Go to step 1

Context

I can reproduce the failure on a Samsung Galaxy S5 with Android 6.0.1. Mostly I receive messages of users and only can see that it stops sending data to the server. The app appears in the Android services list but doesn't do anything.

Debug logs

No logs available

efhilton commented 5 years ago

I'm experiencing something similar where I got no messages in my server even though everything was working the first day on Android 8. Though, and possibly related, after several days, and with me not doing anything to the phone (other than restarting it) or the code, i got a dump into the server, all at the same time, of several days worth of geofence events.

christocracy commented 5 years ago

@efhilton provide your Environment / Config information as above.

Logs too

efhilton commented 5 years ago

I'm no longer convinced it's the exact thing though it may be related. There are SOME geofences that are not responding, hence my confusion. It works fine for say fences around my office, around town. But my personal home and local airport do not trigger. So when I did all my work, most of it was at my office. But days later when I took it home or to the airport, I get absolutely nothing. Otherwise, my office, favorite restaurants, etc. seem to continue to trigger perfectly.

I've recently uninstalled the app, set reset to true, deleted all geofences, and added them again. Home and airport continue to not work, which I find extremely odd.

         Environment is device
         cordova:"6.3.0"
         framework:"Cordova"
         isVirtual:false
         manufacturer:"Google"
         model:"Pixel 2"
         platform:"Android"
         version:"8.1.0"

My configuration is as follows:

            // GEO-LOCATION OPTIONS
            reset: true,  // reset configs every time we start up app.
            debug: true,   // debug mode

            // ACTIVITY RECOGNITION OPTIONS
            activityRecognitionInterval: 10000,
            stopTimeout: 0,
            minimumActivityRecognitionConfidence: 75,

            // HTTP PERSISTENCE OPTIONS
            url: POST_URL,
            maxDaysToPersist: 14,  // #days to try to send to server until we give up
            maxRecordsToPersist: -1, // max records to hold in db.  -1 = unlimited
            enableHeadless: true,
            stopOnTerminate: false,
            autoSync: true,

            // APP OPTIONS
            startOnBoot: true,
            heartbeatInterval: 120,

            // GEOFENCING OPTIONS
            geofenceProximityRadius: 200,
christocracy commented 5 years ago

Post log

efhilton commented 5 years ago

Alright, I'll try to get something useful. However, there are no errors. I simply continue to get heartbeats while I'm at home. My server logs clearly show Enter, Dwell, Exit from my Office. Then nothing as I went home and to the airport. Then Enter, Dwell, Exit from grocery store, restaurant, skyzone, etc. But when I return home I get nothing. Just heartbeats. No errors. It's behaving exactly as if there is no geofence location, though it shows up in the list of fences. It's now been 4 days of this, repeatable.

GinJus commented 5 years ago

When I set de debug mode to "true" it keeps running. Is there something in that mode that keeps the background posting alive?

I have logfiles but there is nothing to see. When I disable the debug mode it sleeps or kills after a while.

The only thing I changed is the debug mode... How come?

christocracy commented 5 years ago

There’s no way debug: true has any effect upon behaviour. That is as superstitious as believing bad luck comes from walking beneath ladders.

GinJus commented 5 years ago

Last night it stopped again and didn't restart. Meanwhile i've updated the plugins and Android to geo 2.12.14 and Android 7.1.0.

The last data I received:

╔═════════════════════════════════════════════
║ DEVICE SENSORS
╠═════════════════════════════════════════════
╟─ ✅  ACCELEROMETER: {Sensor name="MPU6500 Acceleration Sensor", vendor="Invensense", version=1, type=1, maxRange=19.6133, resolution=5.985504E-4, power=0.25, minDelay=5000}
╟─ ✅  GYROSCOPE: {Sensor name="MPU6500 Gyroscope Sensor", vendor="Invensense", version=1, type=4, maxRange=34.906586, resolution=0.0010652645, power=6.1, minDelay=5000}
╟─ ✅  MAGNETOMETER: {Sensor name="YAS532 Magnetic Sensor", vendor="Yamaha Corporation", version=1, type=2, maxRange=1200.0, resolution=0.1, power=6.0, minDelay=10000}
╟─ ✅  SIGNIFICANT_MOTION: {Sensor name="SAMSUNG Significant Motion Sensor", vendor="Samsung Inc.", version=2, type=17, maxRange=1.0, resolution=1.0, power=0.3, minDelay=-1}
╚═════════════════════════════════════════════
06-26 23:33:26.823 INFO [BackgroundGeolocation <init>] 
  ✅  Google Play Services: connected (version code:11720000)
06-26 23:33:26.851 DEBUG [c a] 
  ✅  Opened database
06-26 23:33:26.867 DEBUG [c prune] 
  ℹ️  PRUNE -3 days
06-26 23:33:26.912 DEBUG [a f] 
  ✅  Opened database
06-26 23:33:26.955 DEBUG [LocationService onLocation] 
╔═════════════════════════════════════════════
║ LocationService: location
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 55,634530,5,056958 acc=17 et=+12h56m41s654ms alt=43.400001525878906 {Bundle[mParcelledData.dataSize=52]}], age: 814ms, time: 1530048806129

06-26 23:33:26.993 DEBUG [TSLocationManager onLocationResult] 
╔═════════════════════════════════════════════
║ Process LocationResult
╠═════════════════════════════════════════════

06-26 23:33:27.013 DEBUG [TSLocationManager a] 16.544
06-26 23:33:27.023 DEBUG [TSLocationManager a] 7025.3286
06-26 23:33:27.091 INFO [c persist] 
  ✅  INSERT: 92bf94ff-1873-447a-bc11-71ef62d33c2e
06-26 23:33:27.094 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:27.113 DEBUG [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service
╠═════════════════════════════════════════════

06-26 23:33:27.144 DEBUG [c first] 
  ✅  Locked 1 records
06-26 23:33:27.156 INFO [HttpService a] 
  🔵  HTTP POST: 539aa8b8-2601-4c98-85b1-88c4434a438c
06-26 23:33:27.364 INFO [HttpService$a onResponse] 
  🔵  Response: 200
06-26 23:33:27.412 DEBUG [c destroy] 
  ✅  DESTROY: 539aa8b8-2601-4c98-85b1-88c4434a438c
06-26 23:33:27.414 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:27.461 DEBUG [c first] 
  ✅  Locked 1 records
06-26 23:33:27.521 INFO [HttpService a] 
  🔵  HTTP POST: b0885c2c-0922-487f-bcf3-7109ee2fadff
06-26 23:33:27.625 INFO [HttpService$a onResponse] 
  🔵  Response: 200
06-26 23:33:27.674 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:27.674 DEBUG [c destroy] 
  ✅  DESTROY: b0885c2c-0922-487f-bcf3-7109ee2fadff
06-26 23:33:27.758 DEBUG [c first] 
  ✅  Locked 1 records
06-26 23:33:27.790 INFO [HttpService a] 
  🔵  HTTP POST: 92bf94ff-1873-447a-bc11-71ef62d33c2e
06-26 23:33:27.865 INFO [HttpService$a onResponse] 
  🔵  Response: 200
06-26 23:33:27.888 DEBUG [c destroy] 
  ✅  DESTROY: 92bf94ff-1873-447a-bc11-71ef62d33c2e
06-26 23:33:27.888 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:32.512 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:42.602 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:33:55.414 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:34:05.544 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:34:15.701 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:34:25.819 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:34:34.609 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:34:48.121 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:01.628 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:15.203 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:25.316 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:35.452 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:45.623 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:35:55.756 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:05.935 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:16.116 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:26.230 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:36.380 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:46.492 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:36:55.160 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:37:08.677 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:37:22.201 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:37:35.704 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:37:45.845 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:37:55.951 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:06.049 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:16.167 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:26.298 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:36.384 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:46.518 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:38:56.663 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:39:06.777 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:39:16.884 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:39:32.666 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:39:42.804 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:39:52.900 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:03.013 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:13.155 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:23.275 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:33.422 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:43.581 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:40:53.718 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:41:03.841 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:41:13.959 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:41:24.075 DEBUG [BackgroundGeolocation isMainActivityActive] NO
06-26 23:48:48.849 INFO [TSConfig print] 
╔═════════════════════════════════════════════
║ TSLocationManager version: 2.12.14 (270)
╠═════════════════════════════════════════════
{
  "activityRecognitionInterval": 10000,
  "allowIdenticalLocations": false,
  "autoSync": true,
  "autoSyncThreshold": 3,
  "batchSync": false,
  "debug": true,
  "deferTime": 0,
  "desiredAccuracy": 100,
  "desiredOdometerAccuracy": 100,
  "disableElasticity": false,
  "disableStopDetection": false,
  "distanceFilter": 20,
  "elasticityMultiplier": 1,
  "enableHeadless": false,
  "extras": {},
  "fastestLocationUpdateInterval": 10000,
  "forceReloadOnBoot": false,
  "forceReloadOnGeofence": false,
  "forceReloadOnHeartbeat": false,
  "forceReloadOnLocationChange": false,
  "forceReloadOnMotionChange": false,
  "forceReloadOnSchedule": false,
  "foregroundService": false,
  "geofenceInitialTriggerEntry": true,
  "geofenceProximityRadius": 1000,
  "geofenceTemplate": "",
  "headers": {},
  "headlessJobService": "com.transistorsoft.cordova.bggeo.HeadlessJobService",
  "heartbeatInterval": -1,
  "httpRootProperty": "location",
  "httpTimeout": 3000,
  "isMoving": true,
  "locationTemplate": "{\"lat\":<%= latitude %>, \"lng\":<%= longitude %>}",
  "locationTimeout": 60,
  "locationUpdateInterval": 30000,
  "locationsOrderDirection": "ASC",
  "logLevel": 5,
  "logMaxDays": 2,
  "maxBatchSize": -1,
  "maxDaysToPersist": 3,
  "maxRecordsToPersist": -1,
  "method": "POST",
  "minimumActivityRecognitionConfidence": 75,
  "notificationColor": "",
  "notificationLargeIcon": "",
  "notificationPriority": 0,
  "notificationSmallIcon": "",
  "notificationText": "Location Service activated",
  "notificationTitle": "",
  "params": {
    "data": {
      "uuid": "ebe18e151ac15ed4",
      "version": "2.1"
    }
  },
  "persist": true,
  "schedule": [],
  "startOnBoot": true,
  "stationaryRadius": 25,
  "stopAfterElapsedMinutes": 0,
  "stopOnStationary": false,
  "stopOnTerminate": false,
  "stopTimeout": 5,
  "triggerActivities": "on_foot, walking",
  "url": "http:\/\/api.domain.com\/checklocation\/",
  "enabled": true,
  "schedulerEnabled": false,
  "trackingMode": 1,
  "odometer": 7025.32861328125,
  "isFirstBoot": false
}
efhilton commented 5 years ago

Mine stopped working again yesterday morning. I have not touched the code in a few days. After I noticed that it's not working anymore, I plugged it into my computer to look at the logs. There are absolutely no useful bits of information that I can report. There are no errors, no warnings, no logs. It just silently fails. By the way, I'm now convinced that -- unlike one of my previous posts -- it is not a location issue, but definitely the module stops working after several days.

christocracy commented 5 years ago

I suggest you all install the SampleApp and run it in parallel to your own apps. The SampleApp will post results to my tracking server at http://tracker.transistorsoft.com/your-username

GinJus commented 5 years ago

I've done that, both applications stopped. The Sample App a few hours earlier than my own app. Do you see more data than I can see in the tracker logs? Use my username for the info. Thanks.

-edit- here my logs from my app:

╔═════════════════════════════════════════════
║ DEVICE SENSORS
╠═════════════════════════════════════════════
╟─ ✅  ACCELEROMETER: {Sensor name="MPU6500 Acceleration Sensor", vendor="Invensense", version=1, type=1, maxRange=19.6133, resolution=5.985504E-4, power=0.25, minDelay=5000}
╟─ ✅  GYROSCOPE: {Sensor name="MPU6500 Gyroscope Sensor", vendor="Invensense", version=1, type=4, maxRange=34.906586, resolution=0.0010652645, power=6.1, minDelay=5000}
╟─ ✅  MAGNETOMETER: {Sensor name="YAS532 Magnetic Sensor", vendor="Yamaha Corporation", version=1, type=2, maxRange=1200.0, resolution=0.1, power=6.0, minDelay=10000}
╟─ ✅  SIGNIFICANT_MOTION: {Sensor name="SAMSUNG Significant Motion Sensor", vendor="Samsung Inc.", version=2, type=17, maxRange=1.0, resolution=1.0, power=0.3, minDelay=-1}
╚═════════════════════════════════════════════
07-04 22:30:25.076 INFO [BackgroundGeolocation <init>] 
  ✅  Google Play Services: connected (version code:11720000)
07-04 22:30:25.540 DEBUG [c a] 
  ✅  Opened database
07-04 22:30:25.854 DEBUG [c prune] 
  ℹ️  PRUNE -3 days
07-04 22:30:26.386 DEBUG [a f] 
  ✅  Opened database
07-04 22:30:26.581 INFO [BackgroundGeolocationService onStartCommand] 
╔═════════════════════════════════════════════
║ BackgroundGeolocation Service started
╠═════════════════════════════════════════════

07-04 22:30:26.838 INFO [ActivityRecognitionService a] 
  🎾  Start activity updates: 10000
07-04 22:30:27.353 INFO [BackgroundGeolocationService a] 
  🔵  setPace: null → false
07-04 22:30:27.482 DEBUG [TSConfig c] ℹ️   Persist config
07-04 22:30:27.599 DEBUG [b a] 
  ℹ️  LocationAuthorization: Permission granted
07-04 22:30:27.847 DEBUG [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service
╠═════════════════════════════════════════════

07-04 22:30:32.173 DEBUG [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service
╠═════════════════════════════════════════════

07-04 22:30:35.180 DEBUG [SingleLocationRequest$2 onLocationResult] 
╔═════════════════════════════════════════════
║ SingleLocationRequest: 1
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 52,35655,5,46462 acc=17 et=+3d4h51m54s186ms alt=44.70000076293945 {Bundle[{requestId=1, verticalAccuracy=2.0}]}], age: 4277ms, time: 1530736230762

07-04 22:30:35.295 INFO [TSLocationManager onSingleLocationResult] 
  🔵  Acquired motionchange position, isMoving: false
07-04 22:30:36.354 DEBUG [TSLocationManager a] 16.778
07-04 22:30:36.398 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:36.800 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%)
07-04 22:30:36.858 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:36.939 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:37.050 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:37.262 INFO [c persist] 
  ✅  INSERT: 2a372fd5-e066-4fd0-a9e5-fd76ea8790f6
07-04 22:30:37.321 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:37.395 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%)
07-04 22:30:37.445 DEBUG [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service
╠═════════════════════════════════════════════

07-04 22:30:37.503 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:37.598 DEBUG [c first] 
  ✅  Locked 1 records
07-04 22:30:37.663 INFO [HttpService a] 
  🔵  HTTP POST: 2a372fd5-e066-4fd0-a9e5-fd76ea8790f6
07-04 22:30:38.225 INFO [HttpService$a onResponse] 
  🔵  Response: 200
07-04 22:30:38.515 DEBUG [BackgroundGeolocation isMainActivityActive] NO
07-04 22:30:38.531 DEBUG [c destroy] 
  ✅  DESTROY: 2a372fd5-e066-4fd0-a9e5-fd76ea8790f6
07-05 08:47:03.854 INFO [TSConfig print] 
GinJus commented 5 years ago

Still the same issues. Please help?

christocracy commented 5 years ago

I was on a road trip for most of July with 7 devices (4 Android, including 2 Samsung; 3 iOS). These devices were sitting untouched in a bag, the whole time.

I had no issues.

GinJus commented 5 years ago

Ok. So you say that my customers and I make up these issues?

christocracy commented 5 years ago

No, that your issues are specific to a particular device / os / environment.

So you tested this on the SampleApp? What username did you use so I can observe on my test server at http://tracker.transistorsoft.com?

GinJus commented 5 years ago

Yes, i've used my nickname.

http://tracker.transistorsoft.com/Alienspacecow

christocracy commented 5 years ago

It's not a very long test, only a few hours worth. Many of your locations came from Cellular provider (ie: accuracy >= 1000). Few locations came from GPS. Go for a longer test.

For comparison, you can view my tracking for July here. (you can select my different devices in [Devices][v] dropdown on left.

christocracy commented 5 years ago

Here's what happens when you go for a subway ride. Note the large jumps when I took a subway to the large park.

GinJus commented 5 years ago

That is the problem.... logs can't be longer than that because the app closes on the background. I assumed one log would do because it does the same over and over again with my own app.

The only way it restarts the logging is after a reboot of the phone or manually opening it again. I can't see the background service in Android Assistant after a while and don't get posts on the server.

christocracy commented 5 years ago

because the app closes on the background

Show me a raw $ adb logcat where you perform this.

Are you sure you don't have the Developer Option "Don't keep activities" enabled on your device?

GinJus commented 5 years ago

Are you sure you don't have the Developer Option Don't keep activities enabled on your device?

Yes i'm sure, the app is live and works on most devices. I still use the same configuration as posted previously.

I will try to gather the logcat.

christocracy commented 5 years ago

What's the status on this?

GinJus commented 5 years ago

I'm still figuring out how to retreive these logs.

christocracy commented 5 years ago

have you read the Debugging wiki?

efhilton commented 5 years ago

Personally I'm still experiencing this but I've had to move on to resolve bigger pressing items. I'll try to get back to this soon

On Mon, Aug 20, 2018, 09:49 Chris Scott notifications@github.com wrote:

have you read the Debugging https://github.com/transistorsoft/cordova-background-geolocation-lt/wiki/Debugging wiki?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/717#issuecomment-414343047, or mute the thread https://github.com/notifications/unsubscribe-auth/AYN6evN5OjpgYrI3lS4Zx_i64m0JeNXVks5uSsx0gaJpZM4Uzd-p .

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.