Use snapshot size instead of canvas size when converting canvas to blob (#36705)

The blob data is encoded asynchronously, therefore the canvas size may
have changed since it's data was saved to a snapshot. Using the canvas
size confuses the encoder, because the provided data does not match the
expected size anymore.

Testing: This change includes a new web platform test
Fixes https://github.com/servo/servo/issues/36702

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-04-26 21:44:12 +02:00 committed by GitHub
parent 18d6981d84
commit 902d2ad8f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 11 deletions

View file

@ -9,6 +9,15 @@
{}
]
],
"canvas": {
"toblob-then-change-size-crash.html": [
"355474b4832dde985a73baad925702bbb0cbc73f",
[
null,
{}
]
]
},
"datatransferitem-crash.html": [
"d11355ab38c1e99e0ba3e10d7dfed18bf26af60b",
[

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<!-- https://github.com/servo/servo/issues/36702 -->
<canvas id="canvas"></canvas>
<script>
canvas.toBlob(() => {});
canvas.width = 0;
</script>