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

Make stop() safe and affect createOffer only. Replace attributes with "stopped" direction. #2220

Merged
merged 7 commits into from
Jul 18, 2019

Conversation

jan-ivar
Copy link
Member

@jan-ivar jan-ivar commented Jun 28, 2019

Fixes #2150 and #2176. For consideration.


Preview | Diff

@jan-ivar jan-ivar self-assigned this Jun 28, 2019
@jan-ivar
Copy link
Member Author

@henbos This is based on what we discussed. PTAL.

In short, the PR creates a new tc.stopping sibling to tc.stopped. The former only affects createOffer, not createAnswer, sidestepping #2150. The stop() method now sets stopping instead of stopped, but otherwise works as before locally, and setRemoteDescription(answer) transitions it to stopped, basically.

Renamed old dangerous stop to reject(); made it work only in "have-remote-offer", solving #2176.

I had to audit existing places the spec reads [[Stopped]], to see which should be [[Stopping]] instead. Very few it turned out, mostly high-level modification APIs like addTrack.

Stop reading now if you don't care about edge cases...

The good news is that the setting an RTCSessionDescription algorithm did not look at [[Stopped]] much. I found two places, but they seem like optimizations, and one may even be a bug. I'll file a separate issue.

This means most of our negotiation event firing code already runs on stopped transceivers today, something I verified in Firefox with this fiddle. That may sound bad, but is actually quite orthogonal and seems benign to me, since it's basically shuffling around ended tracks at that point. This was informative to figure out how a peer should react to incoming offers/answers in the new stopping state:

For example: an edge-case is where a fixed-role answerer may end up staying in stopping state for a while, because things like tc.stop() and pc.addTrack won't automatically be negotiated (requires out-of-band-signaling to the fixed-role offerer). So it sits until negotiation comes from the other end, because it's never the offerer. In this case, events may still fire from incoming non-stopped offers, except on the transceiver.receiver.track itself which has been ended synchronously already by stop(), like today.

@henbos
Copy link
Contributor

henbos commented Jul 1, 2019

Stop reading now if you don't care about edge cases...

Of course I care ;) I'll review carefully tomorrow

@jan-ivar
Copy link
Member Author

jan-ivar commented Jul 2, 2019

Slides

@aboba
Copy link
Contributor

aboba commented Jul 11, 2019

Need to remove the reject() portion.

@jan-ivar jan-ivar changed the title Add reject() + make stop() safe. New stopping state affects createOffer only. Make stop() safe, affecting createOffer only. Replace attributes with "stopped" direction. Jul 15, 2019
@jan-ivar
Copy link
Member Author

Removes reject(), and incorporates @henbos's changes proposed at the tail of our last VI, which simplifies by removing the stopped and stopping attributes in favor of a single "stopped" direction.

So instead of reading a stopping attribute, use:

if (tc.direction == "stopped") {

Instead of reading the old stopped attribute (which now only happens from SRD) use:

if (tc.currentDirection == "stopped") {

Keeps the old stop() method, unless there's appetite for direction = "stopped"? (throws now)

tc.stop();
console.log(tc.direction);        // stopped
console.log(tc.currentDirection); // sendrecv
doSignalingHandshake();
console.log(tc.direction);        // stopped
console.log(tc.currentDirection); // stopped

Note how the final value of currentDirection is now "stopped" rather than null. 🤘

@jan-ivar jan-ivar changed the title Make stop() safe, affecting createOffer only. Replace attributes with "stopped" direction. Make stop() safe and affect createOffer only. Replace attributes with "stopped" direction. Jul 15, 2019
@jan-ivar
Copy link
Member Author

Travis seems unhappy. Some kind of respec issue? I can't make out the problem here.

@caribouW3
Copy link
Member

Travis seems unhappy. Some kind of respec issue? I can't make out the problem here.

Apparently a transient problem, it works OK now.

Copy link
Contributor

@henbos henbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this PR, I think it's good. Just one comment.

webrtc.html Show resolved Hide resolved
@aboba aboba merged commit 72e8f65 into w3c:master Jul 18, 2019
@jan-ivar jan-ivar deleted the reject branch July 19, 2019 17:28
@jan-ivar jan-ivar added the Needs Test Needs a WPT test label Jul 19, 2019
a2sheppy added a commit to a2sheppy/browser-compat-data that referenced this pull request Jul 19, 2019
This has just been deprecated in the specification. Initial content
changes have been made to note this is incoming and to prepare
developers to switch to the new way to detect stopped transceivers.
Further updates will come when the change is implemented in browsers.

Reference:
* w3c/webrtc-pc#2220

Content changes:
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stopped
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stop
Elchi3 pushed a commit to mdn/browser-compat-data that referenced this pull request Jul 24, 2019
This has just been deprecated in the specification. Initial content
changes have been made to note this is incoming and to prepare
developers to switch to the new way to detect stopped transceivers.
Further updates will come when the change is implemented in browsers.

Reference:
* w3c/webrtc-pc#2220

Content changes:
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stopped
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Test Needs a WPT test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transceiver.stop() needs more work (avoid BUNDLE footgun)
4 participants