Browse Source

Made updating video sender parameters in sequential manner in order to solve race condition when transaction id (which is generated during getParameters) can be reset at the end of videoSender setParameters and cause exception if another update was already in fly and before its check for transaction id presence.

master
mbondarenko 2 years ago
parent
commit
b3ceca8d52
1 changed files with 23 additions and 0 deletions
  1. 23
    0
      modules/RTC/TraceablePeerConnection.js

+ 23
- 0
modules/RTC/TraceablePeerConnection.js View File

@@ -422,6 +422,8 @@ export default function TraceablePeerConnection(
422 422
         }, 1000);
423 423
     }
424 424
 
425
+    this._lastVideoSenderUpdatePromise = Promise.resolve();
426
+
425 427
     logger.info(`Create new ${this}`);
426 428
 }
427 429
 
@@ -2571,6 +2573,27 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
2571 2573
     if (!localVideoTrack || localVideoTrack.isMuted()) {
2572 2574
         return Promise.resolve();
2573 2575
     }
2576
+
2577
+    // Updating video sender parameters as wrapped-up promise to have ability
2578
+    // to chain promises sequentially later and avoid chrome problem with transaction id
2579
+    // which is reset at the end of video sender setParameters method and can affect
2580
+    // next on-fly update
2581
+    const nextPromise = this._lastVideoSenderUpdatePromise
2582
+        .finally(() => this._updateVideoSenderParameters(frameHeight, localVideoTrack));
2583
+
2584
+    this._lastVideoSenderUpdatePromise = nextPromise;
2585
+
2586
+    return nextPromise;
2587
+};
2588
+
2589
+/**
2590
+ * Configures the video stream with resolution / degradation / maximum bitrates
2591
+ *
2592
+ * @param {number} frameHeight - The max frame height to be imposed on the outgoing video stream.
2593
+ * @param {JitsiLocalTrack} - The local track for which the sender constraints have to be applied.
2594
+ * @returns {Promise} promise that will be resolved when the operation is successful and rejected otherwise.
2595
+ */
2596
+TraceablePeerConnection.prototype._updateVideoSenderParameters = function(frameHeight, localVideoTrack) {
2574 2597
     const videoSender = this.findSenderForTrack(localVideoTrack.getTrack());
2575 2598
 
2576 2599
     if (!videoSender) {

Loading…
Cancel
Save