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 upSupport OffscreenCanvas as CanvasImageSource #24269
Comments
|
On this |
|
Okay! I made some changes to the repo, and there are now 30 new tests passing! However, none of them are in drawing-images-to-the-canvas. I'm trying to figure out what's missing. I added a match statement in canvas_state.rs to call the proper draw function when an offscreen canvas is passed in. I then created my own version of the draw_html_canvas_element_offscreen that basically does the same as the original function, but instead of matching a "normal" canvas's context, it matches for an OffscreenCanvasContext and sends it a message to draw the source's canvas into it. Do you see anything inherently wrong with this? I'd appreciate any help that you could offer! Also, how do you effectively debug? Is there a way to view print statements from Rust code while running tests? Do I need to just bite the bullet and learn how to use GDB? What's your best advice on this? Thanks so much for your time! |
|
It's most effective to run a single test along with the As for the code snippets, those seem reasonable to me (and nothing else in master...bblanke:OffscreenCanvasasCanvasImageSoure seems unreasonable). I recommend deleting the contents of https://github.com/bblanke/servo/blob/13ba9da91cd840fe721e1caa8141f8427b5c8058/tests/wpt/metadata/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.canvas.html.ini and running that test to see the exact failing output that is reported. That might help narrow down where the failure is coming from. |
|
As for gdb, that can definitely be an efficient way to figure out if code is actually running. You can go a long way with the following commands: You can use |
|
GDB is working great Good article for anyone else that finds themselves here: https://lldb.llvm.org/use/tutorial.html |
|
Ah, when you said GDB I assumed you were actually using GDB, not LLDB :) |
|
Lol shoot yeah lldb! Through lldb, I found out that the functions that I expect to get called are indeed getting called (specifically, draw_html_canvas_offscreen). I also know that the test is failing because there's a location where the code expects a colored pixel, but the pixel is black. So, I'm wondering if there's something wrong with the way that I request the destination canvas to draw the source canvas onto it (through Canvas2dMsg::DrawImageInOther)? Does OffscreenCanvas need something added to it to make it support this operation? |
|
I recommend adding some assertions to the test to verify that the canvas that's being used as the image source contains the expected pixels before the draw operation occurs. That should narrow down where the unexpected behaviour is stemming from. |
|
Figured it out! The Offscreen Canvas's width and height properties were switched. I fixed that and ran tests and now 830 new tests are passing... Few questions:
|
|
Woo! I'm pretty sure this is just a lucky bug fix if a lot of tests happen to rely on using OffscreenCanvas as an image source. We already pass lots of onscreen canvas tests and the offscreen canvas uses the exact same backend, so this result makes sense to me. You can run the tests for a particular directory with |
|
With very convenient timing, we just merged 03e574f which incorporated web-platform-tests/wpt#20277. You will need to rebase your changes to master and regenerate the test results; I suspect they will be less overwhelmingly fail->pass as a result. |
…try> Addresses Issue: Support OffscreenCanvas as CanvasImageSource #24269 Added methods to canvas_data to support drawing an offscreen canvas onto another canvas Bug fix: Swapped OffscreenCanvas width and height parameters to match Mozilla spec Tests: Updated metadata for 866 tests <!-- Please describe your changes on the following line: --> --- <!-- 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 #24269 (GitHub issue number if applicable) <!-- Either: --> - [x] These changes do not require tests because they are covered by existing tests <!-- 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. -->
|
Alright; I think I have it now. Submitted an incorrect commit earlier. |
Addresses Issue: Support OffscreenCanvas as CanvasImageSource #24269 Added methods to canvas_data to support drawing an offscreen canvas onto another canvas Bug fix: Swapped OffscreenCanvas width and height parameters to match Mozilla spec Tests: Updated metadata for 866 tests <!-- Please describe your changes on the following line: --> --- <!-- 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 #24269 (GitHub issue number if applicable) <!-- Either: --> - [x] These changes do not require tests because they are covered by existing tests <!-- 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. -->
Support OffscreenCanvas as CanvasImageSource Added methods to canvas_data to support drawing an offscreen canvas onto another canvas Bug fix: Swapped OffscreenCanvas width and height parameters to match Mozilla spec Tests: Updated metadata for 866 tests <!-- Please describe your changes on the following line: --> --- <!-- 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 #24269 (GitHub issue number if applicable) <!-- Either: --> - [x] These changes do not require tests because they are covered by existing tests <!-- 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/webidls/CanvasRenderingContext2D.webidl
Line 15 in 4fe8238
servo/components/script/dom/canvasrenderingcontext2d.rs
Lines 335 to 350 in 4fe8238
servo/components/script/dom/canvasrenderingcontext2d.rs
Lines 359 to 419 in 4fe8238
Tests:
./mach test-wpt tests/wpt/web-platform-tests/offscreen-canvas/drawing-images-to-the-canvasshould report newly passing testsWe'll want to generalize draw_html_canvas_element to support offscreen canvases as well, since the majority of the code is applicable to both. An enum argument is probably the best way to do that.