XilinJia / Podcini

Open source podcast instrument for Android in Kotlin with media3, supporting channels, playlists, podcasts and single media from YouTube and YT Music as well as normal podcasts.
GNU General Public License v3.0
193 stars 8 forks source link

App crashes randomly during playback #52

Open rrd1 opened 5 months ago

rrd1 commented 5 months ago

Checklist

App version

5.4.1

Where did you get the app from

Other

Android version

GrapheneOS, Android 14, latest stabile version

Device model

Pixel 7

First occurred

Since this or the previous release

Steps to reproduce

Expected behaviour

App does not crash ;)

Current behaviour

Logs

        ## Environment

Android version: 14 OS version: 5.10.214-android13-4-gff787e312580 Podcini version: 5.4.1 Model: Pixel 7 Device: panther Product: panther

        ## Crash info

Time: 01-06-2024 17:19:03 Podcini version: 5.4.1

StackTrace

java.lang.IllegalStateException: Can't call init() after release() has been called
    at ac.mdiq.podcini.playback.PlaybackController.initServiceRunning(SourceFile:104)
    at ac.mdiq.podcini.playback.PlaybackController.init(SourceFile:74)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invokeSuspend(SourceFile:83)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(SourceFile:213)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(SourceFile:30)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(SourceFile:27)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:90)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(SourceFile:29)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SourceFile:392)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect(Unknown Source:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invokeSuspend(SourceFile:23)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(SourceFile:61)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(SourceFile:261)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest.flowCollect(SourceFile:21)
    at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(SourceFile:153)
    at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(Unknown Source:0)
    at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(SourceFile:56)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:104)
    at kotlinx.coroutines.EventLoop.processUnconfinedEvent(SourceFile:65)
    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(SourceFile:201)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(SourceFile:26)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(SourceFile:21)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:88)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at ac.mdiq.podcini.playback.PlaybackController.procFlowEvents(SourceFile:79)
    at ac.mdiq.podcini.playback.PlaybackController.init(SourceFile:71)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invokeSuspend(SourceFile:83)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(SourceFile:213)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(SourceFile:30)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(SourceFile:27)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:90)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(SourceFile:29)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SourceFile:392)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:12)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:104)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8532)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@9d41327, Dispatchers.Main.immediate]
rrd1 commented 5 months ago

App crashes sometimes immediately after launching it. I'm afraid the origin log was also from such situation.

Here's another one. I'll try to catch the one during playback soon.

        ## Environment

Android version: 14 OS version: 5.10.214-android13-4-gff787e312580 Podcini version: 5.4.1 Model: Pixel 7 Device: panther Product: panther

        ## Crash info

Time: 01-06-2024 22:56:49 Podcini version: 5.4.1

StackTrace

java.lang.IllegalStateException: Can't call init() after release() has been called
    at ac.mdiq.podcini.playback.PlaybackController.initServiceRunning(SourceFile:104)
    at ac.mdiq.podcini.playback.PlaybackController.init(SourceFile:74)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invokeSuspend(SourceFile:83)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(SourceFile:213)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(SourceFile:30)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(SourceFile:27)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:90)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(SourceFile:29)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SourceFile:392)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect(Unknown Source:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invokeSuspend(SourceFile:23)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(SourceFile:61)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(SourceFile:261)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest.flowCollect(SourceFile:21)
    at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(SourceFile:153)
    at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(Unknown Source:0)
    at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(SourceFile:56)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:104)
    at kotlinx.coroutines.EventLoop.processUnconfinedEvent(SourceFile:65)
    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(SourceFile:201)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(SourceFile:26)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(SourceFile:21)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:88)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at ac.mdiq.podcini.playback.PlaybackController.procFlowEvents(SourceFile:79)
    at ac.mdiq.podcini.playback.PlaybackController.init(SourceFile:71)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invokeSuspend(SourceFile:83)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at ac.mdiq.podcini.playback.PlaybackController$procFlowEvents$1$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(SourceFile:213)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(SourceFile:30)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(SourceFile:0)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(SourceFile:27)
    at kotlinx.coroutines.CoroutineStart.invoke(SourceFile:90)
    at kotlinx.coroutines.AbstractCoroutine.start(SourceFile:123)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(SourceFile:52)
    at kotlinx.coroutines.BuildersKt.launch(SourceFile:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(SourceFile:43)
    at kotlinx.coroutines.BuildersKt.launch$default(SourceFile:1)
    at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(SourceFile:29)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SourceFile:392)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:12)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:104)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8532)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@612b2a6, Dispatchers.Main.immediate]
XilinJia commented 5 months ago

Thanks for reporting. I also noticed this. It happens when starting Podcini after it has been idle for a long time. I know where this is triggered in the code, but not too sure about the underlying cause yet.

XilinJia commented 5 months ago

likely fixed in 5.4.2

rrd1 commented 5 months ago

Thanks a lot for your immediate support! I didn't faced a crash neither at startup nor during playback with the new version until now. So seem to be solved, I'll report if it happens again.

XilinJia commented 5 months ago

I'm glad it works out so far. Please report back if it happens again. I'll keep this open for sometime. Cheers.

rrd1 commented 5 months ago

Unfortunately, it happened quicker than we hoped ;) Crash during playback:

        ## Environment

Android version: 14 OS version: 5.10.214-android13-4-gff787e312580 Podcini version: 5.4.2 Model: Pixel 7 Device: panther Product: panther

        ## Crash info

Time: 04-06-2024 21:49:09 Podcini version: 5.4.2

StackTrace

android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{b69350f u10 ac.mdiq.podcini/.playback.service.PlaybackService c:ac.mdiq.podcini}
    at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2211)
    at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2182)
    at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2477)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8532)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1985)
    at android.app.ContextImpl.startForegroundService(ContextImpl.java:1939)
    at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:831)
    at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:831)
    at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(SourceFile:1189)
    at androidx.core.content.ContextCompat.startForegroundService(SourceFile:752)
    at ac.mdiq.podcini.receiver.MediaButtonReceiver.onReceive(SourceFile:33)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4674)
    at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2364)
    ... 9 more
XilinJia commented 5 months ago

That's something different. has to do with a button press. could you describe the situation?

XilinJia commented 5 months ago

This appears to be related to an open issue of Google's media3: https://github.com/androidx/media/issues/167

It can happen somewhat like (is it similar in your case?):

When you play a media and then pause it and close the app the notification remains. If you click on play button (bluetooth), after a few seconds it will crash.

That has not been fixed in two years. Will investigate about possible workaround soon.

rrd1 commented 5 months ago

I can't recall the situation for sure but could have been similar like that. It was with Bluetooth.