adapter: (chrome shim) after 4.1, senders are no longer kept in sync with tracks

Browsers and versions affected Chrome webrtc-adapter >= 4.1.0

Description MediaStream.removeTrack() doesn’t clean up senders.

Steps to reproduce Remove a track from a peer connection’s local stream

Expected results The following assertions hold

let senders = pc.getSenders().filter((s) => s.track.kind === `audio`);
assert.lengthOf(senders, 1);

pc.getLocalStreams().forEach((stream) => {
  stream.getAudioTracks().forEach((t) => {
    stream.removeTrack(t);
  });
});

senders = pc.getSenders().filter((s) => s.track.kind === `audio`);
assert.lengthOf(senders, 0);

Actual results The second assertion above does not hold.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 20 (7 by maintainers)

Most upvoted comments

oh? On https://webrtc.github.io/samples/src/content/peerconnection/pc1/ calling this doesn’t change pc1.getLocalStreams():

pc1.removeTrack(pc1.getSenders()[0])
pc1.getLocalStreams()[0].getTracks()

That behaviour does not work in Firefox and from the discussions in #559 is not something that is going to be spec-compliant either. You need to explicitly remove a track (which will be available in #611) to remove its sender (and note that in the future the sender won’t be removed but its track will be null’ed)