livekit / client-sdk-android

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

This exception occurs when I switch rooms. subscriber has not been initialized yet #381

Open User-Admin opened 4 months ago

User-Admin commented 4 months ago

Describe the bug kotlin.UninitializedPropertyAccessException: subscriber has not been initialized yet. at io.livekit.android.room.RTCEngine.getSubscriber$livekit_android_sdk_release(RTCEngine.kt:128) at io.livekit.android.room.RTCEngine.onTrickle(RTCEngine.kt:733) at io.livekit.android.room.SignalClient.handleSignalResponseImpl(SignalClient.kt:586) at io.livekit.android.room.SignalClient.access$handleSignalResponseImpl(SignalClient.kt:56) at io.livekit.android.room.SignalClient$onReadyForResponses$1$1.emit(SignalClient.kt:208) at io.livekit.android.room.SignalClient$onReadyForResponses$1$1.emit(SignalClient.kt:206) at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383) at kotlinx.coroutines.flow.SharedFlowImpl.collect(Unknown Source:0) at io.livekit.android.room.SignalClient$onReadyForResponses$1.invokeSuspend(SignalClient.kt:206) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@28ee7dd, Dispatchers.IO]

To Reproduce Steps to reproduce the behavior: I have a list of rooms, and I have multiple rooms, and when I switch between rooms, The main operation is to disconnect the previous room and reconnect the new room Will appear the above said exceptions: kotlin UninitializedPropertyAccessException: the subscriber from then the initialized yet.

Expected behavior How can I avoid this problem, or is there a better solution

Screenshots If applicable, add screenshots to help explain your problem. ~03V$QCA1BUB3@8I0MF LNX

Device Info:

Additional context Add any other context about the problem here.

davidliu commented 4 months ago

Do you have a code sample on what you're doing when you switch rooms?

User-Admin commented 4 months ago

fun roomDisConnected(tokenData: String?) { mutablePrimarySpeaker.value = null room.localParticipant.cleanup() room.disconnect()

 lifecycleScope.launch { 
    delay(500)
    connectToRoom(tokenData)
}

}

There is a 500-millisecond delay in entering the room, otherwise another problem will arise: 8XPM3I 6G~MYNPG)(`~4`S9

User-Admin commented 4 months ago

😄Are there any new solutions to this problem now ?

davidliu commented 4 months ago

Doing a couple internal fixes that will also likely address this.

User-Admin commented 3 months ago

I don't understand what you mean. Do I need to check the code and fix it internally? In the later version iteration, the room initialization exception will be handled synchronously?

davidliu commented 3 months ago

Just that the upcoming version has some fixes that may prevent this bug from happening. Haven't had time to check this specific bug.

User-Admin commented 3 weeks ago

hi,Is there any new progress on this issue? I use the latest 2.4.0 SDK here, but this problem still occurs