Closed ironmanromeo closed 2 years ago
the only difference appears to be logLevel
My demo apps for Flutter and Capacitor are complex, with full map.
I will add mapping to my new demo app.
Right: interesting consideration.
I haven't tested it yet, but I think I see the issue in HelloWorldApp.tsx
. I decided to boot the app in the Simulator and have a look at the memory / CPU usage while simulating location with Freeway Drive. After about 5 minutes, it goes off-the-charts.
Try this: In your bggeolocation-demo-issue
repo, disable this line. That will prevent the onLocation
event-handler from adding a JSON record of each location to the list.
Here's what the memory/cpu profile looks like without adding JSON for each record the the ReactNative UI:
distanceFilter: 0
of course causes an insane amount of records to be added to the UI in a short period of time.
Can this be a problem in SQLite?
You should not use .map. for UI elements. Never! Try FlatList.
Can this be a problem in SQLite?
If you’re talking about the plug-in’s SQLIte, no. Notice the flat memory / cpu response when I disable the plugin updating the UI. The plugin has been doing this same thing with SQLite since 2013.
You should not use .map. for UI elements. Never! Try FlatList.
I’m basically a noob when it comes to React UI.
disable the line I mentioned in your demo app and go outside for a test.
I will, but what happens is obvious: memory spikes because .map continues to create Views as the array grows and at some point the system is no longer able to handle a large number of objects. FlatList instead uses a FIFO mechanism whereby only the views that are on a screen are created and as the last cell that disappears from the view is reused by re-inserting it from the top. They are typically 5 or 6 views instead of thousands. What I see in the simulator is absolutely obvious. I edit the page with the FlatList before going out and put it here.
I’m not concerned about the list.
I’m concerned about finding the reason your app stops tracking after 5min.
In your own app, you’re likely doing something similar, accumulating a large amount of data in memory. Eg: Markers on a map.
I save as you the data in the DB (SQLite), but in fact I have not checked if the UI compromises the memory. Following your advice I will postpone the UI update when the training is finished.
This could help: https://reactnative.dev/docs/appstate
Ok, I took out your demo app with onLocation
prevented from adding records to the list. About one hour: tracking was successful.
This case is closed. The problem was client javascript consuming too much memory and the OS suspending the app to save the phone from the app consuming all the device resources.
There was no issue with the plugin.
@diretur You're being blocked.
This is 100% not a plugin issue. The plugin's responsibility ends once its events are executed. Everything beyond that is your own app's responsibility.
Your Environment
react-native -v
): react-native-cli: 2.0.1 - react-native: 0.64.3Expected Behavior
It should track in the background with "When in use" privacy
Actual Behavior
After a certain period of time the application stops tracking
Steps to Reproduce
Context
Being able to create an iOS and Android application that tracks the activity of a person who walks, runs or rides a bicycle both on the road and on dirt roads.
In log file we found that activity tracking stops here: 02-02 14:41:42.583 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true]
Here I resumed the app: 02-02 14:47:34.370 INFO [LoggerFacade$a a]
we lost tracking from 14:41 to 14:47.
Debug logs
Logs
``` ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.1.35 (391) ╠═════════════════════════════════════════════ ╟─ HUAWEI JSN-L21 @ 9 (react-native) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow {applicationName} to access this device's location even when closed or not in use?", "message": "[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.", "positiveAction": "Change to \"{backgroundPermissionOptionLabel}\"", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -2, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": {}, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": {}, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": false, "locationAuthorizationRequest": "WhenInUse", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "", "text": "Location Service activated", "color": "", "channelName": "TSLocationManager", "smallIcon": "", "largeIcon": "", "priority": 0, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": false, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "", "useSignificantChangesOnly": false, "enabled": false, "schedulerEnabled": false, "trackingMode": 1, "odometer": 11808.599609375, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="accelerometer-bmi160", vendor="BOSCH", version=1, type=1, maxRange=78.4532, resolution=9.576806E-6, power=0.23, minDelay=4000} ╟─ ✅ GYROSCOPE: {Sensor name="bosch-bmi160", vendor="BOSCH", version=1, type=4, maxRange=34.906586, resolution=1.7453292E-5, power=6.1, minDelay=4000} ╟─ ✅ MAGNETOMETER: {Sensor name="mag-akm09918", vendor="akm", version=1001, type=2, maxRange=2000.0, resolution=0.0625, power=6.8, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="significant Motion", vendor="huawei", version=1, type=17, maxRange=2.14748365E9, resolution=1.0, power=0.23, minDelay=-1} ╚═════════════════════════════════════════════ ╔═════════════════════════════════════════════ ║ TrackingService: LocationResult ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 46******,9****** hAcc=26 et=+3d1h28m29s452ms alt=261.0 vel=0.60704195 bear=312.5772 vAcc=1 sAcc=??? bAcc=???], age: 108ms, time: 1643809295463 02-02 14:41:35.580 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════ 02-02 14:41:35.582 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 8.946 02-02 14:41:35.584 DEBUG [TSLocationManager incrementOdometer] Odometer: 11340.667 02-02 14:41:35.586 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 02-02 14:41:35.609 INFO [b persist] ✅ INSERT: 22397d68-6df4-437d-9cad-dcb52aa3f427 02-02 14:41:37.582 DEBUG [AbstractService a] 🎾 TrackingService [eventCount: 1] 02-02 14:41:37.585 DEBUG [TrackingService b] ╔═════════════════════════════════════════════ ║ TrackingService: LocationResult ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 46******,9****** hAcc=30 et=+3d1h28m31s490ms alt=261.0 vel=0.85510886 bear=317.46118 vAcc=1 sAcc=??? bAcc=???], age: 81ms, time: 1643809298000 02-02 14:41:37.587 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════ 02-02 14:41:37.588 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 9.159 02-02 14:41:37.591 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 02-02 14:41:37.597 INFO [b persist] ✅ INSERT: 24fbbe45-5946-42d5-8ddb-b7d8570cc698 02-02 14:41:38.848 DEBUG [AbstractService a] 🎾 TrackingService [eventCount: 1] 02-02 14:41:38.852 DEBUG [TrackingService b] ╔═════════════════════════════════════════════ ║ TrackingService: LocationResult ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 46******,9****** hAcc=23 et=+3d1h28m32s766ms alt=261.0 vel=0.94061583 bear=328.5504 vAcc=1 sAcc=??? bAcc=???], age: 73ms, time: 1643809298777 02-02 14:41:38.857 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 02-02 14:41:38.857 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════ 02-02 14:41:38.858 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 9.319 02-02 14:41:38.859 DEBUG [TSLocationManager incrementOdometer] Odometer: 11374.249 02-02 14:41:38.900 INFO [b persist] ✅ INSERT: 258158e7-aa0a-45c7-97b8-12ba94fd6021 02-02 14:41:39.997 DEBUG [AbstractService a] 🎾 TrackingService [eventCount: 1] 02-02 14:41:40.003 DEBUG [TrackingService b] ╔═════════════════════════════════════════════ ║ TrackingService: LocationResult ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 46******,9****** hAcc=18 et=+3d1h28m33s908ms alt=261.0 vel=1.0325823 bear=337.04288 vAcc=1 sAcc=??? bAcc=???], age: 82ms, time: 1643809299920 02-02 14:41:40.007 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════ 02-02 14:41:40.008 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 9.062 02-02 14:41:40.015 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 02-02 14:41:40.023 INFO [b persist] ✅ INSERT: 8a1604c0-b988-48d1-86cf-ef9436fca905 02-02 14:41:42.570 DEBUG [AbstractService a] 🎾 TrackingService [eventCount: 1] 02-02 14:41:42.578 DEBUG [TrackingService b] ╔═════════════════════════════════════════════ ║ TrackingService: LocationResult ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 46******,9****** hAcc=14 et=+3d1h28m36s477ms alt=261.0 vel=1.1349927 bear=343.4294 vAcc=1 sAcc=??? bAcc=???], age: 83ms, time: 1643809303000 02-02 14:41:42.583 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 02-02 14:41:42.583 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════ 02-02 14:41:42.589 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 9.749 02-02 14:41:42.593 DEBUG [TSLocationManager incrementOdometer] Odometer: 11400.761 02-02 14:41:42.625 INFO [b persist] ✅ INSERT: e9772b4f-bdc9-49bb-9ba0-e72bb8e623c4 02-02 14:47:34.370 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.1.35 (391) ╠═════════════════════════════════════════════ ╟─ HUAWEI JSN-L21 @ 9 (react-native) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow {applicationName} to access this device's location even when closed or not in use?", "message": "[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.", "positiveAction": "Change to \"{backgroundPermissionOptionLabel}\"", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -2, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": {}, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": {}, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": true, "locationAuthorizationRequest": "WhenInUse", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "", "text": "Location Service activated", "color": "", "channelName": "TSLocationManager", "smallIcon": "", "largeIcon": "", "priority": 0, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": false, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "", "useSignificantChangesOnly": false, "enabled": true, "schedulerEnabled": false, "trackingMode": 1, "odometer": 11400.7607421875, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } 02-02 14:47:34.374 INFO [TSConfig print] ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="accelerometer-bmi160", vendor="BOSCH", version=1, type=1, maxRange=78.4532, resolution=9.576806E-6, power=0.23, minDelay=4000} ╟─ ✅ GYROSCOPE: {Sensor name="bosch-bmi160", vendor="BOSCH", version=1, type=4, maxRange=34.906586, resolution=1.7453292E-5, power=6.1, minDelay=4000} ╟─ ✅ MAGNETOMETER: {Sensor name="mag-akm09918", vendor="akm", version=1001, type=2, maxRange=2000.0, resolution=0.0625, power=6.8, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="significant Motion", vendor="huawei", version=1, type=17, maxRange=2.14748365E9, resolution=1.0, power=0.23, minDelay=-1} ╚═════════════════════════════════════════════ 02-02 14:47:34.382 INFO [BackgroundGeolocation