webrtc-android icon indicating copy to clipboard operation
webrtc-android copied to clipboard

MediaStreamTrack has been disposed.

Open YoussefHachicha opened this issue 1 year ago • 1 comments

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

YoussefHachicha avatar Aug 03 '24 20:08 YoussefHachicha

Hi @YoussefHachicha, the new release, version 1.3.0, is now available and includes the m125 patches. Could you check if this issue still occurs with the updated release?

skydoves avatar Nov 26 '24 06:11 skydoves