Bug 1443198 - Part 2: Check whether PC is closed before trying to create transceivers due to offerToReceive. r?jib draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 06 Mar 2018 09:24:18 -0600
changeset 763866 5a42106e9d0a3a6925d57bbbfc455429b3fa49d2
parent 763732 0cce56345b66ce4dc6cd56a8698d4f2df53512ea
push id101574
push userbcampen@mozilla.com
push dateTue, 06 Mar 2018 19:49:40 +0000
reviewersjib
bugs1443198
milestone60.0a1
Bug 1443198 - Part 2: Check whether PC is closed before trying to create transceivers due to offerToReceive. r?jib MozReview-Commit-ID: 5xDzBc9af6Y
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -788,20 +788,16 @@ class RTCPeerConnection {
   createOffer(optionsOrOnSucc, onErr, options) {
     let onSuccess = null;
     if (typeof optionsOrOnSucc == "function") {
       onSuccess = optionsOrOnSucc;
     } else {
       options = optionsOrOnSucc;
     }
 
-    // Spec language implies that this needs to happen as if it were called
-    // before createOffer, so we do this as early as possible.
-    this._ensureTransceiversForOfferToReceive(options);
-
     // This entry-point handles both new and legacy call sig. Decipher which one
     if (onSuccess) {
       return this._legacy(onSuccess, onErr, () => this._createOffer(options));
     }
 
     return this._async(() => this._createOffer(options));
   }
 
@@ -842,16 +838,17 @@ class RTCPeerConnection {
         } else if (transceiver.direction == "recvonly") {
           transceiver.setDirectionInternal("inactive");
         }
       });
   }
 
   async _createOffer(options) {
     this._checkClosed();
+    this._ensureTransceiversForOfferToReceive(options);
     this._syncTransceivers();
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     return this._chain(async () => {
       let haveAssertion;
       if (this._localIdp.enabled) {
         haveAssertion = this._getIdentityAssertion(origin);
       }
       await this._getPermission();