W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > July 2017

Re: [webrtc-pc] setRemoteDescription and ontrack order of events: SRD before ontrack?

From: henbos via GitHub <sysbot+gh@w3.org>
Date: Wed, 26 Jul 2017 11:15:25 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-318023926-1501067723-sysbot+gh@w3.org>
As for the risk of inspecting the `pc` in an event between the effects of setRemoteDescription, but before the SRD's promise's then-callback, I think this is an inherent risk with promises that can't be avoided, regardless of how we write the spec, e.g:
```
Promise.resolve().then(function() {
  console.log("Remote streams: " + pc.getRemoteStreams().length);
});
pc.setRemoteDescription(sdpWithOneRemoteStream).then(function() {
  console.log("setRemoteDescription resolved!");
});
```
Because both promises are resolved before the event loop is empty, I would expect the callbacks to be invoked in order as soon as SRD is done and we get this output:
```
Remote streams: 1
setRemoteDescription resolved!
```

-- 
GitHub Notification of comment by henbos
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1508#issuecomment-318023926 using your GitHub account
Received on Wednesday, 26 July 2017 11:15:26 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:21:40 UTC