Skip to content
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

Open
cdgru opened this issue Jan 27, 2021 · 6 comments
Labels
area: WebRTC Needs help from someone with WebRTC domain knowledge Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!

Comments

@cdgru
Copy link

cdgru commented Jan 27, 2021

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
@cdgru
Copy link
Author

cdgru commented Jan 27, 2021

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?
Keep „let makingOffer = false;“ from A) but looks like that it'll never be changed or am I missing something else?

@Ryuno-Ki Ryuno-Ki added the Content:WebAPI Web API docs label Jan 27, 2021
MendyBerger pushed a commit to MendyBerger/content that referenced this issue Nov 30, 2021
@github-actions github-actions bot added the idle label Dec 8, 2021
@teoli2003 teoli2003 reopened this May 29, 2022
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 29, 2022
@sideshowbarker sideshowbarker removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 30, 2022
@sideshowbarker sideshowbarker added help wanted If you know something about this topic, we would love your help! area: WebRTC Needs help from someone with WebRTC domain knowledge labels Jun 25, 2022
@fippo
Copy link
Contributor

fippo commented Jul 12, 2022

@jan-ivar @henbos can you take a look?

@henbos
Copy link

henbos commented Jul 12, 2022

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.

@henbos
Copy link

henbos commented Jul 12, 2022

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

@sideshowbarker
Copy link
Collaborator

We could update the article not to talk about the old versus the new way of doing things

That sounds great to me

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

100% agreed

@Josh-Cena Josh-Cena changed the title Issue with "Establishing a connection: The WebRTC perfect nego…": … Jan 4, 2023
@jan-ivar
Copy link
Contributor

jan-ivar commented Apr 4, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: WebRTC Needs help from someone with WebRTC domain knowledge Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!
8 participants