In our Web application, we have 2 parties get into conference. We have button to Switch the camera and we are using the following code to Switch Camera (from back to front or front to back) during a video call. When we call replaceTrack(), sometimes the live video gets disconnected on the user end (USER A) and the video tag (of the self video) either freezes or shows blank black screen. But at the same time, for the other user (USER B) in the conference, the video from USER A device is still streamed properly. It doesn’t happen all the time but it does happen quite often on Iphone (running Safari/604.1) if we toggle the camera a couple of times quickly. But we have also noticed the same issue in Lenovo K8 Plus running Android 8.0 on Chrome 83.0.4103.106.
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: { exact: facingMode }, width: ecsipvhelper.resolutionWidth,
height: ecsipvhelper.resolutionHeight, frameRate: ecsipvhelper.frameRate } })
.then(mediaStream => {
var videoTrack = mediaStream.getVideoTracks()[0];
ecsipvhelper.publisher.replaceTrack(videoTrack);
ecsipvhelper.publisherStream = mediaStream;
ecsipvhelper.isFrontCamera = !ecsipvhelper.isFrontCamera;
if(callback !== null) {
callback();
}
})
.catch(error => {
console.log('Error toggling to the session', error.message);
});
;
}