[webrtc-pc] SLD without {sdp} reads [[LastCreatedOffer/Answer]] at the wrong time (#2208)

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

== SLD without {sdp} reads [[LastCreatedOffer/Answer]] at the wrong time ==
The current prose on [setLocalDescription](https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription) reads **[[LastCreatedOffer]]** and **[[LastCreatedAnswer]]** on method entry. This is the wrong time, and may produce the wrong result if other methods are enqueued. For example, it would fail in the [FIFO peer](https://docs.google.com/presentation/d/1UrXARLbAfwmfK686rX_9W_-FGIc62ZDwVd079wIoX7I/edit?ts=5cdd966f#slide=id.g5b048ace1b_21_24) case:
```js
io.onmessage = async ({data: {description, candidate}}) => {
  if (description) {
    await Promise.all([                           // ←- avoids race!
      pc.setRemoteDescription(description),       // ←- 
      pc.createAnswer(),                          // ←- 
      pc.setLocalDescription({type: "answer"})    // ←- unusual, works today
    ]);                                           // ←- 
```
Here, all three promise-returning negotiation methods are invoked at the same time, which means `setLocalDescription` would read `[[LastCreatedAnswer]]` before the *createAnswer* has succeeded (or even begun the in-parallel part of its algorithm). This would cause SLD to either fail (if `[[LastCreatedAnswer]]` was `null`, or apply an outdated answer.

Instead, we need to read these internal slots in the enqueued steps.

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

Received on Friday, 14 June 2019 00:41:52 UTC