livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
190 stars 77 forks source link

There is a crash while connect to room #527

Closed tombang closed 6 hours ago

tombang commented 2 weeks ago

Describe the bug There is a crash while connect to room

To Reproduce Steps to reproduce the behavior: While connect to the room, there is a chance of encountering the following crash:

--------- beginning of crash 10-28 14:27:33.264 3604 3604 E AndroidRuntime: FATAL EXCEPTION: main 10-28 14:27:33.264 3604 3604 E AndroidRuntime: Process: com.tcl.robot.server:remote, PID: 3604 10-28 14:27:33.264 3604 3604 E AndroidRuntime: java.lang.UnsupportedOperationException: Cannot create AudioTrack 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.media.AudioTrack$Builder.build(AudioTrack.java:1390) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl.buildAudioTrack(CommunicationWorkaround.kt:165) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl.playAudioTrackIfNeeded(CommunicationWorkaround.kt:179) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl.onStateChanged(CommunicationWorkaround.kt:138) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl.access$onStateChanged(CommunicationWorkaround.kt:81) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl$1$2.invokeSuspend(CommunicationWorkaround.kt:103) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl$1$2.invoke(Unknown Source:8) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at io.livekit.android.audio.CommunicationWorkaroundImpl$1$2.invoke(Unknown Source:4) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKtMergeKt$mapLatest$1.invokeSuspend(Merge.kt:217) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKtMergeKt$mapLatest$1.invoke(Unknown Source:13) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKtMergeKt$mapLatest$1.invoke(Unknown Source:4) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:34) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:8) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:4) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:44) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.BuildersKtBuilders_commonKt.launch(Builders.common.kt:56) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:33) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.DistinctFlowImpl$collect$2.emit(Distinct.kt:77) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKtZipKt$combine$1$1.invokeSuspend(Zip.kt:33) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKtZipKt$combine$1$1.invoke(Unknown Source:13) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$1$1.invoke(Unknown Source:6) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:76) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7964) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942) 10-28 14:27:33.264 3604 3604 E AndroidRuntime: Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@15fa31f, Dispatchers.Main]

Expected behavior no crash

Screenshots If applicable, add screenshots to help explain your problem.

Device Info:

davidliu commented 1 day ago

Can you provide logs surrounding this crash? There's likely extra logs leading up to this explaining why it couldn't create it.

tombang commented 6 hours ago

this case was caused by audio track hasn't been release