Looks like Chrome have a bug with CanvasRenderingContext2D
and drawImage from a video element when tab gets suspended by a browser (if user focuses a different tab).
Code like that doesn't work anymore when tab is in a background, audio continues to play, timeupdate events of a video are getting fired as usual, but drawImage
draws the same frame on every tick:
const video = document.getElementById('video');
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
...
setInterval(() => ctx.drawImage(videoElement, 0, 0), 33);
This issue is not related to timer throttling (tested with timer events from background workers, drawing current time on a canvas in the same interval and etc).
Does anyone have ideas why is it happening and how to prevent Chrome from suspending video element?