[webrtc-pc] The steps in "Update the connection state" say to fire connectionstatechange when [[IsClosed]] is set to true (#2865)

docfaraday has just created a new issue for https://github.com/w3c/webrtc-pc:

== The steps in "Update the connection state" say to fire connectionstatechange when [[IsClosed]] is set to true ==
From 4.4.1.3 Update the connection state:

"An [RTCPeerConnection](https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection) object has an aggregated [[[ConnectionState]]](https://w3c.github.io/webrtc-pc/#dfn-connectionstate). Whenever the state of an [RTCDtlsTransport](https://w3c.github.io/webrtc-pc/#dom-rtcdtlstransport) changes or when the [[[IsClosed]]](https://w3c.github.io/webrtc-pc/#dfn-isclosed) slot turns true, the user agent MUST update the connection state by queueing a task that runs the following steps:

1. Let connection be this [RTCPeerConnection](https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection) object.

2. Let newState be the value of deriving a new state value as described by the [RTCPeerConnectionState](https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionstate) enum.

3. If connection.[[[ConnectionState]]](https://w3c.github.io/webrtc-pc/#dfn-connectionstate) is equal to newState, abort these steps.

4. Set connection.[[[ConnectionState]]](https://w3c.github.io/webrtc-pc/#dfn-connectionstate) to newState.

5. [Fire an event](https://dom.spec.whatwg.org/#concept-event-fire) named [connectionstatechange](https://w3c.github.io/webrtc-pc/#event-connectionstatechange) at connection."

This directly contradicts 4.4.4 Garbage collection:

"An [RTCPeerConnection](https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection) object MUST not be garbage collected as long as any event can cause an event handler to be triggered on the object. When the object's [[[IsClosed]]](https://w3c.github.io/webrtc-pc/#dfn-isclosed) internal slot is true, no such event handler can be triggered and it is therefore safe to garbage collect the object."

In addition, most places suppress event firing when [[IsClosed]] is true. There are some exceptions, though, and those are likely bugs too. Just grep through for "Fire an event" and find the places that don't do an [[IsClosed]] check.


Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2865 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 27 April 2023 20:09:36 UTC