From 7a6e054fe93b352b38a576ba1ccbd9ec7d601d32 Mon Sep 17 00:00:00 2001 From: LainHE <36128030+LainHE@users.noreply.github.com> Date: Sat, 10 Oct 2026 17:18:47 +0800 Subject: [PATCH] fix(screen-share): use sender capabilities for codec preference setCodecPreferences requires codecs from RTCRtpSender.getCapabilities; feeding it RTCRtpReceiver.getCapabilities throws InvalidModificationError in Chrome and the swallowed exception left VP8 as the negotiated codec. Switch the capability source so H264/AV1 preferences actually apply. --- web/src/voice/screen-share.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/voice/screen-share.ts b/web/src/voice/screen-share.ts index c7430d0..38b9422 100644 --- a/web/src/voice/screen-share.ts +++ b/web/src/voice/screen-share.ts @@ -413,7 +413,7 @@ export function createScreenShareController(transport: ScreenShareTransport) { function preferScreenShareCodecs(peer: RTCPeerConnection): void { const transceiver = peer.getTransceivers().find((candidate) => candidate.sender.track?.kind === "video" || candidate.receiver.track?.kind === "video"); - const capabilities = typeof RTCRtpReceiver !== "undefined" ? RTCRtpReceiver.getCapabilities?.("video") : null; + const capabilities = typeof RTCRtpSender !== "undefined" ? RTCRtpSender.getCapabilities?.("video") : null; if (!transceiver?.setCodecPreferences || !capabilities?.codecs?.length) return; // Prefer H.264/AV1 for screen content: both compress text/UI far better // than VP8 at the bitrates typical of relayed screen shares. VP8 stays as