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

Plugin stops recording after several days #1390

Closed frank-trackjack closed 1 year ago

frank-trackjack commented 1 year ago

Your Environment

Expected Behavior

The plugin should continuously register locations, even after a number of days.

Actual Behavior

We experience it will work for some days but then stops working. See the log on 03-21, it suddenly stops while the phone was used in the field afterwards (3-22).

Context

We are making an app that registers car journeys. We have also created an Android headless task with the same functionality to record rides in the background.

We have been using the cordova version since we already had an app in cordova. Do you perhaps recommend changing platforms? What is the best platform, in your experience, for using your plugin?

Debug logs

Logs ``` 03-21 14:46:45.461 INFO [LocationRequestService handleLocationResult] ╔═════════════════════════════════════════════ ║ motionchange LocationResult: 5 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 51.695882,5.219176 hAcc=4.048 et=+8d6h36m44s757ms alt=49.80000305175781 vAcc=1.0747242 vel=4.346507E-8 sAcc=0.033500053 {Bundle[{}]}], age: 44ms, time: 1679406405416 03-21 14:46:45.469 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position, isMoving: false 03-21 14:46:45.470 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 5.661 03-21 14:46:45.471 DEBUG [TSLocationManager incrementOdometer] Odometer: 359592.78 03-21 14:46:45.487 DEBUG [AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false] 03-21 14:46:45.488 DEBUG [LocationRequestService handleLocationResult] SingleLocationRequest 5 isFinished? true 03-21 14:46:45.488 DEBUG [AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false] 03-21 14:46:45.513 INFO [b persist] ✅ INSERT: 176ac26d-6ee1-4ad0-b4cf-aac47e3b2b8c 03-21 14:46:45.532 DEBUG [TSGeofenceManager startMonitoringStationaryRegion] 🎾 Start monitoring stationary region (radius: 150.0m 51.6958815,5.219176 hAcc=4.048) 03-21 14:46:45.538 DEBUG [AbstractService onDestroy] 🔴 LocationRequestService stopped 03-21 14:46:45.548 DEBUG [AbstractService start] 🎾 TrackingService [eventCount: 1] 03-21 14:46:45.549 INFO [TrackingService handleMotionChangeResult] ╔═════════════════════════════════════════════ ║ TrackingService motionchange: false ╠═════════════════════════════════════════════ 03-21 14:46:45.555 DEBUG [AbstractService finish] ⚙️︎ finish TrackingService [eventCount: 0, sticky: false] 03-21 14:46:45.818 DEBUG [AbstractService onDestroy] 🔴 TrackingService stopped 03-21 15:01:43.005 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:01:43.010 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:01:58.484 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:01:58.744 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:01:58.745 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:02:08.523 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:02:08.529 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 15:02:18.045 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:02:18.047 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:03:17.033 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:03:17.638 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:03:17.640 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:03:27.092 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:03:27.093 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 15:05:39.976 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:05:39.986 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:05:42.648 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:05:42.916 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:05:42.917 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:05:52.715 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:05:52.716 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 15:51:38.190 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:51:38.194 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:52:12.213 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:52:12.450 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:52:12.451 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:53:01.917 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:53:01.920 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:53:01.955 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:53:01.958 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 15:53:37.242 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:53:37.839 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:53:37.842 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:54:01.670 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 15:54:01.674 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 15:54:01.778 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:54:01.778 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 15:54:23.518 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 15:54:25.765 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 15:54:25.772 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 15:55:29.846 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 15:55:29.847 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 16:10:02.276 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 16:10:02.282 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:11:59.074 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:11:59.701 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:12:06.939 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:12:10.432 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 16:12:10.434 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 16:12:20.549 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 16:12:20.553 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 16:14:19.236 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 16:14:19.252 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:14:27.348 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:14:27.959 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:14:35.369 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:14:38.247 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:14:43.508 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:14:44.214 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:15:08.549 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 16:15:09.161 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:15:09.164 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 16:15:14.662 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 16:15:14.663 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 16:15:19.354 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 16:15:19.355 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 16:16:14.664 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 16:16:14.894 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 16:16:14.895 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 16:16:28.295 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 16:16:28.296 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-21 17:11:31.083 DEBUG [LifecycleManager onStart] ☯️ onStart 03-21 17:11:31.097 DEBUG [LifecycleManager onResume] ☯️ onResume 03-21 17:11:47.685 DEBUG [LifecycleManager onPause] ☯️ onPause 03-21 17:11:50.675 DEBUG [LifecycleManager onStop] ☯️ onStop 03-21 17:11:50.688 INFO [TSScheduleManager oneShot] ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 03-21 17:12:03.684 INFO [ScheduleEvent onOneShot] ╔═════════════════════════════════════════════ ║ ⏰ OneShot event fired: TERMINATE_EVENT ╠═════════════════════════════════════════════ 03-21 17:12:03.685 DEBUG [TerminateEvent$a a] ℹ️ TERMINATE_EVENT ignored (MainActivity is still active). 03-23 17:05:51.028 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.3.1 (418) ╠═════════════════════════════════════════════ ╟─ samsung SM-G980F @ 12 (cordova) { ```
christocracy commented 1 year ago

Your issue is likely replayed to your particular device. See https://dontkillmyapp.com.

Yes, you should migrate away from Cordova ASAP. Capacitor is the easiest migration for Cordova users.

My preferred framework is Flutter, followed by React Native.

christocracy commented 1 year ago

Your issue is likely related to your particular device. See https://dontkillmyapp.com.

Yes, you should migrate away from Cordova ASAP. Capacitor is the easiest migration for Cordova users.

My preferred framework is Flutter, followed by React Native.

frank-trackjack commented 1 year ago

Thanks for your advice, we will migrate to another framework ASAP.

We have read the instructions from https://dontkillmyapp.com/ and disabled battery optimization in Android for our app. Still the app stops working after a few days. Is there any other way to keep it from shutting down completely? How do others deal with this problem? It is essential for our use case that the app continues to work for longer periods.

Does switching frameworks affect Android killing the app?

christocracy commented 1 year ago

Is there any other way to keep it from shutting down completely?

Your problem is likely related to your specific device. The plugin is able to continue tracking automatically, regardless if app terminated or device rebooted simply by configuring stopOnTerminate: false, startOnBoot: true.

How do others deal with this problem?

I don't have this problem on my devices (where https://dontkillmyapp.com have been applied)

It is essential for our use case that the app continues to work for longer periods.

I'm fully confident that I can take any of my test devices above outside, which may have been sitting idle on my desk for weeks, and they will track.

Does switching frameworks affect Android killing the app?

No

frank-trackjack commented 1 year ago

Okay, thanks!