react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

LocationRequestService ANR on Android 14

Open reinhardholl opened this issue 6 months ago â€ĸ 10 comments

Your Environment

  • Plugin version: 4.16.5
  • Platform: Android
  • OS version: 14
  • Device manufacturer / model: Samsung A05
  • React Native version (react-native -v): 0.68.2
  • Plugin config
await BackgroundGeolocation.ready({
            reset: true,
            desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
            params: {deviceInfo:deviceInfo,responderId:responderId,responderDeleted:responderDetails?.deleted},
            url: `${environmentConfig.locationsApiHost}/responder/location/${responderId}`,
            autoSync: true,
            distanceFilter: 200,
            autoSyncThreshold: 1,
            maxBatchSize:1,
            disableElasticity: true,
            maxRecordsToPersist:1,
            stationaryRadius: 50,
            batchSync: false,
            disableStopDetection: true,
            pausesLocationUpdatesAutomatically: false,
            headers: {"authorization": `Bearer ${token}`},
            debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
            logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
            stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
            startOnBoot: true,    // <-- Auto start tracking when device is powered-up.
            heartbeatInterval: fiveMinutes,
            disableMotionActivityUpdates: true,
            activityType: BackgroundGeolocation.ACTIVITY_TYPE_AUTOMOTIVE_NAVIGATION,
            preventSuspend: true,
            enableHeadless: true,
            notification:{
                title: "",
                text: "",
                channelName: "TSLocationManager",
                channelId: "com.aura.responder.production.TSLocationManager"
            },
            backgroundPermissionRationale: {
                title: "Allow The Aura responder App to access to this device's location in the background?",
                message: "This app collects location data to enable tracking even when the app is closed or not in use. Please enable always on location permission",
                positiveAction: "Change to always on ",
                negativeAction: "Cancel"
              }
        });

Expected Behavior

Im expecting the app to not ANR while in the foreground.

Actual Behavior

When the app is in the foreground and active I get an ANR after some time. Consistently happening but not clear pattern when.

Context

I am getting ANR's on the LocationRequestService on Android 14 while the app is in the Foreground (ie active). Background tracking is working well. This only started happening after upgrading to 4.16.5. We were on an old version prior to this 4.11.4 so I can't shed light which version introduced this for us. I have hack fixed it by doing this:

<service android:name="com.transistorsoft.locationmanager.service.LocationRequestService"
                 android:foregroundServiceType="location"
                 tools:replace="foregroundServiceType"/>

Not confident that this won't break anything else as it seems that the design of LocationRequestService is to be short lived. Is there anything that we are perhaps doing extending this runtime?

Debug logs

