flutter_background_geolocation icon indicating copy to clipboard operation
flutter_background_geolocation copied to clipboard

App force stop in background (android 14) frequently for no reason.

Open mahdinba97 opened this issue 1 year ago • 12 comments

App crashes in the background and showing force stop dialog. Only happens in release build. No clue what could happen here.

Your Environment

  • Plugin version: 4.13.3
  • Platform: Android
  • OS version: 14
  • Device manufacturer / model: Pixel 7, Samsung A33
  • Flutter info (flutter doctor): version 3.13.1
  • Plugin config:
Config(
  desiredAccuracy: Config.DESIRED_ACCURACY_HIGH,
  geofenceModeHighAccuracy: true,
  stopOnTerminate: false,
  startOnBoot: true,
  debug: false,
  logLevel: Config.LOG_LEVEL_INFO,
  geofenceInitialTriggerEntry: false,
  persistMode: Config.PERSIST_MODE_GEOFENCE,
  distanceFilter: 200,
  elasticityMultiplier: 5,
  stopTimeout: 5,
  enableHeadless: true,
  locationAuthorizationRequest: 'Any',
  notification: Notification(
    smallIcon: 'drawable/app_icon',
  ),
  backgroundPermissionRationale: PermissionRationale(
    message: 'Template message',
  ),
),

Expected Behavior

should work fine in background and not show any errors

Actual Behavior

shows force stop dialog sometimes when in background.

Steps to Reproduce

  1. config background geolocation in the start of the app.
  2. build the app in release mode.
  3. on some condition this happens.

Context

check geofences in the app (and background)

Debug logs

logcat around the crash time

Logs
02-13 09:28:19.009  1241  2808 W AppOps  : Noting op not finished: uid 10029 pkg com.example.app code 79 startTime of in progress event=1707803831216
02-13 09:28:19.014  1241  2808 W ActivityManager: Background started FGS: Disallowed [callingPackage: com.example.app; callingUid: 10029; uidState: CEM ; uidBFSL: n/a; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:DENIED; tempAllowListReason:<null>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-13 09:28:19.014  1241  2808 W ActivityManager: startForegroundService() not allowed due to mAllowStartForeground false: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-13 09:28:19.015  1241  2808 D CompatibilityChangeReporter: Compat change id reported: 174041399; UID 10029; state: ENABLED
02-13 09:28:19.016  1241  2808 W ActivityManager: Unable to send startService intent
02-13 09:28:19.016  1241  2808 W ActivityManager: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:989)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:865)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActivityManagerService$LocalService.startServiceInPackage(ActivityManagerService.java:21224)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:754)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActivityManagerService.sendIntentSender(ActivityManagerService.java:6567)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActivityManagerService.sendIntentSender(ActivityManagerService.java:6520)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at android.app.IActivityManager$Stub.onTransact$sendIntentSender$(IActivityManager.java:12180)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4782)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3195)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at android.os.Binder.execTransactInternal(Binder.java:1375)
02-13 09:28:19.016  1241  2808 W ActivityManager: 	at android.os.Binder.execTransact(Binder.java:1311)

mahdinba97 avatar Feb 07 '24 07:02 mahdinba97

When you have a crash, the first thing to do (before posting an issue here), is fetch the stacktrace from $ adb logcat which shows exactly where, what and why,

There is always a stacktrace.

christocracy avatar Feb 07 '24 13:02 christocracy

updated logs (got it from logcat). thank you. as i have read the documents and updates that you have mentioned about using EXACT_ALARMS in android 34, but this permission needs the app to be listed as alarm app, or the core functionality need to be calendar events. which is not correct for our app, so I think we cannot call getCurrenPosition when the app is in the background? the interesting fact is that error does not show up in some phones, but happens a lot in others.

mahdinba97 avatar Feb 13 '24 10:02 mahdinba97

updated logs (got it from logcat)

You're saying your app actually crashed from that stacktrace?

christocracy avatar Feb 13 '24 13:02 christocracy

this is the only thing suspicious in logcat

mahdinba97 avatar Feb 14 '24 05:02 mahdinba97

That Exception does not cause a crash. It is harmless.

christocracy avatar Feb 14 '24 05:02 christocracy

looking for other suspicious trails in the logcat. but appears that this only happens on android 14. so, updating the issue title.

mahdinba97 avatar Feb 14 '24 06:02 mahdinba97

this is another part of the logcat which is about location provider. seems to be related?

