Re: [webrtc-pc] Semi-sync replaceTrack API pre-initial-negotiation is bizarre.

The reasons are coming back to me: SRD is timing-critical. If users delay calling SRD(offer), the peer connection [won't be ready to receive ICE candidates](https://stackoverflow.com/questions/36839080/webrtc-onicecandidate-am-getting-ice-candidates-with-sdpmid-audio-only-but-not/36851163#36851163).

So e.g. if users were to write:
```js
let getMyTransceiver() = pc.getTransceivers())[0] || pc.addTransceiver("video");

signalingChannel.onmessage = async ({data: {sdp, candidate}}) => {
  if (sdp) {
    await getMyTransceiver().sender.replaceTrack(myVideoTrack); // Delays SRD!
    await pc.setRemoteDescription(sdp);
    if (sdp.type == "offer") {
      await pc.setLocalDescription(await pc.createAnswer());
      sc.send({sdp: pc.localDescription});
    }
  } else if (candidate) await pc.addIceCandidate(candidate);
}
```
...they might occasionally miss ICE candidates, [a hard-to-find bug](https://stackoverflow.com/questions/36839080/webrtc-onicecandidate-am-getting-ice-candidates-with-sdpmid-audio-only-but-not/36851163#36851163).

Possible solutions may be to either:
 1. Enqueue replaceTrack, or
 2. Allow `sender.track = myVideoTrack` IFF "transceiver is not yet associated with a media description"

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1769#issuecomment-364981383 using your GitHub account

Received on Monday, 12 February 2018 16:38:50 UTC