Logs
08-08 09:58:07.201  3944 16789 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 09:58:07.201  3944 16789 I TSLocationManager:   ℹī¸  HttpService is busy
08-08 09:58:07.203  3944  3944 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
08-08 09:58:07.203  3944  3944 I TSLocationManager:   đŸ”ĩ  Acquired current position
08-08 09:58:07.204  3944  3944 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 11.4
08-08 09:58:07.209  3944 16789 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
08-08 09:58:07.209  3944 16789 I TSLocationManager:   ✅  INSERT: c73a5968-4860-4391-a485-66cfd91e4bc4
08-08 09:58:07.213  3944 16789 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
08-08 09:58:07.213  3944 16789 D TSLocationManager:   ℹī¸  SHRINK: 1
08-08 09:58:07.217  3944 16789 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 09:58:07.217  3944 16789 I TSLocationManager:   ℹī¸  HttpService is busy
08-08 09:58:07.429  3944 16802 I TSLocationManager: [c.t.l.http.HttpService$f onResponse]
08-08 09:58:07.429  3944 16802 I TSLocationManager:   đŸ”ĩ  Response: 200
08-08 09:58:07.431  3944 16802 E TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
08-08 09:58:07.431  3944 16802 E TSLocationManager:   â€ŧī¸  DESTROY FAILURE: 883bbee4-9648-418b-83c0-8a7124c03490
08-08 09:58:07.435  3944 16802 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
08-08 09:58:07.435  3944 16802 D TSLocationManager:   ✅  Locked 1 records
08-08 09:58:07.437  3944 16802 I TSLocationManager: [c.t.l.http.HttpService a]
08-08 09:58:07.437  3944 16802 I TSLocationManager:   đŸ”ĩ  HTTP POST: c73a5968-4860-4391-a485-66cfd91e4bc4
08-08 09:58:07.442  3944 16789 I TSLocationManager: [c.t.locationmanager.rpc.a run] ⚡ī¸[RPC: setConfig: {"distanceFilter":150,"autoSyncThreshold":1,"disableElasticity":true,"maxRecordsToPersist":1,"stationaryRadius":50,"disableStopDetection":true}]
08-08 09:58:07.444  3944 16789 D TSLocationManager: [c.t.l.adapter.TSConfig e] ℹī¸   Persist config, dirty: [distanceFilter]
08-08 09:58:07.491  3944  3974 D InputTransport: Input channel destroyed: 'ClientS', fd=165
08-08 09:58:07.494  3944  3974 D InputTransport: Input channel destroyed: 'ClientS', fd=219
08-08 09:58:07.524  3944 16789 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 09:58:07.524  3944 16789 I TSLocationManager:   ℹī¸  HttpService is busy
08-08 09:58:07.614  3944 16837 D TrafficStats: tagSocket(165) with statsTag=0x2710, statsUid=-1
08-08 09:58:07.819  3944 16835 I TSLocationManager: [c.t.l.http.HttpService$f onResponse]
08-08 09:58:07.819  3944 16835 I TSLocationManager:   đŸ”ĩ  Response: 200
08-08 09:58:07.820  3944 16835 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
08-08 09:58:07.820  3944 16835 D TSLocationManager:   ✅  DESTROY: c73a5968-4860-4391-a485-66cfd91e4bc4
08-08 09:58:07.821  3944 16835 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] âŗ stopBackgroundTask: 8
08-08 09:58:07.822  3944 16789 I TSLocationManager: [c.t.locationmanager.rpc.a run] ⚡ī¸[RPC: setConfig: {"distanceFilter":150,"autoSyncThreshold":1,"disableElasticity":true,"maxRecordsToPersist":1,"stationaryRadius":50,"disableStopDetection":true}]
08-08 09:58:07.823  3944  4232 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=342703d1-5f9a-42a9-866e-b776e9af945b, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
08-08 09:58:09.936  3944  3944 I TSLocationManager: [c.t.l.l.TSLocationManager a]
08-08 09:58:09.936  3944  3944 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 09:58:09.936  3944  3944 I TSLocationManager: ║ getCurrentPosition LocationResult: 9 (3919ms old)
08-08 09:58:09.936  3944  3944 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 09:58:09.936  3944  3944 I TSLocationManager: ╟─ 📍  Location[fused -25.790858,28.304810 hAcc=2.45 et=+17m58s737ms alt=1423.3999999999999 vAcc=13.8 vel=0.5556085 sAcc=2.6 bear=53.244816 bAcc=156.8], time: 1723103886015
08-08 09:58:09.940  3944  3944 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
08-08 09:58:09.940  3944  3944 I TSLocationManager:   đŸ”ĩ  Acquired current position
08-08 09:58:09.941  3944  3944 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 2.45
08-08 09:58:09.953  3944 16789 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
08-08 09:58:09.953  3944 16789 I TSLocationManager:   ✅  INSERT: 74276d41-2820-4051-936f-43ce111244ed
08-08 09:58:09.957  3944 16789 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
08-08 09:58:09.957  3944 16789 D TSLocationManager:   ℹī¸  SHRINK: 1
08-08 09:58:09.962  3944 16789 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 09:58:09.962  3944 16789 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 09:58:09.962  3944 16789 I TSLocationManager: ║ HTTP Service (count: 1)
08-08 09:58:09.962  3944 16789 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 09:58:10.009  3944  3944 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] âŗ startBackgroundTask: 9
08-08 09:58:10.014  3944 16789 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
08-08 09:58:10.014  3944 16789 D TSLocationManager:   ✅  Locked 1 records
08-08 09:58:10.015  3944 16789 I TSLocationManager: [c.t.l.http.HttpService a]
08-08 09:58:10.015  3944 16789 I TSLocationManager:   đŸ”ĩ  HTTP POST: 74276d41-2820-4051-936f-43ce111244ed
08-08 09:58:10.352  3944 16835 I TSLocationManager: [c.t.l.http.HttpService$f onResponse]
08-08 09:58:10.352  3944 16835 I TSLocationManager:   đŸ”ĩ  Response: 200
08-08 09:58:10.353  3944 16835 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
08-08 09:58:10.353  3944 16835 D TSLocationManager:   ✅  DESTROY: 74276d41-2820-4051-936f-43ce111244ed
08-08 09:58:10.357  3944 16835 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] âŗ stopBackgroundTask: 9
08-08 09:58:10.358  3944 16789 I TSLocationManager: [c.t.locationmanager.rpc.a run] ⚡ī¸[RPC: setConfig: {"distanceFilter":150,"autoSyncThreshold":1,"disableElasticity":true,"maxRecordsToPersist":1,"stationaryRadius":50,"disableStopDetection":true}]
08-08 09:58:10.358  3944  4232 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=fa2694b3-f9a6-41c8-a551-39db21460d98, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
08-08 09:58:13.017  3944  3944 I OneSignal: Completed setting external user id: devtest-3884with results: {"push":{"success":true}}
08-08 09:58:16.756  3944 16789 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent a]
08-08 09:58:16.756  3944 16789 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 09:58:16.756  3944 16789 I TSLocationManager: ║ ⏰ OneShot event fired: TERMINATE_EVENT
08-08 09:58:16.756  3944 16789 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 09:58:16.757  3944 16789 D TSLocationManager: [c.t.l.event.TerminateEvent$a onChange]
08-08 09:58:16.757  3944 16789 D TSLocationManager:   ℹī¸  TERMINATE_EVENT ignored (MainActivity is still active).
08-08 09:58:29.380  3944 16689 W OneSignal: Location permission exists but GoogleApiClient timed out. Maybe related to mismatch google-play aar versions.
08-08 09:58:44.005  3944  4194 I Mapbox  : [threading]: Worker 4 priority is now 4
08-08 09:59:07.742  3944 16919 D TrafficStats: tagSocket(219) with statsTag=0xffffffff, statsUid=-1
08-08 10:01:07.419  3944  3944 D TSLocationManager: [c.t.l.service.AbstractService a]
08-08 10:01:07.419  3944  3944 D TSLocationManager:   🎾  5:5 [LocationRequestService  startId: 1, eventCount: 1]
08-08 10:01:07.420  3944 16953 I TSLocationManager: [c.t.l.l.TSLocationManager a]
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 10:01:07.420  3944 16953 I TSLocationManager: ║ watchPosition LocationResult: 5 (117ms old)
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╟─ 📍  Location[fused -25.790943,28.304846 hAcc=82.5 et=+21m0s24ms alt=1425.699951171875 vAcc=7.831059], time: 1723104067302
08-08 10:01:07.421  3944 16953 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 2.45
08-08 10:01:07.425  3944 16953 D TSLocationManager: [c.t.l.service.AbstractService a]
08-08 10:01:07.425  3944 16953 D TSLocationManager:   ⚙ī¸ī¸Ž   FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true]
08-08 10:01:07.425  3944 16954 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
08-08 10:01:07.425  3944 16954 I TSLocationManager:   ✅  INSERT: 134bd5de-f6b6-462f-ad1e-323a05fee973
08-08 10:01:07.427  3944 16954 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
08-08 10:01:07.427  3944 16954 D TSLocationManager:   ℹī¸  SHRINK: 1
08-08 10:01:07.428  3944 16954 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 10:01:07.428  3944 16954 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 10:01:07.428  3944 16954 I TSLocationManager: ║ HTTP Service (count: 1)
08-08 10:01:07.428  3944 16954 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 10:01:07.447  3944  3944 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] âŗ startBackgroundTask: 10
08-08 10:01:07.449  3944 16954 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
08-08 10:01:07.449  3944 16954 D TSLocationManager:   ✅  Locked 1 records
08-08 10:01:07.450  3944 16954 I TSLocationManager: [c.t.l.http.HttpService a]
08-08 10:01:07.450  3944 16954 I TSLocationManager:   đŸ”ĩ  HTTP POST: 134bd5de-f6b6-462f-ad1e-323a05fee973
08-08 10:01:07.535  3944 16956 D TrafficStats: tagSocket(177) with statsTag=0xffffffff, statsUid=-1
08-08 09:59:07.742  3944 16919 D TrafficStats: tagSocket(219) with statsTag=0xffffffff, statsUid=-1
08-08 10:01:07.419  3944  3944 D TSLocationManager: [c.t.l.service.AbstractService a]
08-08 10:01:07.419  3944  3944 D TSLocationManager:   🎾  5:5 [LocationRequestService  startId: 1, eventCount: 1]
08-08 10:01:07.420  3944 16953 I TSLocationManager: [c.t.l.l.TSLocationManager a]
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 10:01:07.420  3944 16953 I TSLocationManager: ║ watchPosition LocationResult: 5 (117ms old)
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 10:01:07.420  3944 16953 I TSLocationManager: ╟─ 📍  Location[fused -25.790943,28.304846 hAcc=82.5 et=+21m0s24ms alt=1425.699951171875 vAcc=7.831059], time: 1723104067302
08-08 10:01:07.421  3944 16953 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 2.45
08-08 10:01:07.425  3944 16953 D TSLocationManager: [c.t.l.service.AbstractService a]
08-08 10:01:07.425  3944 16953 D TSLocationManager:   ⚙ī¸ī¸Ž   FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true]
08-08 10:01:07.425  3944 16954 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
08-08 10:01:07.425  3944 16954 I TSLocationManager:   ✅  INSERT: 134bd5de-f6b6-462f-ad1e-323a05fee973
08-08 10:01:07.427  3944 16954 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
08-08 10:01:07.427  3944 16954 D TSLocationManager:   ℹī¸  SHRINK: 1
08-08 10:01:07.428  3944 16954 I TSLocationManager: [c.t.l.http.HttpService flush]
08-08 10:01:07.428  3944 16954 I TSLocationManager: ╔═════════════════════════════════════════════
08-08 10:01:07.428  3944 16954 I TSLocationManager: ║ HTTP Service (count: 1)
08-08 10:01:07.428  3944 16954 I TSLocationManager: ╠═════════════════════════════════════════════
08-08 10:01:07.447  3944  3944 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] âŗ startBackgroundTask: 10
08-08 10:01:07.449  3944 16954 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
08-08 10:01:07.449  3944 16954 D TSLocationManager:   ✅  Locked 1 records
08-08 10:01:07.450  3944 16954 I TSLocationManager: [c.t.l.http.HttpService a]
08-08 10:01:07.450  3944 16954 I TSLocationManager:   đŸ”ĩ  HTTP POST: 134bd5de-f6b6-462f-ad1e-323a05fee973
08-08 10:01:07.535  3944 16956 D TrafficStats: tagSocket(177) with statsTag=0xffffffff, statsUid=-1
08-08 10:01:08.802  3944 16956 I TSLocationManager: [c.t.l.http.HttpService$f onResponse]
08-08 10:01:08.802  3944 16956 I TSLocationManager:   đŸ”ĩ  Response: 200
08-08 10:01:08.804  3944 16956 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
08-08 10:01:08.804  3944 16956 D TSLocationManager:   ✅  DESTROY: 134bd5de-f6b6-462f-ad1e-323a05fee973
08-08 10:01:08.808  3944 16956 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] âŗ stopBackgroundTask: 10
08-08 10:01:08.810  3944  4232 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=bb6cee2a-2dcf-449d-a07b-62d41aa63ca3, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
08-08 10:01:08.810  3944 16954 I TSLocationManager: [c.t.locationmanager.rpc.a run] ⚡ī¸[RPC: setConfig: {"distanceFilter":150,"autoSyncThreshold":1,"disableElasticity":true,"maxRecordsToPersist":1,"stationaryRadius":50,"disableStopDetection":true}]
08-08 10:01:11.038  3944  3944 I ViewRootImpl@a0a0f3f[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 0
08-08 10:01:13.935  3944  3944 D InsetsSourceConsumer: applyRequestedVisibilityToControl: visible=true, type=2
08-08 10:01:13.937  3944  3944 D InsetsSourceConsumer: applyRequestedVisibilityToControl: visible=true, type=1
08-08 10:01:13.953  3944  3944 I ViewRootImpl@a0a0f3f[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 0
08-08 10:01:13.953  3944  3944 D ViewRootImpl@a0a0f3f[MainActivity]: mThreadedRenderer.initializeIfNeeded()#2 mSurface={isValid=true 0xb400006fcb77f000}
08-08 10:01:13.953  3944 16697 I ViewRootImpl@a0a0f3f[MainActivity]: mWNT: t=0xb400006fcb994c80 mBlastBufferQueue=0xb40000700a01cd00 fn= 60 caller= android.view.SyncRtSurfaceTransactionApplier.applyTransaction:96 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0:69 android.view.SyncRtSurfaceTransactionApplier.$r8$lambda$SgowXC58rj3PR958kHUfRgLZmvE:0
08-08 10:01:13.954  3944  3944 D InputMethodManagerUtils: startInputInner - Id : 0
08-08 10:01:13.954  3944  3944 I InputMethodManager: startInputInner - IInputMethodManagerGlobalInvoker.startInputOrWindowGainedFocus
08-08 10:01:13.956  3944 16669 I gralloc4: @set_metadata: update dataspace from GM (0x00000000 -> 0x08010000)
08-08 10:02:07.884  3944 17011 D TrafficStats: tagSocket(173) with statsTag=0xffffffff, statsUid=-1
08-08 10:04:17.523  3944  3970 I nder.production: Thread[2,tid=3970,WaitingInMainSignalCatcherLoop,Thread*=0xb40000708c400000,peer=0x13d00000,"Signal Catcher"]: reacting to signal 3
08-08 10:04:17.523  3944  3970 I nder.production:
08-08 10:04:17.918  3944  3970 I nder.production: Wrote stack traces to tombstoned
08-08 10:04:22.253  3944  3944 I ViewRootImpl@a0a0f3f[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 0
08-08 10:04:22.389  3944  4665 D TrafficStats: tagSocket(173) with statsTag=0x1, statsUid=-1

ANR Log

08-08 10:04:17.421  1384  1420 E ActivityManager: Short FGS ANR'ed: ServiceRecord{8f3c095 u0 com.aura.responder.production/com.transistorsoft.locationmanager.service.LocationRequestService}
08-08 10:04:17.426  1384 17032 D ActivityManager: created ANR temporary file:/data/anr/temp_anr_8696483196750313919.txt
08-08 10:04:19.307  1384 17033 D SystemDumpWriter_ANR: Successful to save dumpsys to log/dumpsys_ANR_WindowManager.txt
08-08 10:04:19.308  1384 17033 D SystemDumpWriter_ANR: save dumpsys, duration=1876
08-08 10:04:22.068  1384 17033 E ActivityManager: ANR in com.aura.responder.production
08-08 10:04:22.073  1384 17033 D ActivityManager: Completed ANR of com.aura.responder.production in 4649ms, latency 1ms
08-08 10:04:22.117  3220  3220 I DMASA[D]: [ANRDetectionService]Enqueue work to ANR
08-08 10:04:22.168  3220  3718 W DMASA[D]: [ANRDetectionService]ServiceInfo is empty

reinhardholl avatar Aug 08 '24 08:08 reinhardholl