Re: [webrtc-extensions] Unclear when all side-effects of setSelectedCandidatePair have taken effect (#182)

> 2. A [selectedcandidatepairchange](https://w3c.github.io/webrtc-pc/#event-icetransport-selectedcandidatepairchange) event is fired.

I'm supportive of a promise. Even though the following might seem to suffice:
```js
transceiver.transport.iceTransport.setSelectedCandidatePair(foo);
await new Promise(r => transceiver.transport.iceTransport.selectedcandidatepairchange = r);
const bar = transceiver.transport.iceTransport.getSelectedCandidatePair();
// foo and bar now match
```
...it risks a race with the ICE agent once in a while if the method is called when a task is already queued to fire the event.

> This would be a good scenario to return a promise that resolves once all the changes have been applied

UNLESS we elide firing `selectedcandidatepairchange` from the method — WebRTC has some precedent of not firing events on JS from JS's own actions, whether that was a good decision or not has been questioned — then we need to make nail down the order: whether the event fires before or after the promise resolves.

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


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

Received on Tuesday, 31 October 2023 17:29:11 UTC