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
When is negotiation complete? #45
Comments
Proposal A: const transceiver = pc.addTransceiver("video");
await new Promise(r => pc.onnegotiationcomplete = r);
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly"); A downside is subsequent actions might delay this event. Proposal B: Expose a const transceiver = pc.addTransceiver("video");
while (pc.negotiationneeded) await state(pc, "stable");
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly"); Complication: once set, we MUST fire Proposal C: Expose a const transceiver = pc.addTransceiver("video");
await pc.negotiationcomplete;
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly"); Its fulfillment would not be delayed by subsequent actions, besting proposals A & B Think of it as the promise addTransceiver etc. should have returned. Proposal D: The Road. |
What is the question that needs answering here?
The last one is silly (outside of testing), we shouldn't bother with designing for that. |
If this is just for testing... Wouldn't the following be able to tell if negotiation was needed in most cases? There might be special cases like when pc closes, if data channels are used or if setCodecPreference or setStreams has happened, but those would probably be separate tests anyway:
And at strategic points in WPTs, probably when returning to stable, you could...
With regards to Proposal B (Expose a negotiationneeded boolean attribute)
Why is this complicated? Why is having to fire the event a problem? Because of "maybe fire" logic...? |
Also: The test should know whether or not negotiation should fire, and by the time you have reached stable you should already know that the PC has performed the check to determine if negotiation is needed, so why couldn't you assert that within the next execution cycle onnegotiatonneeded must have or must not have happened? |
That's specific to addTransceiver and addTrack. Here are all our modification methods:
There are still 4 question marks in that list. Solving them all with one solution seems desirable. Moreover, I wouldn't dismiss the value of this information to an application. E.g. async function addParticipant(someArgs) {
pc.addTransceiver("audio");
return pc.negotiationcomplete;
}
button.onclick = async () => {
await addParticipant(someArgs);
writeOnScreen(`User ${name} has joined. Say hello!`);
}; Being able to authoritatively make statements about a connection seems desirable over, e.g. writeOnScreen(`User ${name} should have joined. Try saying hello!`); |
Why specify check if negotiation is needed if we're forcing JS to write their own buggy version? We'll end up with lots of JS that work in "most cases" but not all. A recipe for sadness. We should at minimum expose
Great question, and the argument against exposing const negotiationNotNeeded = !await Promise.race([
new Promise(r => pc.onnegotiationneeded = r),
new Promise(r => setTimeout(r))
]); Unfortunately, it is no longer reliable, since we decided to chain ONN in w3c/webrtc-pc#2405 and w3c/webrtc-pc#2478 So this is a functional spec regression I think we need to fix. |
A problem arose while writing perfect negotiation wpt tests: When is negotiation complete?
You know, something like:
Naively, one might think this works:
Unfortunately, outside a lab, →
"stable"
might come from rollback, or answering a remote offer.Or even from juuust missing our own negotiation train triggered by a previous local action.
This leaves us stuck writing action-specific spin-tests, not a great API:
So I tried solving this in JS by dispatching my own
negotiated
event in SRD(answer):This avoids rollbacks and remote offers, but we still have to account for just missing a local train:
This avoids the dreaded
while
loop. But who's going to remember this over some intermittent?The text was updated successfully, but these errors were encountered: