Bug 266918 - drawImage(detachedOffscreenCanvas) is supposed to throw
Summary: drawImage(detachedOffscreenCanvas) is supposed to throw
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-12-27 18:40 PST by Kaiido
Modified: 2024-02-13 02:52 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaiido 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.
Comment 1 Kaiido 2024-01-02 02:07:59 PST
Pull request: https://github.com/WebKit/WebKit/pull/22297
Comment 2 Radar WebKit Bug Importer 2024-01-03 18:41:13 PST
<rdar://problem/120451062>
Comment 3 EWS 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.