transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.66k stars 426 forks source link

Location updates are not working properly (getting 20–25 locations in a minute, even on high speed) #2123

Closed alihasan21987 closed 1 month ago

alihasan21987 commented 3 months ago

Your Environment

Expected Behavior

Actual Behavior

I am using the above settings and getting much battery drain, specially on IOS Devices. Moreover, plugin is giving me constantly location updates, e.g. 20-25 location updates in one minutes I have shared a Excel sheet with speed and location with respect to time.

Steps to Reproduce

1.Set the above configuration and you will see the same behaviour as described above. 2. 3. 4.

Context

Debug logs

Logs ``` { activityRecognitionInterval = 10000; activityType = 1; authorization = { }; autoSync = 1; autoSyncThreshold = 0; batchSync = 0; debug = 0; desiredAccuracy = "-1"; desiredOdometerAccuracy = 10; didDeviceReboot = 0; didLaunchInBackground = 0; didRequestUpgradeLocationAuthorization = 1; disableAutoSyncOnCellular = 0; disableElasticity = 0; disableLocationAuthorizationAlert = 0; disableMotionActivityUpdates = 1; disableStopDetection = 0; distanceFilter = 9; elasticityMultiplier = 1; enableTimestampMeta = 0; enabled = 1; extras = { }; geofenceInitialTriggerEntry = 1; geofenceProximityRadius = 2000; geofenceTemplate = ""; headers = { }; heartbeatInterval = 60; httpRootProperty = location; httpTimeout = 60000; iOSHasWarnedLocationServicesOff = 0; isFirstBoot = 0; isMoving = 0; lastLocationAuthorizationStatus = 3; locationAuthorizationAlert = { cancelButton = Cancel; instructions = "To use background location, you must enable 'Always' in the Location Services settings"; settingsButton = Settings; titleWhenNotEnabled = "Location Services are Disabled"; titleWhenOff = "Location Services are OFF"; }; locationAuthorizationRequest = Always; locationTemplate = ""; locationTimeout = 60; locationsOrderDirection = ASC; logLevel = 5; logMaxDays = 3; maxBatchSize = "-1"; maxDaysToPersist = 1; maxRecordsToPersist = "-1"; method = POST; minimumActivityRecognitionConfidence = 70; odometer = "219499.9364983908"; params = { }; pausesLocationUpdatesAutomatically = 1; persistMode = 2; preventSuspend = 0; schedule = ( ); schedulerEnabled = 0; showsBackgroundLocationIndicator = 0; startOnBoot = 1; stationaryRadius = 25; stopAfterElapsedMinutes = "-1"; stopDetectionDelay = 0; stopOnStationary = 0; stopOnTerminate = 0; stopTimeout = 5; trackingMode = 1; url = ""; useSignificantChangesOnly = 0; } [App Battery Drain Stats.xlsx](https://github.com/user-attachments/files/16725727/App.Battery.Drain.Stats.xlsx) [background-geolocation (8).log](https://github.com/user-attachments/files/16725728/background-geolocation.8.log) [location-stats(1_47pm - 4_32pm 22 aug 2024).csv](https://github.com/user-attachments/files/16725736/location-stats.1_47pm.-.4_32pm.22.aug.2024.csv) ```

Questions

  1. What specific settings need to be configured to ensure location updates are triggered as speed changes?
  2. Why plugin is draining battery highly, specially on IOS Devices.
  3. What configuration changes or optimizations can be applied within the plugin settings to minimize battery usage while still maintaining adequate location tracking?
alihasan21987 commented 3 months ago

1- Why isn't the elasticity working with our current settings? 2- What steps can I take to fix the issue with elasticity? 3- Based on our current settings, what percentage of battery drain should we expect from Transistor soft during a 3-hour drive?

christocracy commented 3 months ago

1- Why isn't the elasticity working with our current settings? 2- What steps can I take to fix the issue with elasticity?

It IS working, as you can clearly see in your own logs. You have a configured distanceFilter: 9 (which is really low) and the plugin is clearly scaling your distanceFilter up to 45 when travelling at 17.69 meters/second.

Search your own logs for "Updated distanceFilter"

2024-08-22 13:57:50.111 
📍<+31.47439224,+74.25649331> +/- 4.75m (speed 17.69 mps / course 255.04) @ 22/08/2024, 1:57:49 PM Pakistan Standard Time

2024-08-22 13:57:50.111 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 36.0m | age: 111 ms
╚═══════════════════════════════════════════════════════════

2024-08-22 13:57:50.111 🔵-[TSLocationManager locationManager:didUpdateLocations:] Updated distanceFilter, new: 45.000000, old: 36.000000

3- Based on our current settings, what percentage of battery drain should we expect from Transistor soft during a 3-hour drive?

It will consume just as much battery as following a driving-route in any Maps app (eg: Google Maps). There is no "magic battery saving" when the plugin is in the moving state and tracking location. The battery-saving of this plugin comes in automatically turning off location-services when the device is detected to be stationary.

Are you performing your HTTP requests with each received location?

christocracy commented 2 months ago

getting 20–25 locations in a minute, even on high speed

17.69 m/s = 1061.4 meters/min (17.68 * 60)
1061.4 / 45 (scaled distanceFilter)
= ~ 23 locations/min

if you want fewer locations recorded, increase your distanceFilter: 9 to something more sensible, such as 50.

github-actions[bot] commented 1 month ago

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

github-actions[bot] commented 1 month ago

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