Skip to content

[Bug]: On Android, watchPosition's parameterization seems to have no effect and just use the same update frequency as ready() #2589

@mhoeben

Description

@mhoeben

Required Reading

  • Confirmed

Plugin Version

5.1.1

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Google Pixel 3a, Android Emulator

Device operating-systems(s)

Android 12, Android 16

React Native / Expo version

0.81.5, Expo 54.0.33

What happened?

I am running background tracking at low accuracy and a distance filter of 10 meters. When the user brings the app to the foreground, I want to present them with a map with a more accurate location. From the documentation I understand that watchPosition is meant to cater for this scenario. But whatever parameters I pass to watchPosition (high accuracy and an interval of 1000 milliseconds), the passed callback only seems to get the same updates as the callback set by BackgroundGeolocation.onLocation does.

I expect watchPosition() to provide my app with a stream of higher accuracy and more frequent updates than the background service does.

Note that I also tried to set BackgroundGeolocation.changePace(true) ahead of watchPosition, to no avail.

Plugin Code and/or Config

const state = await BackgroundGeolocation.ready({
                    geolocation: {
                        desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.Low,
                        distanceFilter: 10,
                    },
                    activity: {
                        activityRecognitionInterval: 10000,
                        minimumActivityRecognitionConfidence: 50,
                        stopOnStationary: false,
                        disableStopDetection: false,
                        disableMotionActivityUpdates: false,
                    },
                    app: {
                        stopOnTerminate: false,
                        startOnBoot: true,
                    },
                    logger: {
                        logLevel: BackgroundGeolocation.LogLevel.Verbose,
                    },
                });

Relevant log output

