Sort out order of events with setLocal/RemoteDescription()


Our current spec text about setLocal/RemoteDescription() needs some 
attention. We have several attributes to update, states to change, 
events to fire and a Promise to resolve and all these things need to 
happen in a predictable order. This section has also been updated quite 
a lot since it was written so it has become a bit inconsistent and a few 
things are duplicated.

Right now we synchronously update the signalingState and the 
current/pendingLocal/RemoteDescription attribute in the resolve task. We 
also fire the signalingstatechange event there (synchronously) which 
exposes the newly updated signalingState and the description attribute 
to the script before the promise is resolved, but I think that's the 
most reasonable way to do it since we can't update the attributes as 
part of the Promise resolving (as I understand it at least).

An open question is how much else we should do before resolving the 
promise. We recently updated setRemote() to delay the promise resolving 
until all RTCRtpReceivers have been dispatched to the script, which 
makes sense.

What I suggest changing is to move the synchronous updates of the 
iceGatheringState, iceConnectionState and the firing of the 
negotiationneeded event out of the resolve task. We should define 
procedures for these that queues a task to update the state and fire the 
corresponding event and refer to these procedures in the resolve task.

PR 266 [1] makes the changes proposed above, along with some minor 
changes listed below. Let's use this PR as a base and mold it to 
something that we are happy with.

* Align more with promise guide
* Move processing model out of setLocalDescription function description 
and into the Operations section (and add links)
* Fire the corresponding event for each state change (either 
synchronously or async via "update procedure")
* Remove duplicate changes to the ice gathering state (ice restart 
procedure and resolve task)
* Add links to attributes
* Use a description variable instead of always referring to the 
RTCSessionDescription argument
* Remove duplicate updates of the signaling state
* Fire negotiationneeded async and clear the flag
* Incorporate dispatching of RTCRtpReceivers into the shared processing 



Received on Tuesday, 18 August 2015 11:27:10 UTC