-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that drawImage(detachedCanvas) throws #43835
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. One small comment.
See whatwg/html#10026 and https://bugs.webkit.org/show_bug.cgi?id=266918 The specs are currently underspecified, though all implementations do agree that a detached OffscreenCanvas has a size of 0, which should throw when passed to drawImage(). Only Safari currently fails the test. A fix is on the way at WebKit/WebKit#22297.
803e33b
to
f6de267
Compare
…webkit.org/show_bug.cgi?id=266918 Reviewed by @mattwoodrow. Explanation of why this fixes the bug. By setting the OffscreenCanvas's `size()` after the DetachedCanvas has been created we ensure that the DetachedCanvas has the correct size to later create the new OffscreenCanvas, and that any method checking the size of the previous OffscreenCanvas, including `drawImage()`, gets the expected `0` width and height. Also deletes the custom `width` and `height` getters from OffscreenCanvas since these were only used to return a "fake" `0` in case the OffscreenCanvas got detached, and that they are now truly `0`. The special handling in `setWidth` and `setHeight` is still required though. Tests are not yet published at web-platform-tests/wpt#43835 * Source/WebCore/html/OffscreenCanvas.cpp: (WebCore::OffscreenCanvas::detach): (WebCore::OffscreenCanvas::width const): Deleted. (WebCore::OffscreenCanvas::height const): Deleted. * Source/WebCore/html/OffscreenCanvas.h: import new WPT tests Manually imported since while web-platform-tests/wpt#43835 has been approved, it still hasn't been merged. drawImage(detachedOffscreenCanvas) is supposed to throw https://bugs.webkit.org/show_bug.cgi?id=266918 Reviewed by @Ahmad-S792. Since the previous change this method was failing to trigger the proper exception type when called on a detached OffscreenCanvas, because now the size is actually empty for detached OffscreenCanvas. We need to separate the case 'detached' and 'no buffer', because zero size OffscreenCanvas will match 'no buffer' and we'd throw an InvalidStateError instead of an IndexSizeError for zero-sized OffscreenCanvas. * Source/WebCore/html/OffscreenCanvas.cpp: (WebCore::OffscreenCanvas::convertToBlob): Canonical link: https://commits.webkit.org/274534@main
Small update/bump, the WebKit patch has landed a few weeks ago and now this test has been manually added there. |
Thanks @Kaiido for your continued efforts on improving canvas! |
See whatwg/html#10026 and https://bugs.webkit.org/show_bug.cgi?id=266918
The specs are currently underspecified, though all implementations do agree that a detached
OffscreenCanvas
has a size of 0, which should throw when passed todrawImage()
.Only Safari currently fails the test. A fix is on the way.
Note that I couldn't run
update-built
due to #23292 and hence I did create the generated html manually...