Bug 240380 - Capturing a canvas that is not in the DOM can lead to erratic frame rates or no frame emission at all
Summary: Capturing a canvas that is not in the DOM can lead to erratic frame rates or ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dan Glastonbury
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-05-13 05:05 PDT by youenn fablet
Modified: 2022-05-25 20:16 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2022-05-13 05:05:20 PDT
Capturing a canvas that is not in the DOM can lead to erratic frame rates or no frame emission at all
Comment 1 Radar WebKit Bug Importer 2022-05-13 05:05:45 PDT
<rdar://problem/93239022>
Comment 2 Said Abou-Hallawa 2022-05-13 11:49:39 PDT
Test case is https://jsfiddle.net/0b3dqxeg/
Comment 3 Claudio Destro 2022-05-16 23:10:56 PDT
Hi hope this helps:

in our solution, canvas with CSS fixed position works
Comment 4 Claudio Destro 2022-05-16 23:15:39 PDT
Example missing (sorry):

modify the test case to:

<canvas id="canvas2" style="position: fixed; bottom: 0; right: 0; width: 100px"></canvas>

videos still not playing in 15.4 desktop (they show a red background and nothing else happens)
Comment 5 youenn fablet 2022-05-17 02:39:00 PDT
I did some investigations:
- CanvasCaptureMediaStreamTrack::Source::canvasChanged is correctly called each time the not-in-dom canvas is changed but it returns early due to m_canvas->renderingContext()->needsPreparationForDisplay() returning true.
- Normally, the page will call updateRendering which will make the actual preparation happening, which in turn will tell CanvasCaptureMediaStreamTrack::Source to generate a frame. This is what happens when canvas is in the DOM. When canvas is not in the DOM, Page::updateRendering is not called as often and this impacts the canvas track frame rate.
Comment 6 Dan Glastonbury 2022-05-22 21:18:37 PDT
Pull request: https://github.com/WebKit/WebKit/pull/901
Comment 7 EWS 2022-05-25 20:16:07 PDT
Committed r294864 (250996@main): <https://commits.webkit.org/250996@main>

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