[webrtc-pc] Are various exposed RTCIceCandidate values object-comparable? (#2906)

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

== Are various exposed RTCIceCandidate values object-comparable? ==
Would you expect two calls of [getLocalCandidates()](https://w3c.github.io/webrtc-pc/#dom-rtcicetransport-getlocalcandidates) to return the same objects? Two calls of [getSelectedCandidatePair()](https://w3c.github.io/webrtc-pc/#dom-rtcicetransport-getselectedcandidatepair)?
```js
iceTransport.getLocalCandidates()[0] == iceTransport.getLocalCandidates()[0] // true?
iceTransport.getSelectedCandidatePair().local == iceTransport.getSelectedCandidatePair().local; // true?
```
Probably. What about across the two?
```js
iceTransport.getLocalCandidates().includes(iceTransport.getSelectedCandidatePair().local) // true?
```
Probably. What about the candidates exposed in events?
```js
pc.onicecandidate = e => console.log(iceTransport.getLocalCandidates().includes(e.candidate));
```
Probably there too. [This fiddle](https://jsfiddle.net/jib1/qjgb7zp9/) shows a mixed bag in Chrome, showing `true` in the first case, and `false` thereafter.

It's probably not too late to tighten this up, and get `true` for all of them. This will simplify https://github.com/w3c/webrtc-extensions/pull/175.

### Solution

Other than its constructor, the [surface a candidate](https://w3c.github.io/webrtc-pc/#dfn-surface-the-candidate) algorithm is the _only_ place that [creates an RTCIceCandidate](https://w3c.github.io/webrtc-pc/#dfn-creating-an-rtcicecandidate):

<img width="794" alt="image" src="https://github.com/w3c/webrtc-pc/assets/3136226/28e71b01-961c-4651-84c7-a929007c5728">

The phrase _"transport's set of candidates"_ looks it it should be a linkable concept, suggesting the intent here was to keep track of these objects. We should probably make this more explicit with an internal slot that the getters refer to.

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 November 2023 00:08:55 UTC