Bug 266918

Summary: drawImage(detachedOffscreenCanvas) is supposed to throw
Product: WebKit Reporter: Kaiido <tristan.fraipont>
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, heycam, mattwoodrow, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   

Kaiido
Reported 2023-12-27 18:40:49 PST
When transferring an OffscreenCanvas its width and height attributes become zero. Drawing such a detached OffscreenCanvas through a 2D context's drawImage() method should thus throw a DOMException (from https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument). However it seems the check for the image size still uses the dimension of the OffscreenCanvas from before it got detached as can be seen in both fiddles: https://jsfiddle.net/9zvx6bok/ & https://jsfiddle.net/9zvx6bok/1/ In the first one we draw a detached OffscreenCanvas on a 2D context, where this shouldn't be possible since the reported dimensions are both zero. In the second one, we do set the OffscreenCanvas's dimension to zero before detaching it. This one throws as expected, demonstrating that drawImage() checks the dimensions before the transfer happened.
Attachments
Kaiido
Comment 1 2024-01-02 02:07:59 PST
Radar WebKit Bug Importer
Comment 2 2024-01-03 18:41:13 PST
EWS
Comment 3 2024-02-13 02:52:11 PST
Committed 274534@main (5dbd0444ac2e): <https://commits.webkit.org/274534@main> Reviewed commits have been landed. Closing PR #22297 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.