-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with "Establishing a connection: The WebRTC perfect negotiation pattern": unclear what's being recommended #1802
Comments
I am concerned about makingOffer. It is used in A), no more used/needed in B), but still needed in C) for offerCollision. A) pc.onnegotiationneeded let makingOffer = false;
pc.onnegotiationneeded = async () => {
try {
makingOffer = true;
await pc.setLocalDescription();
signaler.send({ description: pc.localDescription });
} catch(err) {
console.error(err);
} finally {
makingOffer = false;
}
}; B) in the last section "restartice" where the focus in oniceconnectionstatechange, the (new?) pc.onnegotiationneeded handler doen not use makingOffer anymore: pc.onnegotiationneeded = async options => {
await pc.setLocalDescription(await pc.createOffer(options));
signaler.send({ description: pc.localDescription });
};
pc.oniceconnectionstatechange ... C) What I am concerned about, is the signaler.onmessage handler, which still using makingOffer for offerCollision: let ignoreOffer = false;
signaler.onmessage = async ({ data: { description, candidate } }) => {
try {
if (description) {
const offerCollision = (description.type == "offer") &&
(makingOffer || pc.signalingState != "stable");
ignoreOffer = !polite && offerCollision;
if (ignoreOffer) {
return;
} ... What You are recommending for makingOffer? |
Adds border-block examples
The code quoted in B) is under the section "The old way" but just after this section in the article there is the section "Using restartIce()" which does not explicitly call createOffer(), it just calls restartIce() and relies on the Perfect Negotiation logic doing everything correctly for you. |
Calling restartIce() triggers onnegotiationneeded and that event is still using makingOffer so you're safe. We could update the article not to talk about the old versus the new way of doing things, it sounds a bit like a sales pitch for Perfect Negotiation or an interesting fact about how things were supposed to work before, but it's not really helpful in a guide to show how not to do it if you're only interested in how to do it |
That sounds great to me
100% agreed |
It should also be checked against the canonical example in the spec https://www.w3.org/TR/webrtc/#perfect-negotiation-example (since that did undergo a couple of iterations). |
MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation
What information was incorrect, unhelpful, or incomplete?
Specific section or headline?
What did you expect to see?
Did you test this? If so, how?
MDN Content page report details
en-us/web/api/webrtc_api/perfect_negotiation
The text was updated successfully, but these errors were encountered: