- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Mon, 25 Nov 2019 19:15:49 +0000
- To: public-webrtc-logs@w3.org
> pc2 creates an offer and discards pc1's offer because it is the unpolite peer. the ufrags will not be known by pc2.
There is a minor issue here with the impolite peer strategy, but it's unrelated to rollback.
To explain: Perfect negotiation involves two components that in concert avoid glare:
1. The polite peer uses rollback to avoid incoming offer collision
2. The impolite peer ignores the incoming offer to avoid collision
The first (rollback) part is fine, as I [mention above](https://github.com/w3c/webrtc-pc/issues/2367#issuecomment-558201617).
The second part does cause *addIceCandidate* errors, because an "impolite peer" is merely
`if (!polite) return`, so its peer connection object never learns about the would-be offer—there's no such thing as `pc.ignoreRemoteDescription(offer)`—so its *addIceCandidate* doesn't have enough info to silence the obsolete candidates. We first ran into this in https://github.com/w3c/webrtc-pc/issues/2164.
But this is true for any regular incoming offer collision, and not unique to offers with new ufrags.
I was planning to blog about this as a follow-up once perfect negotiation was further along. Unless we want to advocate for the aforementioned method, I vote we let JS handle this as best it can. The errors are harmless noise.
My current strategy—which I plan to blog about once perfect negotiation works in Firefox, to reduce complexity—is for the impolite JS to set a temporary `ignoredRemoteDescription` boolean to quelch *addIceCandidate* errors for a brief while after collision ([still-ugly fiddle](https://jsfiddle.net/jib1/uxdLzfh4/)):
```js
if (description) {
if (!polite && description.type == "offer" && pc.signalingState != "stable") {
ignoredRemoteDescription = true;
return;
}
await pc.setRemoteDescription(description);
ignoredRemoteDescription = false;
if (description.type == "offer") {
await pc.setLocalDescription(await pc.createAnswer());
send({description: pc.localDescription});
}
} else if (candidate) {
try {
await pc.addIceCandidate(candidate);
} catch (e) {
if (!ignoredRemoteDescription) throw e;
}
}
```
Almost-perfect negotiation.
--
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2367#issuecomment-558299867 using your GitHub account
Received on Monday, 25 November 2019 19:15:51 UTC