From f3de5e54d08ce1ff57180a60c2a5afd1ac8c8590 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 22 Jul 2026 14:55:11 +0200 Subject: [PATCH] fix(call): do not downscale screenshare on Firefox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Firefox defaults the VP8/VP9 "max-fs" to ~QHD (~2560×1440 px): - a=fmtp:120 max-fs=12288;max-fr=60 - Raising it lets Firefox encode up to 4K (3840×2160 px): - a=fmtp:120 max-fs=36864;max-fr=60 Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Maksim Sukharev --- src/utils/webrtc/simplewebrtc/peer.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/utils/webrtc/simplewebrtc/peer.js b/src/utils/webrtc/simplewebrtc/peer.js index 2f592176c44..a4e397242d9 100644 --- a/src/utils/webrtc/simplewebrtc/peer.js +++ b/src/utils/webrtc/simplewebrtc/peer.js @@ -356,6 +356,22 @@ function mungeSdpForSimulcasting(sdp) { } /* eslint-enable */ +/** + * Raises the "max-fs" (maximum frame size in macroblocks - 16x16 px) + * codec parameter in an SDP so high-resolution screens are not downscaled. + * Firefox defaults the VP8/VP9 "max-fs" to ~QHD (2560×1440px): + * - a=fmtp:120 max-fs=12288;max-fr=60 + * Raising it lets Firefox encode up to ~4K (3840×2160px): + * - a=fmtp:120 max-fs=36864;max-fr=60 + * Other browsers are not noticed to be affected with that limitation. + * + * @param {string} sdp the SDP string to munge + * @return {string} the updated SDP string + */ +function mungeSdpForScreenMaxFs(sdp) { + return sdp.replace(/max-fs=\d+/g, 'max-fs=' + 36864) +} + Peer.prototype.offer = function(options) { const sendVideo = this.sendVideoIfAvailable && this.type !== 'screen' if (sendVideo && this.enableSimulcast && adapter.browserDetails.browser === 'firefox') { @@ -401,6 +417,12 @@ Peer.prototype.offer = function(options) { } } + // SDP munging only needed for Firefox screensharing (for 4K screens) + if (this.type === 'screen' && adapter.browserDetails.browser === 'firefox') { + console.debug('Raising VP8/9 max-fs for Firefox screensharing') + offer.sdp = mungeSdpForScreenMaxFs(offer.sdp) + } + this.pc.setLocalDescription(offer).then(function() { if (this.parent.config.nick) { // The offer is a RTCSessionDescription that only serializes