End call crash (v1.1.4)
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
)
)
- Start a call
- Waiting until UI is loaded
- 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)
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).
Hey, any news on that @davidliu ?
Hey @benoitletondor, no news at the moment, I'll take another look at fixing this soon though.
Is it fixed in latest version? @davidliu
have same bug, it happens when I try to execute room.disconnect immediately after I'v got Room.State.CONNECTED