Skip to content

Commit 250ff7e

Browse files
committedJan 16, 2025
fix(video-quality) Fixes an issue where outbound resolution can be stuck 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.
1 parent 115065f commit 250ff7e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎modules/RTC/TraceablePeerConnection.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -2057,10 +2057,10 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
20572057
}
20582058
const sourceName = localVideoTrack.getSourceName();
20592059

2060+
this._senderMaxHeights.set(sourceName, frameHeight);
2061+
20602062
// Ignore sender constraints if the video track is muted.
20612063
if (localVideoTrack.isMuted()) {
2062-
this._senderMaxHeights.set(sourceName, frameHeight);
2063-
20642064
return Promise.resolve();
20652065
}
20662066

@@ -2125,7 +2125,6 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
21252125
let bitrates = this.tpcUtils.calculateEncodingsBitrates(localVideoTrack, codec, frameHeight);
21262126
const scalabilityModes = this.tpcUtils.calculateEncodingsScalabilityMode(localVideoTrack, codec, frameHeight);
21272127
let scaleFactors = this.tpcUtils.calculateEncodingsScaleFactor(localVideoTrack, codec, frameHeight);
2128-
const sourceName = localVideoTrack.getSourceName();
21292128
let needsUpdate = false;
21302129

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

21992198
if (!needsUpdate) {
2200-
this._senderMaxHeights.set(sourceName, frameHeight);
2201-
22022199
return Promise.resolve();
22032200
}
22042201

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

22072204
return videoSender.setParameters(parameters).then(() => {
2208-
this._senderMaxHeights.set(sourceName, frameHeight);
22092205
localVideoTrack.maxEnabledResolution = frameHeight;
22102206
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
22112207
});

0 commit comments

Comments
 (0)
Please sign in to comment.