1 Commits
Author SHA1 Message Date
Meta42 4c7d0aa9fa fix: audio pump starvation on large files with audio (#1041)
Root causes fixed:
1. Remove starvation check that suspends AudioContext — it freezes the
   video clock and causes playback to stall permanently
2. Add backpressure (1s BUFFER_AHEAD) to prevent audio pump from decoding
   unbounded buffers, starving the video decoder
3. Add setTimeout(0) yield between batches so video rAF callbacks can run
4. Batch audio buffer reads (16 per iteration) to reduce IPC overhead
5. Fix latestScheduledEndTime time-domain: use media-time (same domain as
   currentTime) instead of AudioContext-time, so backpressure check works
   correctly after seeking

Without these fixes, playing a large file (9+ GB) with audio causes:
- Audio pump decodes hundreds of buffers in 1 second (195s of audio decoded
  in 1s wall clock)
- Main thread blocked by 177 IPC calls/sec from audio iterator
- Video frames never render (rAF starved)
- After seek: backpressure never triggers due to time-domain mismatch,
  causing persistent stutter and eventual silence
2026-06-07 09:18:04 +08:00