[webrtc-pc] Why does addIceCandidate throw an error when no remoteDescription. Most libraries abstract this error away (#2519)

Sean-Der has just created a new issue for https://github.com/w3c/webrtc-pc:

== Why does addIceCandidate throw an error when no remoteDescription. Most libraries abstract this error away ==
(This feedback is from [Pion](https://github.com/pion/webrtc) not my full-time job, go ahead and delete if that isn't ok)

This is defined [here](https://github.com/w3c/webrtc-pc/blob/master/webrtc.html#L3032-L3035)

```
If remoteDescription is null return a promise rejected with a newly created InvalidStateError.
```

I don't believe this restriction is needed, and many popular WebRTC libraries just circumvent this check. In [simple-peer](https://github.com/feross/simple-peer/blob/master/index.js#L209-L211) the library caches candidates, and then adds them.

I do the same in Pion.

I can get more datapoints from other implementations if that is helpful. I have seen this pattern in many private code bases as well.
----

From an implementer standpoint this is really easy to handle. If you get an ICE candidate before you have ICE details just cache them, and when you have enough details you can start connectivity checks.

I work with a lot of people learning WebRTC/building things for the first time because of Pion. This error is constant, and is probably my #2 issue (after H264 in Chrome questions/not support all profiles). Especially with the new rush of interest with COVID this is something that I will sometimes have people sharing logs multiple times in Slack a day with this error.

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2519 using your GitHub account

Received on Sunday, 26 April 2020 08:44:39 UTC