Skip to content

Commit

Permalink
fix(video-quality) Fixes an issue where outbound resolution can be st…
Browse files Browse the repository at this point in the history
…uck at wrong resolution.

The calls to RTCRtpSender.setParameters() are all chained and the current maxHeight is set after the call to setParameters is resolved. If there is another call made to setParameters before the previous one resolves, we can end up passing the wrong maxHeight resulting in the client getting stuck at an unexpected resolution. This issue can be reproduced sometimes  when the users are moving across the main and breakout rooms. TPC.setVideoCodecs() ends up pushing a wrong maxHeight for update when the previous call to setParameters hasn't resolved yet.
  • Loading branch information
jallamsetty1 committed Jan 16, 2025
1 parent 115065f commit 250ff7e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2057,10 +2057,10 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
}
const sourceName = localVideoTrack.getSourceName();

this._senderMaxHeights.set(sourceName, frameHeight);

// Ignore sender constraints if the video track is muted.
if (localVideoTrack.isMuted()) {
this._senderMaxHeights.set(sourceName, frameHeight);

return Promise.resolve();
}

Expand Down Expand Up @@ -2125,7 +2125,6 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
let bitrates = this.tpcUtils.calculateEncodingsBitrates(localVideoTrack, codec, frameHeight);
const scalabilityModes = this.tpcUtils.calculateEncodingsScalabilityMode(localVideoTrack, codec, frameHeight);
let scaleFactors = this.tpcUtils.calculateEncodingsScaleFactor(localVideoTrack, codec, frameHeight);
const sourceName = localVideoTrack.getSourceName();
let needsUpdate = false;

// Do not configure 'scaleResolutionDownBy' and 'maxBitrate' for encoders running in VP9 legacy K-SVC mode since
Expand Down Expand Up @@ -2197,15 +2196,12 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
}

if (!needsUpdate) {
this._senderMaxHeights.set(sourceName, frameHeight);

return Promise.resolve();
}

logger.info(`${this} setting max height=${frameHeight},encodings=${JSON.stringify(parameters.encodings)}`);

return videoSender.setParameters(parameters).then(() => {
this._senderMaxHeights.set(sourceName, frameHeight);
localVideoTrack.maxEnabledResolution = frameHeight;
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
});
Expand Down

0 comments on commit 250ff7e

Please sign in to comment.