If a client repeatedly join/leaves the same SFURoom, clients connected using Firefox may get an error preventing them from receiving MediaStreams from other clients (confirmed on Firefox 57 and 58).
This is caused by the same MediaStreamTrack id being used multiple times.
We have found a workaround to get around this problem until we can fix it. By using stream.clone()
to duplicate the stream before joining the room again, it is possible to generate a new MediaStreamTrack id every time.
Below is a sample implementation. We call track.stop()
on all tracks of the old stream in order to prevent a possible memory leak. When the stream is already assigned to a video element's srcObject, you should assign the new stream as the old one will be stopped.
function cloneAndDeactivateStream(stream) {
const newStream = stream.clone();
// If you have assigned the stream to a video element, you need to assign it the new stream.
// e.g. videoElem.srcObject = newStream;
stream.getTracks().forEach(track => track.stop());
return newStream;
}
localStream = cloneAndDeactivateStream(localStream);
room = peer.joinRoom(roomName, {mode: 'sfu', stream: localStream});
Comments
0 comments
Article is closed for comments.