Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System crashes us on Android 15 if foreground service runs for too long #795

Open
grote opened this issue Nov 11, 2024 · 1 comment
Open
Labels
Milestone

Comments

@grote
Copy link
Collaborator

grote commented Nov 11, 2024

--------- beginning of crash
10-23 17:27:05.674 16081 16081 E AndroidRuntime: FATAL EXCEPTION: main
10-23 17:27:05.674 16081 16081 E AndroidRuntime: Process: com.stevesoltys.seedvault, PID: 16081
10-23 17:27:05.674 16081 16081 E AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException: A foreground service of type dataSync did not stop within its timeout: ComponentInfo{com.stevesoltys.seedvault/androidx.work.impl.foreground.SystemForegroundService}
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.app.ActivityThread.generateForegroundServiceDidNotStopInTimeException(ActivityThread.java:2280)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2242)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2557)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:107)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:232)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:317)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8705)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
10-23 17:27:05.674 16081 16081 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
@grote grote added the bug label Nov 11, 2024
@grote grote added this to the Roadmap milestone Nov 11, 2024
@grote
Copy link
Collaborator Author

grote commented Nov 22, 2024

Some related docs: https://developer.android.com/about/versions/15/changes/foreground-service-types

If the timeout period is reached, the system calls the service's Service.onTimeout(int, int) method. At this time, the service has a few seconds to call Service.stopSelf(). If the service does not call Service.stopSelf(), an ANR will occur with this error message: "A foreground service of <fgs_type> did not stop within its timeout: <component_name>".

However, our workers automatically use androidx.work.impl.foreground.SystemForegroundService, so we can't fix this ourselves. Maybe there's a WorkManager bug for this upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant