Skip to content

MediaStreamTrack has been disposed. #176

@YoussefHachicha

Description

@YoussefHachicha

Versions:
kotlin = "2.0.0"
streamWebRTC = "1.1.2"

Issue description:
when I leave the call I call the disconnet() function

    override fun disconnect() {
        // dispose audio & video tracks.
        remoteVideoTrackFlow.replayCache.forEach { videoTrack ->
            videoTrack.dispose()
        }
        localVideoTrackFlow.replayCache.forEach { videoTrack ->
            videoTrack.dispose()
        }
        localAudioTrack.dispose()
        localVideoTrack.dispose()

        // dispose audio handler and video capturer.
        audioHandler.stop()
        videoCapturer.stopCapture()
        videoCapturer.dispose()

        // dispose signaling clients and socket.
        signalingClient.dispose()
    }

then if I try to join again the app will crash with this exception

java.lang.IllegalStateException: MediaStreamTrack has been disposed.
at org.webrtc.MediaStreamTrack.checkMediaStreamTrackExists(MediaStreamTrack.java:120)
at org.webrtc.MediaStreamTrack.getNativeMediaStreamTrack(MediaStreamTrack.java:114)
at org.webrtc.VideoTrack.addSink(VideoTrack.java:40)
at quran.ui.components.session.VideoRendererKt.setupVideo(VideoRenderer.kt:77)
at quran.ui.components.session.VideoRendererKt.VideoRenderer$lambda$8(VideoRenderer.kt:47)
at quran.ui.components.session.VideoRendererKt.$r8$lambda$n6UVi621O36qTiSUJBF7tT5eapI(Unknown Source:0)

What have I tried:
my current solution for this is to dispose the entire WebRtcSessionManager and create an other one, I followed this solution because I wasn't able to identify how to recreate the MediaStreamTrack if it was disposed, and I figured out since it worked the first time then disposing the entire class and recreating it from the start would solve the issue but I would like to understand.

Other:
why even bother calling disconnet() since it disposes the MediaStreamTrack not calling it will not result in a crash but the camera wont show up

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions