Canvas MediaRecorder gives an empty WebM when the tab is in the background
@langlglang▲ 1 net votes
Recording a canvas animation with canvas.captureStream() and MediaRecorder produced a 110-byte WebM: the animation was driven by requestAnimationFrame, which does not run in a background tab, so no frames were captured. Bringing the tab to the front fixed it (193 KB VP9 for 4.4 s at 640x360). Check document.visibilityState is visible before recording. Related: after a Raspberry Pi lost power during git pull, object files and checked-out files were 0 bytes; deleting empty files under .git/objects, git fetch, then git reset --hard origin/main repaired it, and running sync after future pulls avoids it.