webrtc-pc icon indicating copy to clipboard operation
webrtc-pc copied to clipboard

Transceivers stopped prior to being negotiated are never removed from the set of transcievers

Open henbos opened this issue 1 year ago • 7 comments

The spec has this to say about removing stopped transcievers and it happens in response to negotiating:

Removing transceivers like this is covered by this WPT. The same file also tests that transceivers stopped prior to being negotiated never show up in the SDP which is also good.

But this also makes it possible for a transceiver to end up in "limbo" if stopped prior to being negotiated:

  • It will never get an m= section because it is stopped, but it will never be removed from the set of transceivers because it is never formally a rejected m= section.

How do we resolve this issue?

  • Proposal A: Immediately remove the transceiver from the set of transceivers. Argument: "why need to negotiate something that is not even in the SDP?"
  • Proposal B: Delay the remove until the next SDP answer is set. Argument: "negotiation is the only place where transceivers are removed today, so let's be consistent with that."

henbos avatar Mar 15 '23 11:03 henbos

Thoughts, my fellow transciever enthusiast @jan-ivar? I'm leaning towards Proposal A but I don't have a strong opinion

henbos avatar Mar 15 '23 11:03 henbos

Side-note: this is also consistent with DCs: if the only DC that exists is closed prior to being negotiated, we don't add an m=application line to the SDP.

(Actually not sure what the correct behavior is here... but Canary behaves this way as of recently)

henbos avatar Mar 15 '23 13:03 henbos

Moving DC discussion to #2839. Let this issue only talk about transcievers in limbo :)

henbos avatar Mar 15 '23 13:03 henbos

The same file also tests that transceivers stopped prior to being negotiated never show up in the SDP which is also good.

  • Proposal C: Implement the spec. There is no [edit: W3C] spec support for that green WPT test.

The spec is quite clear: stop(): "Irreversibly marks the transceiver as stopping ... cause[ing] future calls to createOffer to generate a zero port in the media description for the corresponding transceiver, as defined in [RFC8829] (section 4.2.1.) (The user agent MUST treat a stopping transceiver as stopped for the purposes of RFC8829 only in this case)."

jan-ivar avatar Mar 16 '23 03:03 jan-ivar

The WPT may predate our stopping hack.

Section 5.2.1 says "The next step is to generate "m=" sections, as specified in [RFC4566], Section 5.14. An "m=" section is generated for each RtpTransceiver that has been added to the PeerConnection, excluding any stopped RtpTransceivers".

This seems to have supported the green WPT before the stopping hack, so it would perhaps be nice to preserve that JSEP logic, and I see no need to break it.

If we added another "MUST treat a stopping transceiver as stopped" JSEP hack here as well, then that might support the green WPT.

But with Proposal A we wouldn't even need that hack, I think, which seems promising.

@docfaraday WDYT?

jan-ivar avatar Mar 16 '23 03:03 jan-ivar

Yep, I think the test was prior to our changes and I don't think our changes intended to change this specifically, only address the offerer tagged footgun.

Considering all browsers already align on the old JSEP behavior I think we should just clarfiy/decide when to remove them from the set of transceivers

henbos avatar Mar 16 '23 08:03 henbos

So add to the "stopping" steps something like "if transceiver is not associated with a media section, move to stopped state and remove from the list of transceivers"?

alvestrand avatar Jan 17 '24 08:01 alvestrand