Bug 257016

Summary: Media recorder produces empty chunks
Product: WebKit Reporter: Jozef <32jojo32>
Component: CanvasAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, eric.carlson, jer.noble, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
canvas-bug-mwe none

Jozef
Reported 2023-05-19 03:01:39 PDT
Created attachment 466413 [details] canvas-bug-mwe When attaching MediaStream before context in canvas is created then MediaRecorder produces only empty chunks. Steps to replicate: 1. Open the provided html file 2. Click the button 3. You will see only empty chunks in console 4. Uncomment the line #14 and comment code on line #17 5. Click the button again 6. You will see one non-empty chunk in console
Attachments
canvas-bug-mwe (1.01 KB, text/html)
2023-05-19 03:01 PDT, Jozef
no flags
youenn fablet
Comment 1 2023-05-23 02:34:29 PDT
I reproduced the issue. The difference seems to be that HTMLDocument is made observer of the canvas when it works and not when it works. It follows that Document::canvasChanged is called which triggers preparation of canvas, which triggers a video frame in the stream.
Radar WebKit Bug Importer
Comment 2 2023-05-23 02:34:47 PDT
youenn fablet
Comment 3 2023-05-23 02:36:54 PDT
In the failing case, CanvasCaptureMediaStreamTrack::Source::canvasChanged returns early because the rendering context needsPreparationForDisplay returns true. But the document is not observing the canvas so ends up not triggering the code path of HTMLCanvasElement::prepareForDisplay.
youenn fablet
Comment 4 2023-05-23 03:48:59 PDT
EWS
Comment 5 2023-05-24 09:19:36 PDT
Committed 264478@main (712b8a916d0d): <https://commits.webkit.org/264478@main> Reviewed commits have been landed. Closing PR #14236 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.