Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGetImageData for OffscreenCanvas without an associated canvas element returns blank pixels #24271
Comments
|
@highfive: assign me |
|
Hey @rasviitanen! Thanks for your interest in working on this issue. It's now assigned to you! |
|
Hi! I'm with an NC State group that's been assigned to work on this as a part of a school project. @rasviitanen, have you made progress on this? How can I help? |
|
@bblanke Hey fellow student. I have had some major hardware issues, which has been hindering me from resolving this issue and running the tests properly. I have however, made some progress on this, and created an implementation that for the most part resolves this issue. You could help me investigate this issue. I'll to upload the patch shortly and give a more detailed explanation. I'll make sure to let you know once I upload it. |
|
Awesome! I'm excited to help |
|
@rasviitanen Ah, so the reason the test is "passing" right now is that the existing implementation to compare pixel values relies on GetImageData. If the passing condition for the test is transparent black pixels, the incorrect GetImageData implementation will make the test look like it's passing because the expected pixel data is found. When the bug is fixed, it exposes that the existing canvas implementation that's actually being tested is faulty. |
|
Which tests are you all using to validate this? When I look at the metadata in tests/wpt/metadata/offscreen-canvas all of the tests are set to FAIL |
|
The absence of an ini file for https://github.com/servo/servo/tree/master/tests/wpt/web-platform-tests/offscreen-canvas/the-offscreen-canvas/initial.reset.path.html means the test hardness defaults to expecting it to pass. |
|
Thank you! I'm looking through it now; nice to have a good reference to learn from. |
fix getimagedata returns empty pixels <!-- Please describe your changes on the following line: --> GetImageData for OffscreenCanvas without an associated canvas element returned blank pixels. To solve this, we now pass a `Size2D` instead of a canvas to relevant functions. I don't quite know if it's ok that `OffscreenCanvasRenderingContext2D` now have a `width` and `height`, but I found no other reasonable solution to this. There are some tests that previously were marked as `PASS` that are now failing. It seems that they were passing for the wrong reason. These are: > tests/wpt/metadata/offscreen-canvas/pixel-manipulation/2d.imageData.put.unchanged.html.ini > tests/wpt/metadata/offscreen-canvas/pixel-manipulatio/2d.imageData.put.unchanged.worker.js.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.html.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.worker.js.ini --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24271 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
fix getimagedata returns empty pixels <!-- Please describe your changes on the following line: --> GetImageData for OffscreenCanvas without an associated canvas element returned blank pixels. To solve this, we now pass a `Size2D` instead of a canvas to relevant functions. I don't quite know if it's ok that `OffscreenCanvasRenderingContext2D` now have a `width` and `height`, but I found no other reasonable solution to this. There are some tests that previously were marked as `PASS` that are now failing. It seems that they were passing for the wrong reason. These are: > tests/wpt/metadata/offscreen-canvas/pixel-manipulation/2d.imageData.put.unchanged.html.ini > tests/wpt/metadata/offscreen-canvas/pixel-manipulatio/2d.imageData.put.unchanged.worker.js.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.html.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.worker.js.ini --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24271 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
fix getimagedata returns empty pixels <!-- Please describe your changes on the following line: --> GetImageData for OffscreenCanvas without an associated canvas element returned blank pixels. To solve this, we now pass a `Size2D` instead of a canvas to relevant functions. I don't quite know if it's ok that `OffscreenCanvasRenderingContext2D` now have a `width` and `height`, but I found no other reasonable solution to this. There are some tests that previously were marked as `PASS` that are now failing. It seems that they were passing for the wrong reason. These are: > tests/wpt/metadata/offscreen-canvas/pixel-manipulation/2d.imageData.put.unchanged.html.ini > tests/wpt/metadata/offscreen-canvas/pixel-manipulatio/2d.imageData.put.unchanged.worker.js.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.html.ini > tests/wpt/metadata/offscreen-canvas/the-offscreen-canvas/initial.reset.path.worker.js.ini --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24271 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Code:
servo/components/script/dom/canvasrenderingcontext2d.rs
Lines 281 to 284 in 4fe8238
servo/components/script/dom/canvasrenderingcontext2d.rs
Lines 281 to 284 in 4fe8238
servo/components/script/dom/canvasrenderingcontext2d.rs
Lines 1056 to 1058 in 4fe8238
In cases like
OffscreenCanvasRenderingContext2D::GetImageDatawhen there is no associated canvas element (eg. https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/offscreen-canvas/drawing-rectangles-to-the-canvas/2d.clearRect.clip.html), we need to provide a real canvas size. I propose we replace the optional canvas element argument with a canvas size argument instead, and modify the callers to pass it in as appropriate.We should get a bunch of tests with better results when running
./mach test-wpt tests/wpt/web-platform-tests/offscreen-canvas.