Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions web/js/components/preact/HLSVideoCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,17 @@ export function HLSVideoCell({

useEffect(() => {
if (privacyActive) {
const focused = document.activeElement;
const container = tileContainerRef.current;
const focusedInTile = focused instanceof Node && !!container?.contains(focused);

if (!focusedInTile && focused !== document.body) {
hadPrivacyFocusRef.current = false;
previousFocusedElementRef.current = null;
return;
}

if (!hadPrivacyFocusRef.current) {
const focused = document.activeElement;
previousFocusedElementRef.current = focused instanceof HTMLElement && focused !== document.body
? focused : null;
}
Expand All @@ -106,6 +115,13 @@ export function HLSVideoCell({
}

if (!hadPrivacyFocusRef.current) return;
if (document.activeElement !== privacyResumeButtonRef.current &&
document.activeElement !== document.body) {
hadPrivacyFocusRef.current = false;
previousFocusedElementRef.current = null;
return;
}

hadPrivacyFocusRef.current = false;
const previous = previousFocusedElementRef.current;
if (previous && previous.isConnected) {
Expand Down Expand Up @@ -403,8 +419,8 @@ export function HLSVideoCell({
console.log(`Using HLS.js for stream ${stream.name} (mode: ${usingGo2rtc ? 'go2rtc' : 'native'})`);

// Shared low-memory budget: keep only a small forward buffer and zero back-buffer.
// backBufferLength: 0 is the single biggest win — HLS.js default keeps decoded
// frames forever for seeking, which multiplies by stream count and crashes the tab.
// backBufferLength: 0 removes played media from the buffer as playback advances,
// which helps reduce memory pressure across many concurrent streams.
const sharedMemoryConfig = {
maxBufferLength: 4, // seconds of forward buffer (default: 30)
maxMaxBufferLength: 8, // hard ceiling (default: 600)
Expand Down
Loading