Bug 242679

Summary: [macOS] Canvas.getContext('2d').drawImage on a camera video stream does not work when tab is backgrounded
Product: WebKit Reporter: youenn fablet <youennf>
Component: MediaAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: ansarman, dino, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description youenn fablet 2022-07-13 01:07:50 PDT
1. Load https://jsfiddle.net/eq5upzh6/.
2. Grant prompt
3. Once the camera starts, switch to another tab and change what the camera captures.
4. Wait 6 seconds
5. Switch back to the JSFiddle tab.

One of the canvas (canvas1) stayed to a camera frame just before the switch to the other tab.
We would expect canvas1 to keep being updated even when the other tab is backgrounded.
Comment 1 Radar WebKit Bug Importer 2022-07-13 01:08:08 PDT
<rdar://problem/96937033>
Comment 2 youenn fablet 2022-07-13 01:08:49 PDT
This bug was externally reported.
Comment 3 Anastasiya Sarmant 2022-07-13 01:22:20 PDT
The canvas stops streaming when the tab becomes inactive.
Comment 4 youenn fablet 2022-07-22 04:15:51 PDT
In the jsfiddle, the video element is not playing any audio and might be paused when page goes to background.
One way to prevent it is to add a silent audio track. For instance https://jsfiddle.net/0h5edpLw/.

This raises the question of what happens to media elements which get paused as not visible+silent while they are repeatedly drawn to canvas.
In a sense, these media elements are visible so we should probably not pause them.
Comment 5 youenn fablet 2022-07-22 06:50:14 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2655
Comment 6 EWS 2022-07-22 12:19:12 PDT
Committed 252738@main (de9dae2e5319): <https://commits.webkit.org/252738@main>

Reviewed commits have been landed. Closing PR #2655 and removing active labels.