SchildiChat / SchildiChat-android

Matrix client / Element Android fork
https://schildi.chat/android/
Apache License 2.0
407 stars 57 forks source link

Crash when receiving call: ForegroundServiceStartNotAllowedException #133

Closed Bubu closed 1 year ago

Bubu commented 2 years ago

Describe the bug Crash when receiving call (in background) via unifiedpush.

To Reproduce Steps to reproduce the behavior: (might not work 100% of the time?)

  1. start schildichat
  2. Close the activity (swipe away from recents)
  3. Call the account from another user/server
  4. It never starts ringing
  5. Open schildi a while later -> it tells you it crashed

Expected behavior No crash, schildi starts ringing

Smartphone (please complete the following information):

Additional context

Upstream relevance

Add any other context about the problem here.

Logcat crash log:

07-05 01:41:38.032 11978 11978 E AndroidRuntime: Process: de.spiritcroc.riotx.testing.foss, PID: 11978
07-05 01:41:38.032 11978 11978 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.vector.app.core.services.CallService@9285040 with Intent { act=im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED cmp=de.spiritcroc.riotx.testing.foss/im.vector.app.core.services.CallService (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service de.spiritcroc.riotx.testing.foss/im.vector.app.core.services.CallService
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4724)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ActivityThread.access$2000(ActivityThread.java:256)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7870)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
07-05 01:41:38.032 11978 11978 E AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service de.spiritcroc.riotx.testing.foss/im.vector.app.core.services.CallService
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Parcel.readParcelable(Parcel.java:3334)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:2421)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:2410)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2393)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2335)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7155)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.Service.startForeground(Service.java:736)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at im.vector.app.core.services.CallService.handleUnexpectedState(CallService.kt:8)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at im.vector.app.core.services.CallService.onStartCommand(CallService.kt:25)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4706)
07-05 01:41:38.032 11978 11978 E AndroidRuntime:    ... 9 more

Have also sent a rageshake yesterday night.

SpiritCroc commented 2 years ago

Might fix itself with the next upstream merge, when we switch to upstreams UnifiedPush implementation :thinking:

Bubu commented 2 years ago

Still happening, just got another crash like this. Edit: Wait not, true, it's a different exception, but happening in a related circumstances:

09-15 21:04:17.380  3384  8271 E AndroidRuntime: FATAL EXCEPTION: pool-8-thread-1
09-15 21:04:17.380  3384  8271 E AndroidRuntime: Process: de.spiritcroc.riotx.testing.foss, PID: 3384
09-15 21:04:17.380  3384  8271 E AndroidRuntime: android.app.BackgroundServiceStartNotAllowedException: Not allowed to start service Intent { act=im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED cmp=de.spiritcroc.riotx.testing.foss/im.vector.app.core.services.CallAndroidService (has extras) }: app is in background uid UidRecord{e1f0fa7 u0a454 TRNB bg:+1m38s247ms idle change:procadj procs:0 seq(785123,766682)}
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1908)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at android.app.ContextImpl.startService(ContextImpl.java:1864)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at android.content.ContextWrapper.startService(ContextWrapper.java:817)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCallManager.onCallEnded(WebRtcCallManager.kt:16)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCallManager.access$onCallEnded(WebRtcCallManager.kt:1)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCallManager$createWebRtcCall$webRtcCall$4.invoke(WebRtcCallManager.kt:2)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCallManager$createWebRtcCall$webRtcCall$4.invoke(WebRtcCallManager.kt:1)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall$terminate$2.invokeSuspend(WebRtcCall.kt:18)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall$terminate$2.invoke(Unknown Source:8)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall$terminate$2.invoke(Unknown Source:4)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:1)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:10)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall.terminate(WebRtcCall.kt:1)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall.access$terminate(WebRtcCall.kt:1)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at im.vector.app.features.call.webrtc.WebRtcCall$endCall$1.invokeSuspend(WebRtcCall.kt:8)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:18)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:1012)
09-15 21:04:17.380  3384  8271 E AndroidRuntime:    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@ae7f8b6, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@55089b7]

Still need to try to reproduce the original exception though.

SpiritCroc commented 2 years ago

Didn't manage to reproduce yet. I guess push should be same to upstream now though, if I don't miss anything :thinking:

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 150 days with no activity. Remove stale label or comment or this will be closed in 14 days.