Re: [webrtc-pc] When to fire events triggered by setRemoteDescription.

So, the remaining issue here are the `addtrack` and `removetrack` events on the streams. To synchronize them completely (detaching them from their state-change), I think violates POLA if the listener looks at `stream.getTracks().length`, as I argue in https://github.com/w3c/webrtc-pc/pull/1667#discussion_r155406891. cc @annevk

I think we can get most of the way there, without violating POLA, by deferring both the addition/removal of the tracks as well as their related event firing until the end of the algorithm, right before we fire the `track` events we've gathered similarly.

Basically, push the tracks on two lists (removeList and addList), then later for each track in removeList remove the track and fire the removetrack event, and then ditto for the addList.

Since these lists are copies, they should be safe to walk. Listeners of these events will find everything in place, except for the tracks which are being removed/added one by one.

Listeners of the `track` events will see everything in place, as before (unaffected by this).

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1691#issuecomment-352919912 using your GitHub account

Received on Tuesday, 19 December 2017 23:38:42 UTC