From 258ad3511d24fa2d8d575bf0267a5f8bc6f187c3 Mon Sep 17 00:00:00 2001 From: byGalax Date: Sat, 16 May 2026 19:19:30 +0200 Subject: [PATCH] fix(screen-share): preset dims no longer crop non-16:9 monitors Pass width/height as { ideal: N } constraints (not exact values) so Chromium preserves the source's aspect ratio instead of cropping non-matching monitors. Previously a 1920x1200 monitor under a 1080p preset lost the bottom 120px including the Windows taskbar. The auto-preset fallback now omits width/height entirely (both set to undefined) so getDisplayMedia uses the screen's native resolution. Cast through `unknown` to satisfy LiveKit's VideoResolution type, which declares width/height as plain number but Chromium accepts the full MediaTrackConstraints shape at runtime. --- apps/desktop/src/context/CallContext.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/context/CallContext.tsx b/apps/desktop/src/context/CallContext.tsx index a316843..7773771 100644 --- a/apps/desktop/src/context/CallContext.tsx +++ b/apps/desktop/src/context/CallContext.tsx @@ -1442,20 +1442,29 @@ export function CallProvider({ children }: { children: ReactNode }) { // the same system audio twice and Chromium's version would // include our own renderer playback. audio: preferNativeLoopback ? false : wantAudio, + // Preset dims are passed as `ideal` constraints (not fixed width/height) + // so Chromium picks the closest match preserving the source's aspect + // ratio instead of CROPPING non-matching monitors. Without this, a 16:10 + // monitor (1920×1200, 2560×1600) streamed under a 16:9 preset loses its + // bottom strip — including the Windows taskbar. + // + // LiveKit's VideoResolution types declare width/height as `number`, but + // Chromium's getDisplayMedia accepts the full MediaTrackConstraints shape + // including { ideal: N } objects — we cast through `unknown` to satisfy tsc. ...(ssParams.dims ? { resolution: { - width: ssParams.dims.width, - height: ssParams.dims.height, + width: { ideal: ssParams.dims.width }, + height: { ideal: ssParams.dims.height }, frameRate: fps, - }, + } as unknown as { width: number; height: number; frameRate: number }, } : { resolution: { - width: 3840, - height: 2160, frameRate: fps, - }, + width: undefined, + height: undefined, + } as unknown as { width: number; height: number; frameRate: number }, }), ...(displaySurface ? ({ displaySurface } as { displaySurface: DisplaySurfaceHint })