05-19 20:37:23.606 18488 18488 D TSLocationManager: [LifecycleManager g] ☯️  onStart
05-19 20:37:23.606 18488 18488 D TSLocationManager: [TerminateEvent$a onChange] 
05-19 20:37:23.606 18488 18488 D TSLocationManager:   ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
05-19 20:37:23.606 18488 18488 D TSLocationManager: [TerminateEvent$a onChange] 
05-19 20:37:23.606 18488 18488 D TSLocationManager:   ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
05-19 20:37:23.630 18488 18488 D TSLocationManager: [LifecycleManager f] ☯️  onResume
05-19 20:37:23.771 18488 18488 D TSLocationManager: [LifecycleManager d] ☯️ onWindowFocusChanged: true
05-19 20:37:23.837 18488 19970 I TSLocationManager: [TSLocationManager watchPosition] 
05-19 20:37:23.837 18488 19970 I TSLocationManager:   🎾  watchPosition: ON
05-19 20:37:23.838 18488 19970 D TSLocationManager: [LocationAuthorization withPermission] 
05-19 20:37:23.838 18488 19970 D TSLocationManager:   ℹ️  LocationAuthorization: Permission granted
05-19 20:37:23.844 18488 18622 D TSLocationManager: [AccuracyTranslator translateIfNeeded] *** Translate: 100, useCL: false
05-19 20:37:23.850 18488 19785 I TSLocationManager: [m c] 
05-19 20:37:23.850 18488 19785 I TSLocationManager:   🔴  Stop heartbeat
05-19 20:37:23.855 18488 19785 D TSLocationManager: [TSGeofenceManager stopMonitoringStationaryRegion] 
05-19 20:37:23.855 18488 19785 D TSLocationManager:   🔴  Stop monitoring stationary region
05-19 20:37:23.856 18488 18622 D TSLocationManager: [LocationAuthorization withBackgroundPermission] 
05-19 20:37:23.856 18488 18622 D TSLocationManager:   ℹ️  LocationAuthorization: Permission granted
05-19 20:37:23.857 18488 19785 I TSLocationManager: [TrackingService a] 
05-19 20:37:23.857 18488 19785 I TSLocationManager:   🔵  setPace: falsetrue
05-19 20:37:23.859 18488 19785 D TSLocationManager: [TSGeofenceManager$d run] 
05-19 20:37:23.859 18488 19785 D TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:23.859 18488 19785 D TSLocationManager: ║ TSGeofenceManager monitoring 0/0
05-19 20:37:23.859 18488 19785 D TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:23.859 18488 19785 D TSLocationManager: ╚═════════════════════════════════════════════
05-19 20:37:23.860 18488 19785 D TSLocationManager: [EventManager c]   🛜 ⚡️ geofenceschange
05-19 20:37:23.943 18488 18488 D TSLocationManager: [SingleLocationRequest trySatisfyLastLocation] 📍  
05-19 20:37:23.943 18488 18488 D TSLocationManager: ╟─ age: 10721ms
05-19 20:37:23.943 18488 18488 D TSLocationManager: ╟─ maximumAge: 30000
05-19 20:37:23.943 18488 18488 D TSLocationManager: ╟─ desiredAccuracy: 20.0
05-19 20:37:23.943 18488 18488 D TSLocationManager: ╟─ meetsAccuracy: true
05-19 20:37:23.943 18488 18488 D TSLocationManager: ╟─ meetsStaleness: true
05-19 20:37:23.945 18488 19785 I TSLocationManager: - Enable: true → true, trackingMode: 1
05-19 20:37:23.946 18488 18488 I TSLocationManager: [TSLocationManager a] 
05-19 20:37:23.946 18488 18488 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:23.946 18488 18488 I TSLocationManager: ║ motionchange LocationResult: 11 (10723ms old)
05-19 20:37:23.946 18488 18488 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:23.946 18488 18488 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=5.0 et=+17h2m39s738ms alt=66.4 vAcc=0.26 vel=0.30352196 sAcc=0.5 bear=116.0 bAcc=30.0 {Bundle[{persist=true}]}], time: 1779219433222
05-19 20:37:23.946 18488 18488 I TSLocationManager: [TSLocationManager onSingleLocationResult] 
05-19 20:37:23.946 18488 18488 I TSLocationManager:   🔵  MOTIONCHANGE isMoving=true df=50.0 — resetting short-term filter state
05-19 20:37:23.946 18488 18488 I TSLocationManager: [TSLocationManager onSingleLocationResult] 
05-19 20:37:23.946 18488 18488 I TSLocationManager:   🔵  Acquired motionchange position, isMoving: true
05-19 20:37:23.946 18488 19785 D TSLocationManager: [HttpService startMonitoringConnectivityChanges] 
05-19 20:37:23.946 18488 19785 D TSLocationManager:   🎾  Start monitoring connectivity changes
05-19 20:37:23.946 18488 19785 D TSLocationManager: [DeviceSettings startMonitoringPowerSaveChanges] 
05-19 20:37:23.946 18488 19785 D TSLocationManager:   🎾  Start monitoring powersave changes
05-19 20:37:23.946 18488 19785 I TSLocationManager: [ActivityRecognitionService d] 
05-19 20:37:23.946 18488 19785 I TSLocationManager:   🎾  Start motion-activity updates
05-19 20:37:23.950 18488 18488 I TSLocationManager: [TSLocationManager requestLocationUpdates] 
05-19 20:37:23.950 18488 18488 I TSLocationManager:   🎾  Location-services: ON
05-19 20:37:23.960 18488 19785 I TSLocationManager: [w a] 
05-19 20:37:23.960 18488 19785 I TSLocationManager:   💾 ✅ 8a6eabe0-6902-453c-bb9d-2ca3ea0f5a5d
05-19 20:37:23.977 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:37:23.977 18488 18488 D TSLocationManager:   🎾  motionchange [TrackingService  startId: 1, eventCount: 1]
05-19 20:37:23.977 18488 18488 I TSLocationManager: [TrackingService l] 
05-19 20:37:23.977 18488 18488 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:23.977 18488 18488 I TSLocationManager: ║ TrackingService motionchange: true
05-19 20:37:23.977 18488 18488 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:23.977 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:37:23.977 18488 18488 D TSLocationManager:   ⚙️︎  FINISH [TrackingService startId: 1, eventCount: 0, sticky: true]
05-19 20:37:24.009 18488 18488 I TSLocationManager: [ActivityRecognitionService d] 
05-19 20:37:24.009 18488 18488 I TSLocationManager:   🎾  Start motion-activity updates
05-19 20:37:24.025 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ providerchange
05-19 20:37:24.027 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ location
05-19 20:37:24.029 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ motionchange
05-19 20:37:24.044 18488 18488 D TSLocationManager: [SingleLocationRequest trySatisfyLastLocation] 📍  
05-19 20:37:24.044 18488 18488 D TSLocationManager: ╟─ age: 10820ms
05-19 20:37:24.044 18488 18488 D TSLocationManager: ╟─ maximumAge: 30000
05-19 20:37:24.044 18488 18488 D TSLocationManager: ╟─ desiredAccuracy: 20.0
05-19 20:37:24.044 18488 18488 D TSLocationManager: ╟─ meetsAccuracy: true
05-19 20:37:24.044 18488 18488 D TSLocationManager: ╟─ meetsStaleness: true
05-19 20:37:24.045 18488 18488 I TSLocationManager: [TSLocationManager a] 
05-19 20:37:24.045 18488 18488 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:24.045 18488 18488 I TSLocationManager: ║ motionchange LocationResult: 12 (10822ms old)
05-19 20:37:24.045 18488 18488 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:24.045 18488 18488 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=5.0 et=+17h2m39s738ms alt=66.4 vAcc=0.26 vel=0.30352196 sAcc=0.5 bear=116.0 bAcc=30.0 {Bundle[{persist=false}]}], time: 1779219433222
05-19 20:37:24.045 18488 18488 I TSLocationManager: [TSLocationManager onSingleLocationResult] 
05-19 20:37:24.045 18488 18488 I TSLocationManager:   🔵  MOTIONCHANGE isMoving=true df=50.0 — resetting short-term filter state
05-19 20:37:24.046 18488 18488 I TSLocationManager: [TSLocationManager onSingleLocationResult] 
05-19 20:37:24.046 18488 18488 I TSLocationManager:   🔵  Acquired motionchange position, isMoving: true
05-19 20:37:24.047 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ location
05-19 20:37:24.048 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ motionchange
05-19 20:37:24.050 18488 18488 I TSLocationManager: [TSLocationManager a] 
05-19 20:37:24.050 18488 18488 I TSLocationManager:   🔴  Location-services: OFF
05-19 20:37:24.053 18488 18488 I TSLocationManager: [TSLocationManager requestLocationUpdates] 
05-19 20:37:24.053 18488 18488 I TSLocationManager:   🎾  Location-services: ON
05-19 20:37:24.062 18488 18488 I TSLocationManager: [ActivityRecognitionService d] 
05-19 20:37:24.062 18488 18488 I TSLocationManager:   🎾  Start motion-activity updates
05-19 20:37:24.190 18488 18488 D TSLocationManager: [TSLocationManagerActivity a] locationsettings
05-19 20:37:24.264 18488 18488 D TSLocationManager: [LifecycleManager d] ☯️ onWindowFocusChanged: false
05-19 20:37:24.269 18488 18488 I TSLocationManager: [TSScheduleManager oneShot] 
05-19 20:37:24.269 18488 18488 I TSLocationManager:   ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
05-19 20:37:24.356 18488 18488 D TSLocationManager: [TSLocationManagerActivity onDestroy] locationsettings
05-19 20:37:24.392 18488 18488 D TSLocationManager: [LifecycleManager d] ☯️ onWindowFocusChanged: true
05-19 20:37:24.393 18488 18488 I TSLocationManager: [TSScheduleManager cancelOneShot] 
05-19 20:37:24.393 18488 18488 I TSLocationManager:   ⏰ Cancel OneShot: TERMINATE_EVENT
05-19 20:37:41.212 18488 18488 D TSLocationManager: [LifecycleManager d] ☯️ onWindowFocusChanged: false
05-19 20:37:41.214 18488 18488 I TSLocationManager: [TSScheduleManager oneShot] 
05-19 20:37:41.214 18488 18488 I TSLocationManager:   ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
05-19 20:37:42.920 18488 18488 D TSLocationManager: [LifecycleManager d] ☯️ onWindowFocusChanged: true
05-19 20:37:42.922 18488 18488 I TSLocationManager: [TSScheduleManager cancelOneShot] 
05-19 20:37:42.922 18488 18488 I TSLocationManager:   ⏰ Cancel OneShot: TERMINATE_EVENT
05-19 20:37:43.242 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:37:43.242 18488 18488 D TSLocationManager:   🎾  5:10 [LocationRequestService  startId: 1, eventCount: 1]
05-19 20:37:43.243 18488 19785 I TSLocationManager: [TSLocationManager a] 
05-19 20:37:43.243 18488 19785 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:43.243 18488 19785 I TSLocationManager: ║ watchPosition LocationResult: 10 (19ms old)
05-19 20:37:43.243 18488 19785 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:43.243 18488 19785 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=47.0014 et=+17h3m9s740ms alt=66.4 vAcc=10.76035], time: 1779219463223
05-19 20:37:43.247 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:37:43.247 18488 18488 D TSLocationManager:   🎾  start [TrackingService  startId: 2, eventCount: 1]
05-19 20:37:43.248 18488 18488 D TSLocationManager: [TrackingService c] 
05-19 20:37:43.248 18488 18488 D TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:43.248 18488 18488 D TSLocationManager: ║ TrackingService: LocationResult
05-19 20:37:43.248 18488 18488 D TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:43.248 18488 18488 D TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=47.0014 et=+17h3m9s740ms alt=66.4 vAcc=10.76035]
05-19 20:37:43.248 18488 18488 D TSLocationManager: ╟─ Age: 24ms, time: 1779219463223
05-19 20:37:43.248 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:37:43.248 18488 18488 D TSLocationManager:   ⚙️︎  FINISH [TrackingService startId: 2, eventCount: 0, sticky: true]
05-19 20:37:43.248 18488 19785 D TSLocationManager: [AbstractService a] 
05-19 20:37:43.248 18488 19785 D TSLocationManager:   ⚙️︎  FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true]
05-19 20:37:43.248 18488 19970 D TSLocationManager: [TSLocationManager onLocationResult] 
05-19 20:37:43.248 18488 19970 D TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:37:43.248 18488 19970 D TSLocationManager: ║ Process LocationResult
05-19 20:37:43.248 18488 19970 D TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:37:43.248 18488 19970 D TSLocationManager: [TSLocationManager onLocationResult] LocationFilterResult: LocationFilterResult{decision=ACCEPTED, reason='ok', selected=0.0, raw=0.0, effective=0.0, anomaly=false, acc(cur)=47.0014, acc(prev)=5.0}
05-19 20:37:43.250 18488 18488 D TSLocationManager: [EventManager c]   🛜 ⚡️ location
05-19 20:37:43.251 18488 19785 I TSLocationManager: [w a] 
05-19 20:37:43.251 18488 19785 I TSLocationManager:   💾 ✅ 8b61025c-1b48-4b43-8f21-add436fac958
05-19 20:38:13.238 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:38:13.238 18488 18488 D TSLocationManager:   🎾  5:10 [LocationRequestService  startId: 2, eventCount: 1]
05-19 20:38:13.239 18488 19785 I TSLocationManager: [TSLocationManager a] 
05-19 20:38:13.239 18488 19785 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:38:13.239 18488 19785 I TSLocationManager: ║ watchPosition LocationResult: 10 (12ms old)
05-19 20:38:13.239 18488 19785 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:38:13.239 18488 19785 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=89.004196 et=+17h3m39s742ms alt=66.4 vAcc=21.26105], time: 1779219493226
05-19 20:38:13.245 18488 19785 D TSLocationManager: [AbstractService a] 
05-19 20:38:13.245 18488 19785 D TSLocationManager:   ⚙️︎  FINISH [LocationRequestService startId: 2, eventCount: 0, sticky: true]
05-19 20:38:16.544 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:38:16.544 18488 18488 D TSLocationManager:   🎾  start [ActivityRecognitionService  startId: 1, eventCount: 1]
05-19 20:38:16.545 18488 19785 D TSLocationManager: [ActivityRecognitionService a] 
05-19 20:38:16.545 18488 19785 D TSLocationManager:   🚘 ️DetectedActivity [type=STILL, confidence=100]
05-19 20:38:16.547 18488 19785 D TSLocationManager: [AbstractService a] 
05-19 20:38:16.547 18488 19785 D TSLocationManager:   ⚙️︎  FINISH [ActivityRecognitionService startId: 1, eventCount: 0, sticky: false]
05-19 20:38:16.550 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:38:16.550 18488 18488 D TSLocationManager:   🎾  STOP_TIMEOUT [TrackingService  startId: 3, eventCount: 1]
05-19 20:38:16.551 18488 18488 I TSLocationManager: [TSScheduleManager oneShot] 
05-19 20:38:16.551 18488 18488 I TSLocationManager:   ⏰ Scheduled OneShot: STOP_TIMEOUT in 300000ms (jobID: 2059034116)
05-19 20:38:16.552 18488 18488 W TSLocationManager: [TSScheduleManager oneShot] 
05-19 20:38:16.552 18488 18488 W TSLocationManager:   ℹ️  Scheduling exact alarms requires android.permission.USE_EXACT_ALARM with SDK >= 34.  Oneshot using in-exact Alarm
05-19 20:38:16.553 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:38:16.553 18488 18488 D TSLocationManager:   ⚙️︎  FINISH [TrackingService startId: 3, eventCount: 0, sticky: true]
05-19 20:38:16.749 18488 18488 D TSLocationManager: [AbstractService f] 
05-19 20:38:16.749 18488 18488 D TSLocationManager:   ⚙️︎  ActivityRecognitionService.stopSelfResult(1): true
05-19 20:38:16.749 18488 18488 D TSLocationManager: [AbstractService onDestroy] 
05-19 20:38:16.749 18488 18488 D TSLocationManager:   🔴  ActivityRecognitionService stopped
05-19 20:38:43.242 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:38:43.242 18488 18488 D TSLocationManager:   🎾  5:10 [LocationRequestService  startId: 3, eventCount: 1]
05-19 20:38:43.244 18488 19785 I TSLocationManager: [TSLocationManager a] 
05-19 20:38:43.244 18488 19785 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:38:43.244 18488 19785 I TSLocationManager: ║ watchPosition LocationResult: 10 (14ms old)
05-19 20:38:43.244 18488 19785 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:38:43.244 18488 19785 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=100.0 et=+17h4m9s746ms alt=66.4 vAcc=31.762451], time: 1779219523229
05-19 20:38:43.250 18488 19785 D TSLocationManager: [AbstractService a] 
05-19 20:38:43.250 18488 19785 D TSLocationManager:   ⚙️︎  FINISH [LocationRequestService startId: 3, eventCount: 0, sticky: true]
05-19 20:39:13.246 18488 18488 D TSLocationManager: [AbstractService a] 
05-19 20:39:13.246 18488 18488 D TSLocationManager:   🎾  5:10 [LocationRequestService  startId: 4, eventCount: 1]
05-19 20:39:13.247 18488 19785 I TSLocationManager: [TSLocationManager a] 
05-19 20:39:13.247 18488 19785 I TSLocationManager: ╔═════════════════════════════════════════════
05-19 20:39:13.247 18488 19785 I TSLocationManager: ║ watchPosition LocationResult: 10 (14ms old)
05-19 20:39:13.247 18488 19785 I TSLocationManager: ╠═════════════════════════════════════════════
05-19 20:39:13.247 18488 19785 I TSLocationManager: ╟─ 📍  Location[fused 42.441638,-71.121442 hAcc=100.0 et=+17h4m39s748ms alt=66.4 vAcc=42.26315], time: 1779219553232
05-19 20:39:13.252 18488 19785 D TSLocationManager: [AbstractService a] 
05-19 20:39:13.252 18488 19785 D TSLocationManager:   ⚙️︎  FINISH [LocationRequestService startId: 4, eventCount: 0, sticky: true]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions