1

I've implemented Android client using Twilio SDK to do video calls. It works as expected but I found an edge case which I can not figure out how to fix. Here is essence of video call code:

val connectionOptions = ConnectOptions.Builder(accessToken)
                .audioTracks(listOf(audioManager.getLocalAudioTrack()))
                .roomName(roomId)
                .build()
val roomListener = RoomListener()

Video.connect(androidContext, connectOptions, roomListener)

class RoomEventListener : Room.Listener {
    override fun onParticipantDisconnected(room: Room, remoteParticipant: RemoteParticipant) {
       // remove participant from the screen, unsubscribe from events
    }

    override fun onConnectFailure(room: Room, twilioException: TwilioException) {
        exitScreenWithErrorMessage(R.string.video_consult_room_connection_error)
    }

    override fun onReconnected(room: Room) {
        _shouldShowReconnectionActivity.value = false
    }

    override fun onParticipantConnected(room: Room, remoteParticipant: RemoteParticipant) {
        onRemoteParticipantConnected(remoteParticipant)
    }

    override fun onConnected(room: Room) {
        _shouldShowConnectionActivity.value = false
        this@VideoCallViewModel.room = room
        room.remoteParticipants.forEach { onRemoteParticipantConnected(it) }
        determineMainParticipant()
        onLocalParticipantConnected(room)
    }

    override fun onDisconnected(room: Room, twilioException: TwilioException?) {
        exitVideoConsultScreen()
    }

    override fun onReconnecting(room: Room, twilioException: TwilioException) {
        _shouldShowReconnectionActivity.value = true
    }
}

Test case:

  • Bob joins video call using Android phone
  • Jane joins same video call from any device (iOS, web, Android)

When Jane loses connection (i.e. turn off internet)

I'm not sure why under such conditions Android client has been disconnected (We tested it on different devices with Android 8/9).

Couple more details:

  1. If Jane exits room using "End call" button (so room.disconnect() code from Twilio SDK has been called) then Bob stays in the room.
  2. When Bob using iOS device (implementation of iOS and Android quite the same) then described use case passes.
  3. We tried 5.0.1 and 5.1.0 version of com.twilio:video-android library.
  4. I noticed Known Issue for Android Twilio Video library in Release notes and I'm not sure can it affects described use case or not:

Unpublishing and republishing a LocalAudioTrack or LocalVideoTrack might not be seen by Participants. As a result, tracks published after a Room.State.RECONNECTED event might not be subscribed to by a RemoteParticipant.

IliaEremin
  • 3,338
  • 3
  • 26
  • 35

1 Answers1

1

I opened issue on twilio github repo https://github.com/twilio/video-quickstart-android/issues/454 - and this is expected behaviour for twilio video sdk 5.x+. Both for Android and iOS sdks.

IliaEremin
  • 3,338
  • 3
  • 26
  • 35