Now I see the Shaka Player config. Let me find the video event handlers for buffering and the watchdog:
Now I understand the problem. The issue is:
rebufferingGoal: 2 for Shaka Player is too low (line 1675), causing aggressive rebufferinghandleStreamError has a 10-second grace period but the initial retry happens at 1 second intervalsLet me fix these issues:
Now let me also improve the HLS.js config for similar streams:
I've fixed the persistent 2-second buffering issue with three key changes:
rebufferingGoal from 3 to 10 seconds, added jumpLargeGaps: true to skip gaps instead of stalling, increased timeout from 60s to 90s, and raised stallThreshold from 1s to 3s to prevent aggressive rebuffering cycles.maxStarvationDelay from 4s to 8s for better resilience.Now I have a clear picture. I can see the root causes of lag over 12 hours:
setHighestQuality calls selectVariantTrack with clearBuffer: true which destroys buffer every time — and it's called repeatedlyrebufferingGoal: 2 inside setHighestQuality — overrides the global fix I made earlier, causing 2s rebuffering againbackBufferLength / bufferBehind growing unbounded — over 12 hours the back-buffer will consume massive RAM causing browser to lag/crashsendHeartbeat / polling at aggressive intervals — accumulate over long sessionsNow I have a full picture. Let me make all the critical fixes:
Root causes found:
setHighestQuality overrides the streaming config with rebufferingGoal: 2 and bufferingGoal: 60 — killing the fixbackBufferLength: 120 / bufferBehind: 120 over 12 hours fills RAM causing browser GC pauses → lagpositionSaveIntervalRef fires every second for live channels (wasteful)Now fix the backBuffer growing unboundedly over 12 hours:
Now fix HLS.js back buffer for the same reason:
Now let me check and fix the viewer heartbeat interval and position save interval:
The intervals look good (heartbeat at 2 min, time at 30s). Now I need to add a periodic RAM cleanup effect that trims the back-buffer every 30 minutes for long sessions, and also add a memory leak guard for the autoRetry stall check which re-fires infinitely if never cleared:
Four targeted fixes were applied:
setHighestQuality no longer overrides the streaming config — the rebufferingGoal: 2 / bufferingGoal: 60 inside that function was silently cancelling all the buffer tuning every time quality was set, causing the persistent 2-second restarts.initializePlayer() instead of retryStream() (which destroys/recreates the player), and guards against re-firing while already recovered.