flutter_background_geolocation icon indicating copy to clipboard operation
flutter_background_geolocation copied to clipboard

Plugin stop working around 2 hours, not sure is user turn mobile off or not?

Open iporsut opened this issue 2 years ago • 3 comments

Your Environment

  • Plugin version: 4.12.2
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: Vivo , vivo 1906
  • Flutter info (flutter doctor):

┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available!                  │
│                                                         │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.0, on macOS 14.0 23A344 darwin-arm64, locale en-TH)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.83.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
  • Plugin config:
bg.Config(
      reset: true,
      debug: false,
      autoSync: true,
      locationAuthorizationRequest: 'Always',
      geofenceModeHighAccuracy: true,
      maxRecordsToPersist: 1,
      preventSuspend: true,
      heartbeatInterval: 60,
      logLevel: bg.Config.LOG_LEVEL_VERBOSE,
      desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
      distanceFilter: 15,
      backgroundPermissionRationale: bg.PermissionRationale(
          title:
              "Allow {applicationName} to access this device's location even when the app is closed or not in use.",
          message:
              "This app collects location data to enable recording your trips to work and calculate distance-travelled.",
          positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
          negativeAction: 'Cancel'),
      url: url,
      stopOnTerminate: false,
      startOnBoot: true,
      // locationTemplate: '{ "lat": "<%= latitude %>", "long": "<%= longitude %>" }',
      headers: {
        "x-device-info-model": deviceInfo.model,
        "x-device-info-manufacturer": deviceInfo.manufacturer,
        "x-device-info-version": deviceInfo.version,
        "x-device-info-platform": deviceInfo.platform,
        "x-device-info-framework": deviceInfo.framework,
        "x-package-info-version": packageInfo.version,
        "x-package-info-build-number": packageInfo.buildNumber,
      },
      enableHeadless: true,
    )

Expected Behavior

We expect continually http send to backend when looking at debug log.

Actual Behavior

We found that log discontinue and stop logging since 05:34:06.657 10-27 05:34:06.657 INFO [HttpService flush] and come back again at 07:40:58.383 10-27 07:40:58.383 DEBUG [LoggerFacade$a a] PID: 3

Steps to Reproduce

Context

Debug logs

Logs
  🎾  START [TrackingService  [startId: 28, eventCount: 1]
10-27 05:34:06.610 DEBUG [TrackingService handleLocationResult] 
╔═════════════════════════════════════════════
║ TrackingService: LocationResult
╠═════════════════════════════════════════════
╟─ 📍  Location[fused M:0,0,-11872,585 hAcc=10 et=+8d14h38m37s288ms alt=-27.098236083984375 vel=17.956417 bear=157.93564 vAcc=4 sAcc=1 bAcc=4 {Bundle[{}]}]
╟─ Age: 59ms, time: 1698359646550

10-27 05:34:06.611 DEBUG [TSLocationManager onLocationResult] 
╔═════════════════════════════════════════════
║ Process LocationResult
╠═════════════════════════════════════════════

10-27 05:34:06.612 INFO [TrackingService performStopDetection] 
  ℹ️  Distance from stoppedAtLocation: 53.488327
10-27 05:34:06.612 DEBUG [TrackingService performStopDetection] 
  ℹ️  Force cancel cancel stopTimeout due to apparent movement beyond stoppedAt location
10-27 05:34:06.612 INFO [TSLocationManager onLocationResult] 
  🔵  Re-scaled distanceFilter: 60.0->75.0)
10-27 05:34:06.614 INFO [TSScheduleManager cancelOneShot] 
  ⏰ Cancel OneShot: STOP_TIMEOUT
10-27 05:34:06.617 DEBUG [TSLocationManager locationIsInvalid] Distance from last location: 72.784325, apparent speed: 18.177904
10-27 05:34:06.617 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 10.005
10-27 05:34:06.618 DEBUG [TSLocationManager incrementOdometer] Odometer: 384145.03
10-27 05:34:06.629 INFO [b persist] 
  ✅  INSERT: 9c8d0e2d-4200-48eb-9c4c-aabd613e0cf3
10-27 05:34:06.631 INFO [TSScheduleManager oneShot] 
  ⏰ Scheduled OneShot: MOTION_ACTIVITY_CHECK in 64004ms (jobID: -18513055)
10-27 05:34:06.634 DEBUG [AbstractService finish] 
  ⚙️︎   FINISH [TrackingService startId: 28, eventCount: 0, sticky: true]
10-27 05:34:06.650 DEBUG [HeadlessTask onHeadlessEvent] 💀 [HeadlessTask location]
10-27 05:34:06.654 DEBUG [b g] 
  ℹ️  SHRINK: 1
10-27 05:34:06.657 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 1)
╠═════════════════════════════════════════════

10-27 07:40:58.383 DEBUG [LoggerFacade$a a] PID: 3
10-27 07:40:58.385 INFO [LoggerFacade$a a] 
╔═════════════════════════════════════════════
║ DEVICE SENSORS
╠═════════════════════════════════════════════
╟─ ✅  ACCELEROMETER: {Sensor name="LIS2HH Accelerometer", vendor="STMicroelectronics", version=1, type=1, maxRange=39.226738, resolution=0.0023928226, power=0.18, minDelay=5000}
╟─ ✅  GYROSCOPE: {Sensor name="AK09918-pseudo-gyro", vendor="akm", version=2, type=4, maxRange=2000.0, resolution=0.1, power=1.0, minDelay=10000}
╟─ ✅  MAGNETOMETER: {Sensor name="AK09918 Magnetometer", vendor="AKM", version=1, type=2, maxRange=4900.0, resolution=0.1, power=1.1, minDelay=10000}
╟─ ✅  SIGNIFICANT_MOTION: {Sensor name="Significant Motion Detector", vendor="QTI", version=2, type=17, maxRange=1.0, resolution=1.0, power=0.17999268, minDelay=-1}
╚═════════════════════════════════════════════
10-27 07:40:58.385 INFO [LoggerFacade$a a] 
╔═════════════════════════════════════════════
║ TSLocationManager version: 3.4.4 (425)
╠═════════════════════════════════════════════
╟─ vivo vivo 1906 @ 11 (flutter)

Does it is because user turn off mobile phone or something else problem with application?

iporsut avatar Oct 27 '23 11:10 iporsut

Where you see this, it means your application process was restarted from a terminated state:

10-27 07:40:58.385 INFO [LoggerFacade$a a] 
╔═════════════════════════════════════════════
║ TSLocationManager version: 3.4.4 (425)
╠═════════════════════════════════════════════

There is no explanation for why the OS decided to terminate your application process. Either the user explicitly terminated the process via settings or the OS was under severe memory pressure due to some other app running in the foreground. The plugin had an active foreground-service running at 5:34:06.

christocracy avatar Oct 27 '23 12:10 christocracy

That's mean if process was force terminated by OS then headless task callback function and location tracker will stop even we configure stopOnTerminate: false, right?

iporsut avatar Oct 27 '23 13:10 iporsut

@iporsut I am almost positive i've had good success results for plugin continuing to work even after terminmate from memory pressure; for example, obviously if the phone restarts all apps stop and restart right? and after days/weeks go by they all restart eventually from memory pressure right?

it's been a few months probably you got more info? anyway, you an have a headless task registered to get more info and save stuff to database/local storage/logs, that's what i did.

neiljaywarner avatar Jan 30 '24 19:01 neiljaywarner

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 19 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 03 '24 01:05 github-actions[bot]