client-sdk-android icon indicating copy to clipboard operation
client-sdk-android copied to clipboard

End call crash (v1.1.4)

Open Arm63 opened this issue 3 years ago • 5 comments

Describe the bug

On version, 1.1.4 try to end the call with the calling room.disconnect(), the crash is happens

Create room in ViewModel

    val audioHandler = AudioSwitchHandler(app)
    val room = LiveKit.create(
        appContext = app,
        options = RoomOptions(adaptiveStream = true, dynacast = true),
        overrides = LiveKitOverrides(
            audioHandler = audioHandler
        )
    )
  1. Start a call
  2. Waiting until UI is loaded
  3. End a call
 fun endCall(){
        viewModelScope.launch {

            val sessionId = getSessionCode() ?: return@launch
            val endSessionResponse = conferenceManager.stopLiveKitConference(sessionId)

            if (!endSessionResponse.success) return@launch

            disconnect()
        }
    }
    
       fun disconnect() {
        if (room.state != Room.State.DISCONNECTED) {
            room.disconnect()
        }
        state = CallState.IDLE
    }

When I call stopLiveKitConference our server deletes the room and sends me a response of server call, after that I call the room.disconnect() and a crash happens. But when I call delay like 2000 before of room.dissconnect(), and all works normally without the crash.

Expected behavior Call must end

Device Info:

  • Device: [Google Pixel 2]

  • OS: [Android 11]

  • LiveKit SDK version: [1.1.4]

    kotlin.UninitializedPropertyAccessException: publisher has not been initialized yet. at io.livekit.android.room.RTCEngine.getPublisher$livekit_android_sdk_release(RTCEngine.kt:98) at io.livekit.android.room.participant.LocalParticipant.unpublishTrack(LocalParticipant.kt:413) at io.livekit.android.room.participant.LocalParticipant.unpublishTrack$default(LocalParticipant.kt:402) at io.livekit.android.room.participant.LocalParticipant.cleanup(LocalParticipant.kt:566) at io.livekit.android.room.Room.cleanupRoom(Room.kt:446) at io.livekit.android.room.Room.handleDisconnect(Room.kt:465) at io.livekit.android.room.Room.disconnect(Room.kt:248) at -------------LiveKitCallViewModel.disconnect(LiveKitCallViewModel.kt:321)

Arm63 avatar Oct 26 '22 15:10 Arm63

Looks like there's a race condition here with the RTCEngine processing a leave message while Room.disconnect() is called. This might take some time to fix.

In the meantime, I think reversing the order might be a workaround (disconnecting the room object before deleting the room from the server).

davidliu avatar Nov 14 '22 15:11 davidliu

Hey, any news on that @davidliu ?

benoitletondor avatar Jan 16 '23 14:01 benoitletondor

Hey @benoitletondor, no news at the moment, I'll take another look at fixing this soon though.

davidliu avatar Jan 19 '23 10:01 davidliu

Is it fixed in latest version? @davidliu

shimika avatar May 12 '23 01:05 shimika

have same bug, it happens when I try to execute room.disconnect immediately after I'v got Room.State.CONNECTED

usayplz avatar Aug 05 '23 06:08 usayplz