fix: use LiveKit track.attach() for adaptive stream and switch screen share to VP9 single-layer

Camera was stuck at 180p because our custom <video> rendering bypassed
LiveKit's adaptive stream observer. Replaced manual srcObject binding
with track.attach()/detach() in VoiceUser, StreamTile, and PictureInPicture
so the SFU receives viewport dimensions and forwards the correct
H.264 simulcast layer.

Screen share VP9 SVC with L3T3 spatial layers failed because hardware
VP9 encoders (NVENC, QSV, VCE) don't support spatial scalability —
Chrome silently degrades to L1T1. Reverted to VP9 single-layer
(simulcast: false, no scalabilityMode). Also targets encodings[length-1]
in applyOverdrive() for correct simulcast layer targeting.
This commit is contained in:
Jannis Braun
2026-02-26 02:33:18 +01:00
parent 33e9198de6
commit 4bb69851d3
5 changed files with 55 additions and 24 deletions
@@ -122,17 +122,26 @@ export function PictureInPicture() {
return 'Call';
}, [currentVoiceChannelId, channels]);
// Video track attachment
// Derive the LiveKit Track from the selected stream's participant
const lkTrack = selectedStream
? (selectedStream.type === 'screen'
? selectedStream.participant.lkScreenTrack
: selectedStream.participant.lkVideoTrack)
: null;
// Video track attachment — use LiveKit's track.attach() to register the element
// with the adaptive stream observer (enables SFU layer switching by viewport size)
// shouldShow in deps ensures re-run when PiP becomes visible (videoRef was null before)
useEffect(() => {
const videoEl = videoRef.current;
if (!videoEl) return;
if (selectedStream?.track) {
videoEl.srcObject = new MediaStream([selectedStream.track]);
if (lkTrack) {
lkTrack.attach(videoEl);
return () => { lkTrack.detach(videoEl); };
} else {
videoEl.srcObject = null;
}
}, [selectedStream?.track, shouldShow]);
}, [lkTrack, shouldShow]);
// Initialize position to bottom-right
useEffect(() => {