Frequently crashes in the background.
How To Reproduce
#!/system/bin/sh
adb shell input KEYCODE_HOME && \
sleep 5400
Outcome
What Was Expected
No crashes.
What Occurred Instead
FATAL EXCEPTION: main Process: im.vector.app, PID: 594 java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@ba7286d with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.fdroid.service.GuardAndroidService at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4840) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2290) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8223) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:977) Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.fdroid.service.GuardAndroidService at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54) at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50) at android.os.Parcel.readParcelableInternal(Parcel.java:4870) at android.os.Parcel.readParcelable(Parcel.java:4852) at android.os.Parcel.createExceptionOrNull(Parcel.java:3052) at android.os.Parcel.createException(Parcel.java:3041) at android.os.Parcel.readException(Parcel.java:3024) at android.os.Parcel.readException(Parcel.java:2966) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761) at android.app.Service.startForeground(Service.java:775) at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(GuardAndroidService.kt:15) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4822) ... 9 more
This may relate to doublesymmetry/react-native-track-player/issues/2231.
Frequency Of Occurrence
The undermentioned screenshot demonstrates the frequency of these recurrences:
Hardware
[ro.product.brand]: [Fairphone] [ro.build.product]: [FP5]
OS Version
[ro.build.version.release]: [14] [ro.build.display.id]: [FP5.UT27.B.059.20240809]
Application Version And Origin
sourcePackage=im.vector.app versionCode=40106182
...from f-droid.org/repo/im.vector.app_40106182.apk.
Homeserver
Will you send logs?
Yes
Are you willing to provide a PR?
No
Im also affected by this, or at least something similar.
The only pattern I've seen is that these occur when I haven't used my phone in a while. Unfortunately it's difficult to pinpoint more specifically. I have excluded battery optimisation for Element, but it's made no discernible difference.
Phone: Pixel 7 OS: GrapheneOS Android version: 16
Logs:
...
--------- switch to crash
09-28 04:32:13.853 20593 20593 E AndroidRuntime: FATAL EXCEPTION: main
09-28 04:32:13.853 20593 20593 E AndroidRuntime: Process: im.vector.app, PID: 20593
09-28 04:32:13.853 20593 20593 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@af39a63 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5505)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2656)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:248)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Looper.loop(Looper.java:338)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:9106)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:50)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:371)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.readParcelableInternal(Parcel.java:5235)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.readParcelable(Parcel.java:5217)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:3344)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:3333)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:3309)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:3251)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7312)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.Service.startForeground(Service.java:778)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5487)
09-28 04:32:13.853 20593 20593 E AndroidRuntime: ... 11 more
...
I also see this on Element from F-Droid.
Phone: Pixel 6 OS: LineageOS microG Android version: 15
Same on Pixel 7a on lineageos+microg on android 15
@thiswillbeyourgithub, do you mention MicroG because your im.vector.app installation's installerPackageName is com.android.vending?
@RokeJulianLockhart just to clarify: i couldn't find the crash logs so I'm reporting the same symptoms but don't know if the bug is the exact same as OP. I mentionned microg because I never know if that's relevant. I have no idea what you mean by your question I'm sorry. If you clarify or walk me through i'm happy to help though!
i couldn't find the crash logs so I'm reporting the same symptoms but don't know if the bug is the exact same as OP
@thiswillbeyourgithub, you'll find the logs in adb logcat --buffer=crash, especially if you then | grep im.vector.app. However, solely insofar as the crash occurred after the most recent reboot.
I have no idea what you mean by your question I'm sorry. If you clarify or walk me through i'm happy to help though!
Apologies. I should have asked: “Where did you install Element from? Aurora Store, or F-Droid?”
Thanks a lot for the follow up. Here is the logcat output using adb logcat --buffer=crash | grep im.vector.app:
12-04 04:29:47.152 23914 23914 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@bad4525 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-04 04:29:47.152 23914 23914 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-04 05:59:47.938 6322 6322 E AndroidRuntime: Process: im.vector.app, PID: 6322
12-04 05:59:47.938 6322 6322 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@7e527d8 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-04 05:59:47.938 6322 6322 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-04 06:27:40.604 16905 16905 E AndroidRuntime: Process: im.vector.app, PID: 16905
12-04 06:27:40.604 16905 16905 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@4435b69 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-04 06:27:40.604 16905 16905 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-04 06:27:59.446 17564 17564 E AndroidRuntime: Process: im.vector.app, PID: 17564
12-04 06:27:59.446 17564 17564 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@f565b52 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-04 06:27:59.446 17564 17564 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-05 05:11:46.146 4591 4591 E AndroidRuntime: Process: im.vector.app, PID: 4591
12-05 05:11:46.146 4591 4591 E AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException: A foreground service of type dataSync did not stop within its timeout: ComponentInfo{im.vector.app/im.vector.app.fdroid.service.GuardAndroidService}
12-05 05:11:47.931 15648 15648 E AndroidRuntime: Process: im.vector.app, PID: 15648
12-05 05:11:47.931 15648 15648 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@a70e984 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-05 05:11:47.931 15648 15648 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-05 05:16:03.887 22326 22326 E AndroidRuntime: Process: im.vector.app, PID: 22326
12-05 05:16:03.887 22326 22326 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@2ebbe8f with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-05 05:16:03.887 22326 22326 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14
)
12-05 05:19:55.603 28597 28597 E AndroidRuntime: Process: im.vector.app, PID: 28597
12-05 05:19:55.603 28597 28597 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@4435b69 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
12-05 05:19:55.603 28597 28597 E AndroidRuntime: at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(SourceFile:14)
12-05 05:26:02.098 8962 8962 E AndroidRuntime: Process: im.vector.app, PID: 8962
12-05 05:26:02.098 8962 8962 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@4435b69 with null: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground s
I installed it through F-Droid.
@thiswillbeyourgithub, those are very corrupt traces. I presume due to what F0x1d/LogFox/issues/178#issuecomment-3457827589 cites. Your application, therefore, appears to be crashing significantly more frequently than mine is! That is, based upon the timestamps, unless you manually duplicated solely the head of each trace? No worries if so; they're not important.
Well no the app is actually pretty unreliable when in the background. Like I know that 100% of the time I leave it in the background I expect to at some point later have to manually re launch the app.
Edit: and it is set to unrestricted background battery usage
100% of the time I leave it in the background I expect to at some point later have to manually re launch the app.
@thiswillbeyourgithub, that could be due to what issuetracker.google.com/issues/205156966#comment134 (that URI requires some time to load) cites, if it affects your device, too.
Does that mean there's no possible fix? I'm rooted if that helps.
@thiswillbeyourgithub, I solely see what upstream changes FPOS incorporates, after AOSP's source is released. Considering that Google's issue tracking isn't stellar, combined with that, we'll likely know after A16's general release. However, this can be worked around, to an extent, by the developer, and the user can add the application to the deviceidle whitelist (per dumpsys).
Having superuser access likely means that you can more granularly control this, but IDK.