fix mse buffer trim spinning in a remove loop (#24643)

Subtracting 15s from the buffered end left a floating point remainder, so when Firefox held exactly 15s of buffer the handler called remove() on a near-zero range that removed nothing, and each updateend called it again. The loop pegged a CPU core and kept running after the websocket closed. Trimming now requires more than 1s past the window.
This commit is contained in:
Josh Hawkins
2026-10-12 10:22:02 -06:00
committed by GitHub
parent 7e402d70df
commit cf67f08913
+1 -1
View File
@@ -473,7 +473,7 @@ function MSEPlayer({
} else if (sb.buffered && sb.buffered.length) { } else if (sb.buffered && sb.buffered.length) {
const end = sb.buffered.end(sb.buffered.length - 1) - 15; const end = sb.buffered.end(sb.buffered.length - 1) - 15;
const start = sb.buffered.start(0); const start = sb.buffered.start(0);
if (end > start) { if (end - start > 1) {
sb.remove(start, end); sb.remove(start, end);
msRef.current?.setLiveSeekableRange(end, end + 15); msRef.current?.setLiveSeekableRange(end, end + 15);
} }