02-13 09:23:36.968  1241  1697 E AppOps  : Could not forward noteOp of 108 to com.google.android.gms/10225(fused_location_provider)
02-13 09:23:36.968  1241  1697 E AppOps  : android.os.DeadObjectException
02-13 09:23:36.968  1241  1697 E AppOps  : 	at android.os.BinderProxy.transactNative(Native Method)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at android.os.BinderProxy.transact(BinderProxy.java:662)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.internal.app.IAppOpsAsyncNotedCallback$Stub$Proxy.opNoted(IAppOpsAsyncNotedCallback.java:118)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.lambda$collectAsyncNotedOp$3(AppOpsService.java:2928)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.$r8$lambda$j7JuBmeFuvKV9Ixgv9xHNEaV-DA(AppOpsService.java:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$$ExternalSyntheticLambda14.accept(R8$$SyntheticClass:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at android.os.RemoteCallbackList.broadcast(RemoteCallbackList.java:333)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.collectAsyncNotedOp(AppOpsService.java:2926)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationUnchecked(AppOpsService.java:2744)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationImpl(AppOpsService.java:2647)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.-$$Nest$mnoteOperationImpl(AppOpsService.java:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.$r8$lambda$-zO2p3wazaltMFolMcvKOcU7eN4(AppOpsService.java:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.policy.AppOpsPolicy.noteOperation(AppOpsPolicy.java:235)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.noteOperation(AppOpsService.java:6499)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperation(AppOpsService.java:2628)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at android.app.AppOpsManager.noteOpNoThrow(AppOpsManager.java:8521)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.injector.SystemAppOpsHelper.noteOpNoThrow(SystemAppOpsHelper.java:143)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.lambda$onReportSvStatus$2(GnssStatusProvider.java:186)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.$r8$lambda$bVLjJowpD_c4AguJpiz2DzQNnyY(GnssStatusProvider.java:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.listeners.ListenerMultiplexer.deliverToListeners(ListenerMultiplexer.java:626)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.onReportSvStatus(GnssStatusProvider.java:185)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.lambda$reportSvStatus$2(GnssNative.java:1120)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.$r8$lambda$cr9qihzlW6jEpUxoEJIvOMBxpdo(GnssNative.java:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative$$ExternalSyntheticLambda25.runOrThrow(R8$$SyntheticClass:0)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at android.os.Binder.withCleanCallingIdentity(Binder.java:462)
02-13 09:23:36.968  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.reportSvStatus(GnssNative.java:1116)
02-13 09:23:36.969  1241  1697 E AppOps  : Could not forward noteOp of 108 to com.google.android.gms/10225(network_location_provider)
02-13 09:23:36.969  1241  1697 E AppOps  : android.os.DeadObjectException
02-13 09:23:36.969  1241  1697 E AppOps  : 	at android.os.BinderProxy.transactNative(Native Method)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at android.os.BinderProxy.transact(BinderProxy.java:662)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.internal.app.IAppOpsAsyncNotedCallback$Stub$Proxy.opNoted(IAppOpsAsyncNotedCallback.java:118)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.lambda$collectAsyncNotedOp$3(AppOpsService.java:2928)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.$r8$lambda$j7JuBmeFuvKV9Ixgv9xHNEaV-DA(AppOpsService.java:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$$ExternalSyntheticLambda14.accept(R8$$SyntheticClass:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at android.os.RemoteCallbackList.broadcast(RemoteCallbackList.java:333)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.collectAsyncNotedOp(AppOpsService.java:2926)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationUnchecked(AppOpsService.java:2744)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationImpl(AppOpsService.java:2647)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.-$$Nest$mnoteOperationImpl(AppOpsService.java:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.$r8$lambda$-zO2p3wazaltMFolMcvKOcU7eN4(AppOpsService.java:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.policy.AppOpsPolicy.noteOperation(AppOpsPolicy.java:235)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.noteOperation(AppOpsService.java:6499)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperation(AppOpsService.java:2628)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at android.app.AppOpsManager.noteOpNoThrow(AppOpsManager.java:8521)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.injector.SystemAppOpsHelper.noteOpNoThrow(SystemAppOpsHelper.java:143)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.lambda$onReportSvStatus$2(GnssStatusProvider.java:186)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.$r8$lambda$bVLjJowpD_c4AguJpiz2DzQNnyY(GnssStatusProvider.java:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.listeners.ListenerMultiplexer.deliverToListeners(ListenerMultiplexer.java:626)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.onReportSvStatus(GnssStatusProvider.java:185)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.lambda$reportSvStatus$2(GnssNative.java:1120)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.$r8$lambda$cr9qihzlW6jEpUxoEJIvOMBxpdo(GnssNative.java:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative$$ExternalSyntheticLambda25.runOrThrow(R8$$SyntheticClass:0)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at android.os.Binder.withCleanCallingIdentity(Binder.java:462)
02-13 09:23:36.969  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.reportSvStatus(GnssNative.java:1116)
02-13 09:23:36.971  1241  1697 E AppOps  : Could not forward noteOp of 108 to com.google.android.gms/10225(fused_location_provider)
02-13 09:23:36.971  1241  1697 E AppOps  : android.os.DeadObjectException
02-13 09:23:36.971  1241  1697 E AppOps  : 	at android.os.BinderProxy.transactNative(Native Method)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at android.os.BinderProxy.transact(BinderProxy.java:662)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.internal.app.IAppOpsAsyncNotedCallback$Stub$Proxy.opNoted(IAppOpsAsyncNotedCallback.java:118)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.lambda$collectAsyncNotedOp$3(AppOpsService.java:2928)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.$r8$lambda$j7JuBmeFuvKV9Ixgv9xHNEaV-DA(AppOpsService.java:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$$ExternalSyntheticLambda14.accept(R8$$SyntheticClass:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at android.os.RemoteCallbackList.broadcast(RemoteCallbackList.java:333)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.collectAsyncNotedOp(AppOpsService.java:2926)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationUnchecked(AppOpsService.java:2744)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperationImpl(AppOpsService.java:2647)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.-$$Nest$mnoteOperationImpl(AppOpsService.java:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.$r8$lambda$-zO2p3wazaltMFolMcvKOcU7eN4(AppOpsService.java:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.policy.AppOpsPolicy.noteOperation(AppOpsPolicy.java:235)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.noteOperation(AppOpsService.java:6499)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.appop.AppOpsService.noteOperation(AppOpsService.java:2628)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at android.app.AppOpsManager.noteOpNoThrow(AppOpsManager.java:8521)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.injector.SystemAppOpsHelper.noteOpNoThrow(SystemAppOpsHelper.java:143)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.lambda$onReportSvStatus$2(GnssStatusProvider.java:186)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.$r8$lambda$bVLjJowpD_c4AguJpiz2DzQNnyY(GnssStatusProvider.java:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider$$ExternalSyntheticLambda3.apply(R8$$SyntheticClass:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.listeners.ListenerMultiplexer.deliverToListeners(ListenerMultiplexer.java:626)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.GnssStatusProvider.onReportSvStatus(GnssStatusProvider.java:185)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.lambda$reportSvStatus$2(GnssNative.java:1120)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.$r8$lambda$cr9qihzlW6jEpUxoEJIvOMBxpdo(GnssNative.java:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative$$ExternalSyntheticLambda25.runOrThrow(R8$$SyntheticClass:0)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at android.os.Binder.withCleanCallingIdentity(Binder.java:462)
02-13 09:23:36.971  1241  1697 E AppOps  : 	at com.android.server.location.gnss.hal.GnssNative.reportSvStatus(GnssNative.java:1116)

mahdinba97 avatar Feb 14 '24 09:02 mahdinba97

None of that stacktrace references com.transistorsoft. I have no insight on that.

christocracy avatar Feb 14 '24 13:02 christocracy

@christocracy I have the same exact issue on more recent androids and the logs report ANR from com.transistorsoft.locationmanager.service.GeofencingService

Here's related the logcat (I have replace the app package name with com.example.app):

02-20 21:55:52.830  1570  1690 E ActivityManager: Short FGS timed out: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:55:57.830  1570  1690 E ActivityManager: Short FGS procstate demoted: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:02.830  1570  1690 E ActivityManager: Short FGS ANR'ed: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:17.203  1570 31728 E ActivityManager: ANR in com.example.app
02-20 21:56:17.203  1570 31728 E ActivityManager: Reason: A foreground service of FOREGROUND_SERVICE_TYPE_SHORT_SERVICE did not stop within a timeout: ComponentInfo{com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:17.208  1570 31728 D ActivityManager: Completed ANR of com.example.app in 14376ms, latency 1ms
02-20 21:56:17.284  1570  1669 D CoreBackPreview: Window{c2cd9e5 u0 Application Not Responding: com.example.app}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.WindowOnBackInvokedDispatcher$OnBackInvokedCallbackWrapper@ce928e3, mPriority=0, mIsAnimationCallback=false}
02-20 21:56:18.809  1570  1669 I ActivityManager: Killing 27811:com.example.app/u0a420 (adj 200): user request after error
02-20 21:56:18.810  1570  1669 D CoreBackPreview: Window{c2cd9e5 u0 Application Not Responding: com.example.app}: Setting back callback null
02-20 21:56:18.907  1570  4350 W ActivityManager: Scheduling restart of crashed service com.example.app/com.transistorsoft.locationmanager.service.TrackingService in 1122344ms for start-requested
02-20 21:56:18.907  1570  4350 W ActivityManager: Scheduling restart of crashed service com.example.app/com.transistorsoft.tsbackgroundfetch.FetchJobService in 1000ms for connection
02-20 21:56:18.907  1570  4350 W ActivityManager: Short FGS brought down without stopping: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
Rest of the logs

If you want to see what was happening before and after the crash, here's the rest of the logs:

02-20 21:46:56.945  1570  4087 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708425688168
02-20 21:46:56.982  1570  4087 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: TRNB; uidBFSL: n/a; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:ACTIVITY_RECOGNITION; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:46:57.226  1570  2981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:46:57.236  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:46:57.378  1570  3248 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:46:57.405  1570  2981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:46:57.412  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:46:57.416  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:46:57.416  1570  3248 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:46:57.719  1570  2981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:46:57.720  1570  2981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:46:57.730  1570  4356 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:46:57.733  1570  4659 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.TrackingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:46:57.739  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:46:57.754  1570  4659 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:46:57.754  1570  4659 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:46:57.767  1570  4659 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.TrackingService
02-20 21:46:57.775  1570  2981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.TrackingService
02-20 21:46:59.788  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:46:59.798  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:46:59.799  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:46:59.816  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:47:06.419  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:47:51.630  1570  3248 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426016989
02-20 21:47:51.637  1570  4659 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:47:51.654  1570  4659 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:47:51.668  1570  4356 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:47:51.683  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:47:51.683  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:47:51.699  1570  2441 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:47:51.807  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426016989
02-20 21:47:51.814  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:47:51.836  1570  3248 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426071835
02-20 21:47:51.841  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:48:48.916  1570  1979 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426071835
02-20 21:48:48.925  1570  1979 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:48:48.952  1570  1979 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:48:48.958  1570  3215 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:48:49.017  1570  3215 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:48:49.039  1570  3215 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:48:49.048  1570  3215 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:48:49.062  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:48:49.062  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:48:49.266  1570  4353 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:48:49.274  1570  1979 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:48:49.297  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:48:49.301  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:48:49.301  1570  2441 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:48:51.514  1570  2981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:48:51.547  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:48:51.547  1570  3248 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:48:51.562  1570  1979 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:48:58.306  1570  1979 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:49:17.042  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426071835
02-20 21:49:17.072  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:49:17.102  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:49:17.112  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:49:17.139  1570  2981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:49:17.140  1570  2981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:49:17.197  1570  4353 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:49:17.307  1570  3215 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426071835
02-20 21:49:17.311  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:49:17.334  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426157333
02-20 21:49:17.340  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:50:42.825  1570  2981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426157333
02-20 21:50:42.854  1570  2981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:50:42.878  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:50:42.916  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:50:42.947  1570  4087 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:50:42.953  1570  4087 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:50:42.961  1570  2981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:50:42.965  1570  4087 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:50:42.965  1570  4087 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:50:43.254  1570  4087 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:50:43.270  1570  2441 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:50:43.274  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:50:43.278  1570  4087 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:50:43.278  1570  4087 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:50:43.288  1570  2441 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:50:43.304  1570  3215 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:50:43.304  1570  3215 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:50:43.319  1570  4087 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:50:45.452  1570  4331 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:51:28.161  1570  2029 I JobServiceContext: Client timed out while executing (no jobFinished received). Sending onStop: a44f0f7 #u0a420/999 com.example.app/com.transistorsoft.tsbackgroundfetch.FetchJobService
02-20 21:51:28.189  1570  4353 W CountQuotaTracker: <0>com.example.app::timeout-total has reached 80% of it's count limit of 10
02-20 21:52:17.286  1570  1981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426157333
02-20 21:52:17.308  1570  1981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:52:17.329  1570  1979 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:17.352  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:17.399  1570  1593 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:52:17.399  1570  1593 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:52:17.421  1570  1979 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:52:17.505  1570  1593 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426157333
02-20 21:52:17.510  1570  2441 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:17.526  1570  4353 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426337525
02-20 21:52:17.531  1570  4353 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:52.356  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426337525
02-20 21:52:52.362  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:52:52.372  1570  3499 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:52.376  1570  4351 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:52:52.424  1570  1593 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:52:52.434  1570  4353 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:52:52.440  1570  4351 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:52:52.445  1570  4356 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:52:52.445  1570  4356 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:52:52.771  1570  4353 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:52:52.774  1570  1979 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:52:52.798  1570  3323 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:52:52.798  1570  3323 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:52:52.803  1570  1981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:52:52.812  1570  4310 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:52:52.829  1570  1979 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:52:52.829  1570  1979 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:52:52.838  1570  1979 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 21:52:58.372  1570  4665 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426016989
02-20 21:55:52.830  1570  1690 E ActivityManager: Short FGS timed out: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:55:57.830  1570  1690 E ActivityManager: Short FGS procstate demoted: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:02.830  1570  1690 E ActivityManager: Short FGS ANR'ed: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:17.203  1570 31728 E ActivityManager: ANR in com.example.app
02-20 21:56:17.203  1570 31728 E ActivityManager: Reason: A foreground service of FOREGROUND_SERVICE_TYPE_SHORT_SERVICE did not stop within a timeout: ComponentInfo{com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:56:17.208  1570 31728 D ActivityManager: Completed ANR of com.example.app in 14376ms, latency 1ms
02-20 21:56:17.284  1570  1669 D CoreBackPreview: Window{c2cd9e5 u0 Application Not Responding: com.example.app}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.WindowOnBackInvokedDispatcher$OnBackInvokedCallbackWrapper@ce928e3, mPriority=0, mIsAnimationCallback=false}
02-20 21:56:18.809  1570  1669 I ActivityManager: Killing 27811:com.example.app/u0a420 (adj 200): user request after error
02-20 21:56:18.810  1570  1669 D CoreBackPreview: Window{c2cd9e5 u0 Application Not Responding: com.example.app}: Setting back callback null
02-20 21:56:18.907  1570  4350 W ActivityManager: Scheduling restart of crashed service com.example.app/com.transistorsoft.locationmanager.service.TrackingService in 1122344ms for start-requested
02-20 21:56:18.907  1570  4350 W ActivityManager: Scheduling restart of crashed service com.example.app/com.transistorsoft.tsbackgroundfetch.FetchJobService in 1000ms for connection
02-20 21:56:18.907  1570  4350 W ActivityManager: Short FGS brought down without stopping: ServiceRecord{815a515 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 21:57:02.406  1570  1692 I ActivityManager: Start proc 31803:com.example.app/u0a420 for service {com.example.app/com.transistorsoft.tsbackgroundfetch.FetchJobService}
02-20 21:57:02.691  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.TrackingService
02-20 21:57:02.697  1570  4331 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.TrackingService
02-20 21:57:03.677  1570  4356 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 21:57:03.705  1570  3248 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:57:03.714  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:57:03.720  1570  4665 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:57:03.720  1570  4665 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:57:59.654  1570  4328 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426622646
02-20 21:57:59.677  1570  4328 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 21:57:59.699  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:57:59.714  1570  3248 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:57:59.751  1570  4328 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 21:57:59.752  1570  4328 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 21:57:59.790  1570  3248 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 21:57:59.903  1570  2303 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426622646
02-20 21:57:59.907  1570  2303 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 21:57:59.944  1570  4328 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708426679942
02-20 21:57:59.950  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService

Another crash log Here's another crash log which happened 30 minutes after previous one:
02-20 22:30:42.555  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708428493334
02-20 22:30:42.583  1570  3499 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 22:30:42.618  1570  3215 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:30:42.631  1570  4088 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:30:42.667  1570  1594 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 22:30:42.690  1570  4088 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 22:30:42.706  1570  1594 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 22:30:42.715  1570  1981 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 22:30:42.715  1570  1981 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 22:30:45.205  1570  3499 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 22:30:45.208  1570  1981 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 22:30:45.225  1570  3323 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 22:30:45.234  1570  3323 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 22:30:45.240  1570  4310 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 22:30:45.240  1570  4310 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 22:30:45.246  1570  3323 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 22:30:45.246  1570  3323 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { act=start cmp=com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:LOCATION_PROVIDER,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 22:30:45.261  1570  3323 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.LocationRequestService
02-20 22:30:51.887  1570  4088 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 22:33:45.243  1570  1690 E ActivityManager: Short FGS timed out: ServiceRecord{fc5f723 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 22:33:50.241  1570  1690 E ActivityManager: Short FGS procstate demoted: ServiceRecord{fc5f723 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 22:33:55.242  1570  1690 E ActivityManager: Short FGS ANR'ed: ServiceRecord{fc5f723 u0 com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 22:33:58.541  1570  8637 E ActivityManager: ANR in com.example.app
02-20 22:33:58.541  1570  8637 E ActivityManager: Reason: A foreground service of FOREGROUND_SERVICE_TYPE_SHORT_SERVICE did not stop within a timeout: ComponentInfo{com.example.app/com.transistorsoft.locationmanager.service.GeofencingService}
02-20 22:33:58.544  1570  8637 D ActivityManager: Completed ANR of com.example.app in 3301ms, latency 1ms
02-20 22:33:58.574  1570  1669 D CoreBackPreview: Window{8099b8b u0 Application Not Responding: com.example.app}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.WindowOnBackInvokedDispatcher$OnBackInvokedCallbackWrapper@d7f103, mPriority=0, mIsAnimationCallback=false}
02-20 22:34:07.596  1570  1669 D CoreBackPreview: Window{8099b8b u0 Application Not Responding: com.example.app}: Setting back callback null
02-20 22:34:43.089  1570  4657 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708428493334
02-20 22:34:43.095  1570  4657 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 22:34:43.106  1570  4657 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:34:43.118  1570  4661 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:34:43.135  1570  4651 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.GeofencingService
02-20 22:34:43.135  1570  4651 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.GeofencingService }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:1; bindFromPackage:null: isBindService:false] (Called on SHORT_SERVICE)
02-20 22:34:43.158  1570  4661 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 1 startTime of in progress event=1708426622646
02-20 22:34:43.378  1570  4665 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708428493334
02-20 22:34:43.389  1570  4665 I ActivityManager: Background started FGS: Allowed [callingPackage: com.example.app; callingUid: 10420; uidState: FGS ; uidBFSL: [BFSL]; intent: Intent { cmp=com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService (has extras) }; code:PROC_STATE_FGS; tempAllowListReason:<null,reasonCode:ACTIVITY_RECOGNITION,duration:20000,callingUid:10160>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]
02-20 22:34:43.398  1570  4651 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:34:43.407  1570  4665 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService
02-20 22:34:43.438  1570  4661 W AppOps  : Noting op not finished: uid 10420 pkg com.example.app code 79 startTime of in progress event=1708428883435
02-20 22:34:43.445  1570  3215 W ActivityManager: Foreground service started from background can not have location/camera/microphone access: service com.example.app/com.transistorsoft.locationmanager.service.ActivityRecognitionService

mahdi-ninja avatar Feb 20 '24 11:02 mahdi-ninja

Android 14 has introduced radical new restrictions on the operation of foreground services (which this plug-in relies heavily upon).

I do not have any issues with interrupted tracking in the /example app, which I field test almost daily.

@mahdi-ninja you need to provide far more information and code (see the original post for required info)

christocracy avatar Feb 20 '24 14:02 christocracy

@christocracy

Here's more information and code. What else do you need?

Environment

  • Plugin version:4.13.5

  • Platform: Android

  • OS version: 14

  • Device manufacturer / model: Pixel 8, Pixel 7, Samsung Galaxy S23

  • Flutter info (flutter doctor): [✓] Flutter (Channel stable, 3.16.9, on macOS 14.3.1 23D60 darwin-arm64, locale en-AU) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] VS Code (version 1.86.2) [✓] Connected device (4 available) [✓] Network resources

  • Plugin config:

  Future<void> configureService() async {
    try {
      BackgroundGeolocation.onGeofence(onGeofenceEvent);
      BackgroundGeolocation.onMotionChange(onMotionChange);

      await BackgroundGeolocation.ready(
        Config(
          startOnBoot: true,
          stopOnTerminate: false,
          logLevel: await _getLogLevel(),
          geofenceModeHighAccuracy: true,
          desiredAccuracy: Config.DESIRED_ACCURACY_HIGH,
          enableHeadless: true,
          locationAuthorizationRequest: 'Any',
        ),
      );
    } catch (ex) {
      print(ex);
    }
  }


  Future<bool> ensureServiceIsStarted() async {
    if (!PlatformConfigs.enabledGeofence) return true;
    final isTrackingEnabled = await isEnabledTracking();
    final state = await BackgroundGeolocation.state;
    if (isTrackingEnabled == true) {
      if (state.enabled) {
        return true;
      }

      for (int retries = 0; retries < 5; retries++) {
        try {
          if (retries != 0) await Future.delayed(const Duration(seconds: 2));

          final newState = await BackgroundGeolocation.startGeofences();
          return newState.enabled;
        } catch (e) {
          print(e);
          Utility.backgroundGeolocationLog(
            e.toString(),
            isError: true,
          );
        }
      }
      return false;
    } else {
      if (state.enabled) await BackgroundGeolocation.stop();
      return true;
    }
  }

mahdi-ninja avatar Feb 22 '24 07:02 mahdi-ninja

BackgroundGeolocation.onGeofence(onGeofenceEvent); BackgroundGeolocation.onMotionChange(onMotionChange);

You need to show all code, including the code of your event-handlers, not just the function names.

christocracy avatar Feb 22 '24 14:02 christocracy

Hey @christocracy Here's the suspicious part (note the sticky: true):

02-24 20:28:32.873 DEBUG [AbstractService a] 
  🎾  start [GeofencingService  startId: 3, eventCount: 1]
02-24 20:28:32.874 DEBUG [AbstractService a] 
  ⚙️︎   FINISH [GeofencingService startId: 3, eventCount: 0, sticky: true]
02-24 20:28:32.878 DEBUG [AbstractService a] 
  🎾  1:4 [LocationRequestService  startId: 4, eventCount: 1]

mahdi-ninja avatar Feb 29 '24 20:02 mahdi-ninja

Try this branch: I simply changed the foregroundServiceType of the GeofencingService from shortService -> location in the plugin's AndroidManifest:

Install from branch GeofencingService-foregroundServiceType

📂 pubspec.yaml:

dependencies:
  flutter_background_geolocation:
    git:
      url: https://github.com/transistorsoft/flutter_background_geolocation.git
      ref: GeofencingService-foregroundServiceType

christocracy avatar Feb 29 '24 20:02 christocracy

Have you tested this branch yet?

christocracy avatar Mar 07 '24 15:03 christocracy

Hey @christocracy Thanks for the update. We've been testing it for the last few days and it's been working fine. Just wanted to do some broader testing before confirming that the issue is fully resolved. But so far, it looks good. Thanks again!

mahdi-ninja avatar Mar 07 '24 22:03 mahdi-ninja

@christocracy That change fixed the ANR issue but it doesn't execute the headless task function in my code. Here's how I register my task:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await App.init();

  runApp(MyApp());

  bg.BackgroundGeolocation.registerHeadlessTask(headlessTask);
}

// ignore: avoid_void_async
void headlessTask(bg.HeadlessEvent headlessEvent) async {
  bg.Logger.info('[BackgroundGeolocation HeadlessTask]: $headlessEvent');

  switch (headlessEvent.name) {
    case bg.Event.MOTIONCHANGE:
      await App.kiwiContainer<GeofenceService>().onMotionChange(headlessEvent.event);
      break;
    case bg.Event.GEOFENCE:
      await App.kiwiContainer<GeofenceService>().onGeofenceEvent(headlessEvent.event);
      break;
  }
}

When I run the code on Android 14, in headless mode, here's the log that I get:

03-11 13:19:52.241 DEBUG [AbstractService a] 
  🎾  start [GeofencingService  startId: 22, eventCount: 1]
03-11 13:19:52.289 INFO [GeofencingService a] 
╔═════════════════════════════════════════════
║ Geofencing Event: EXIT
╠═════════════════════════════════════════════
╟─ 222
╚═════════════════════════════════════════════
03-11 13:19:52.303 DEBUG [HeadlessTask onHeadlessEvent] 💀 [HeadlessTask location]
03-11 13:19:52.306 INFO [SQLiteLocationDAO persist] 
  ✅  INSERT: e6af250f-f782-41ed-a13b-36f87a5bd61f
03-11 13:19:52.307 DEBUG [AbstractService a] 
  ⚙️︎   FINISH [GeofencingService startId: 22, eventCount: 0, sticky: true]
03-11 13:19:52.309 DEBUG [HeadlessTask onHeadlessEvent] 💀 [HeadlessTask geofence]
03-11 13:20:02.276 DEBUG [AbstractService a] 
  🎾  start [GeofencingService  startId: 23, eventCount: 1]
03-11 13:20:02.278 INFO [GeofencingService a] 

There's no trace of the log that I've added at the start of the headlessTask function (i.e. bg.Logger.info('[BackgroundGeolocation HeadlessTask]: $headlessEvent') )

mahdi-ninja avatar Mar 11 '24 07:03 mahdi-ninja

See API docs Config.enableHeadless

Why did you not add @pragma('vm:entry-point') above your function, as directed?

Screenshot 2024-03-11 at 11 41 58 AM

christocracy avatar Mar 11 '24 15:03 christocracy

Thanks @christocracy. You're right, the problem was just @pragma('vm:entry-point') which was missing after the upgrade.

So, looks like the issue is fully resolved in Android 14. Thanks again.

Are you going to publish a new release soon with this fix or should I just use the GeofencingService-foregroundServiceType branch for now?

mahdi-ninja avatar Mar 12 '24 03:03 mahdi-ninja

Are you going to publish a new release soon

I'll publish when you let me know that you're satisfied.

christocracy avatar Mar 12 '24 04:03 christocracy

Are you going to publish a new release soon

I'll publish when you let me know that you're satisfied.

I am! It is working perfectly fine now. Thanks again!

mahdi-ninja avatar Mar 12 '24 09:03 mahdi-ninja

It's published to 4.14.1

christocracy avatar Mar 12 '24 15:03 christocracy

Should this fix also apply to react-native-background-geolocation in 4.14.1 as well?

I am still getting the below ANR on Android 14 on 4.16.0:

ANR in com.vehotechnologies.DriverDevelop
PID: 30567
Reason: A foreground service of FOREGROUND_SERVICE_TYPE_SHORT_SERVICE did not stop within a timeout: ComponentInfo{com.mycompany.MyApp/com.transistorsoft.locationmanager.service.LocationRequestService}
ErrorId: c11a4216-c4ed-4495-a54b-0dd520c4a5c9
Frozen: false
Load: 4.26 / 3.82 / 3.69

spsaucier avatar Apr 03 '24 16:04 spsaucier

Should this fix also apply to react-native-background-geolocation in 4.14.1 as well?

The fix was applied to the GeofencingService. Your error comes from LocationRequestService, which by design is for short periods of time (eg .getCurrentPosition:

christocracy avatar Apr 03 '24 17:04 christocracy

Should this fix also apply to react-native-background-geolocation in 4.14.1 as well?

I am still getting the below ANR on Android 14 on 4.16.0:

ANR in com.vehotechnologies.DriverDevelop
PID: 30567
Reason: A foreground service of FOREGROUND_SERVICE_TYPE_SHORT_SERVICE did not stop within a timeout: ComponentInfo{com.mycompany.MyApp/com.transistorsoft.locationmanager.service.LocationRequestService}
ErrorId: c11a4216-c4ed-4495-a54b-0dd520c4a5c9
Frozen: false
Load: 4.26 / 3.82 / 3.69

We are also seeing this ANR in Android 14 on 4.16.5 of the react-native-background-geolocation plugin. (I can also log the issue there, this was just related so wanted to keep context). This ANR happens while the app is open and not when it's killed.

Details of our ANR:

08-06 20:59:01.903  1380  1411 E ActivityManager: Short FGS ANR'ed: ServiceRecord{fd2504e u0 **/com.transistorsoft.locationmanager.service.LocationRequestService}
08-06 20:59:01.906  1380  5419 D ActivityManager: created ANR temporary file:/data/anr/temp_anr_7904267466455187307.txt
08-06 20:59:03.497  1380  5421 D SystemDumpWriter_ANR: Successful to save dumpsys to log/dumpsys_ANR_WindowManager.txt
08-06 20:59:03.498  1380  5421 D SystemDumpWriter_ANR: save dumpsys, duration=1590
08-06 20:59:05.968  1380  5421 E ActivityManager: ANR in **
08-06 20:59:05.972  1380  5421 D ActivityManager: Completed ANR of ** in 4067ms, latency 1ms

reinhardholl avatar Aug 06 '24 19:08 reinhardholl