flutter_background_geolocation icon indicating copy to clipboard operation
flutter_background_geolocation copied to clipboard

`stopTimeout` seems to be stopping location updates even if not stopped for full duration

Open kvenn opened this issue 6 months ago • 3 comments

Your Environment

  • Plugin version: 4.15.4
  • Platform: iOS
  • OS version: 17.6
  • Device manufacturer / model: iPhone 13 Pro (physical)
  • Flutter info (flutter doctor):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.4)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.2)
[✓] VS Code (version 1.92.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!
  • Plugin config:
// And this one
return bg.Config(
      transistorAuthorizationToken: token,
      showsBackgroundLocationIndicator: false,
      stopOnTerminate: false,
      startOnBoot: true,
      stopTimeout: 4,
)

Expected Behavior

Locations continue to send if I stop for less than stopTimeout. And if I stop for over stopTimeout, locations should get sent again after moving 200m

From the Philosophy of Operation

If any motion is detected before this timer expires, the plugin will remain in the moving state.

Actual Behavior

Taking a short stop prevents locations from being sent. I don't get locations even after 200m+ of movement.

Steps to Reproduce

  1. stopTimeout = 4 minutes
  2. Move over 200m
  3. Stop for 60 seconds
  4. Move 200m

Context

I'm seeing high background usage and I'm trying to configure the plugin to spend less time running in the background.

I ran two builds on the same device, one with disableStopDetection: true and the other with it false and stopTimeout: 4.

The one with stopTimeout: 4 used 8 minutes in the background. The one with disableStopDetection: true used 45 minutes.

The only issue, is that the one with stopTimeout: 4 stopped reporting after a short pause.

disableStopDetection: true - you can see the point in the bottom right is further than 200m image

stopTimeout: 4 image

Relevant Logs:

----------- The screenshot time is in UTC, but it starts right before here

2024-08-12 17:12:53.520 🔵-[HttpResponse handleResponse] Response: 200

2024-08-12 17:12:53.529 ✅-[TSHttpService post:]_block_invoke DESTROY: CC5E22A9-C7C4-4F5C-BBD5-4F6760DDEEC1

2024-08-12 17:12:53.529 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 126 OF (
    126
)

2024-08-12 17:13:07.451 🔵-[TSLocationManager startMotionTriggerTimer] Motion-trigger timer engaged: Stop-detection will trigger in 10 seconds...

2024-08-12 17:13:17.456 🔵-[TSLocationManager beginStopDetection] ⏲Stop-timeout engaged: 240 s...

2024-08-12 17:13:44.703 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2024-08-12 17:13:44.704 ℹ️-[TSLocationManager resetStopTimeoutTimer] 

2024-08-12 17:13:44.730 ℹ️+[LocationAuthorization run:onCancel:] status: 3

----------- No new location updates between 17:13 -> 17:35

2024-08-12 17:35:20.123 🔵-[TSHttpService init]_block_invoke Network: WiFi | Flags: -R -------

Debug logs

Logs I think the relevant log starts here: 2024-08-12 17:13:07.451 ``` 2024-08-12 17:12:07.047 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 14.2

2024-08-12 17:12:07.047 ℹ️-[TSConfig persist]

2024-08-12 17:12:07.050 🔵-[TSConfig incrementOdometer:] 26901.9

2024-08-12 17:12:07.051 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-08-12 17:12:07.058 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 842A4234-2AF0-4A01-BCCE-21ECECAB6B3A

2024-08-12 17:12:07.059 ✅-[BackgroundTaskManager createBackgroundTask] 120

2024-08-12 17:12:07.062 ✅-[TSHttpService schedulePost] LOCKED: 842A4234-2AF0-4A01-BCCE-21ECECAB6B3A

2024-08-12 17:12:07.893 🔵-[HttpResponse handleResponse] Response: 200

2024-08-12 17:12:07.902 ✅-[TSHttpService post:]_block_invoke DESTROY: 842A4234-2AF0-4A01-BCCE-21ECECAB6B3A

2024-08-12 17:12:07.902 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 120 OF ( 120 )

2024-08-12 17:12:31.043 🔵-[TSLocationManager locationManager:didUpdateLocations:] Updated distanceFilter, new: 72.000000, old: 114.000000

2024-08-12 17:12:31.043 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 14.2

2024-08-12 17:12:31.043 ℹ️-[TSConfig persist]

2024-08-12 17:12:31.046 🔵-[TSConfig incrementOdometer:] 27021.4

2024-08-12 17:12:31.047 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-08-12 17:12:31.050 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 91030B9A-B6D1-4AF1-9A70-94AFC6734637

2024-08-12 17:12:31.051 ✅-[BackgroundTaskManager createBackgroundTask] 123

2024-08-12 17:12:31.053 ✅-[TSHttpService schedulePost] LOCKED: 91030B9A-B6D1-4AF1-9A70-94AFC6734637

2024-08-12 17:12:31.587 🔵-[HttpResponse handleResponse] Response: 200

2024-08-12 17:12:31.594 ✅-[TSHttpService post:]_block_invoke DESTROY: 91030B9A-B6D1-4AF1-9A70-94AFC6734637

2024-08-12 17:12:31.594 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 123 OF ( 123 )

2024-08-12 17:12:53.052 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 14.2

2024-08-12 17:12:53.052 ℹ️-[TSConfig persist]

2024-08-12 17:12:53.054 🔵-[TSConfig incrementOdometer:] 27095.0

2024-08-12 17:12:53.055 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-08-12 17:12:53.062 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: CC5E22A9-C7C4-4F5C-BBD5-4F6760DDEEC1

2024-08-12 17:12:53.063 ✅-[BackgroundTaskManager createBackgroundTask] 126

2024-08-12 17:12:53.066 ✅-[TSHttpService schedulePost] LOCKED: CC5E22A9-C7C4-4F5C-BBD5-4F6760DDEEC1

2024-08-12 17:12:53.520 🔵-[HttpResponse handleResponse] Response: 200

2024-08-12 17:12:53.529 ✅-[TSHttpService post:]_block_invoke DESTROY: CC5E22A9-C7C4-4F5C-BBD5-4F6760DDEEC1

2024-08-12 17:12:53.529 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 126 OF ( 126 )

2024-08-12 17:13:07.451 🔵-[TSLocationManager startMotionTriggerTimer] Motion-trigger timer engaged: Stop-detection will trigger in 10 seconds...

2024-08-12 17:13:17.456 🔵-[TSLocationManager beginStopDetection] ⏲Stop-timeout engaged: 240 s...

2024-08-12 17:13:44.703 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2024-08-12 17:13:44.704 ℹ️-[TSLocationManager resetStopTimeoutTimer]

2024-08-12 17:13:44.730 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-08-12 17:35:20.123 🔵-[TSHttpService init]_block_invoke Network: WiFi | Flags: -R -------

2024-08-12 17:35:20.125 🔵-[TSLocationManager onResume:] enabled? 1

2024-08-12 17:35:20.151 ℹ️-[LocationDAO purge:] 1

2024-08-12 17:35:20.248 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 14.2

2024-08-12 17:35:20.248 ℹ️-[TSConfig persist]

2024-08-12 17:35:20.256 🔵-[TSConfig incrementOdometer:] 28027.8


</details>

kvenn avatar Aug 12 '24 22:08 kvenn