-
-
Notifications
You must be signed in to change notification settings - Fork 185
Description
tl;dr
- KeepAliveService needs to implement
onTimeoutand stop itself to prevent the whole app from crashing. - Service type of
KeepAliveServiceshould likely be changed fromdataSynctoremoteMessaging.remoteMessagingis what Molly uses and this service type does not have strict 6h per 24h quota according to the documentation.
I am running 2.25.0-foss with core 2.27.0 (self-built) on latest GrapheneOS (Android 16, I think it is the just open sourced "QPR1").
I have looked at the time of permanent notification because of #4077 and noticed that it got reset, after 10+ hours next time I looked it was only 3 h. I looked at the log and it appears the app has crashed and uptime was indeed 3 h:
uptime=3h 36m 17s
...
--------- beginning of crash
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: FATAL EXCEPTION: main
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: Process: com.b44t.messenger, PID: 4400
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException: A foreground service of type dataSync did not stop within its timeout: ComponentInfo{com.b44t.messenger/org.thoughtcrime.securesms.connect.KeepAliveService}
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.app.ActivityThread.generateForegroundServiceDidNotStopInTimeException(ActivityThread.java:2422)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2384)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2757)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.os.Looper.dispatchMessage(Looper.java:315)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:251)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.os.Looper.loop(Looper.java:349)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:9085)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:50)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
12-02 00:28:12.153 4400 4400 🔴 AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:371)
--------- beginning of system
It is a crash in KeepAliveService which apparently does not handle onTimeout. Similar problem was recently fixed for FetchForegroundService: #4018
I also now noticed that in the bugreport that was closed (#4016) crash log was also about KeepAliveService which is a permanent notification, not background fetch.
We should at least handle onTimeout in KeepAliveService and stop it on timeout. This will make permanent notification disappear, but at least not crash the app.
I also have Molly running next to Delta Chat, and it has permanent notification for 2 days already. The reason it survives longer is likely because it is not a dataSync, but android:foregroundServiceType="remoteMessaging" . dataSync and mediaProcesing foreground services have a limit of 6 hours per 24 hours according to the documentation:
https://developer.android.com/develop/background-work/services/fgs/timeout
I have a 14 hour notification already, so not clear how this actually works, but it probably makes sense to change the type to remoteMessaging anyway.