Bug 1435013: Sync transceivers before creating offers/answers. r?jib draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Thu, 01 Feb 2018 12:07:02 -0600
changeset 750732 5ce3dfe79b69c4ea2176de8fd1716cca119aba2e
parent 748899 fd995039d89708923b5673ecebc652967d40bd4e
push id97721
push userbcampen@mozilla.com
push dateFri, 02 Feb 2018 18:10:53 +0000
reviewersjib
bugs1435013
milestone60.0a1
Bug 1435013: Sync transceivers before creating offers/answers. r?jib MozReview-Commit-ID: EORXVc8Hnky
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -844,16 +844,17 @@ class RTCPeerConnection {
         } else if (transceiver.direction == "recvonly") {
           transceiver.setDirectionInternal("inactive");
         }
       });
   }
 
   async _createOffer(options) {
     this._checkClosed();
+    this._syncTransceivers();
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     return this._chain(async () => {
       let haveAssertion;
       if (this._localIdp.enabled) {
         haveAssertion = this._getIdentityAssertion(origin);
       }
       await this._getPermission();
       await this._certificateReady;
@@ -875,16 +876,17 @@ class RTCPeerConnection {
     if (typeof optionsOrOnSucc == "function") {
       return this._legacy(optionsOrOnSucc, onErr, () => this._createAnswer({}));
     }
     return this._async(() => this._createAnswer(optionsOrOnSucc));
   }
 
   async _createAnswer(options) {
     this._checkClosed();
+    this._syncTransceivers();
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     return this._chain(async () => {
       // We give up line-numbers in errors by doing this here, but do all
       // state-checks inside the chain, to support the legacy feature that
       // callers don't have to wait for setRemoteDescription to finish.
       if (!this.remoteDescription) {
         throw new this._win.DOMException("setRemoteDescription not called",
                                          "InvalidStateError");