-
-
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
Entanglement game panics while cropping image in canvas thread #15386
Comments
I'm pretty sure the problem is in the calculation of crop_area_bytes_length, which multiplies crop_rect.size.height by itself, and ignores crop_rect.size.width. |
Please make a comment here if you intend to work on this issue. Thank you! |
I am taking a stab. |
Here's what I did index 4377855..2eb11d5 100644
--- a/components/canvas/canvas_paint_thread.rs
+++ b/components/canvas/canvas_paint_thread.rs
@@ -745,7 +745,7 @@ fn crop_image(image_data: Vec<u8>,
// (consecutive elements in a pixel row of the image are contiguous in memory)
let stride = image_size.width * 4;
let image_bytes_length = image_size.height * image_size.width * 4;
- let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.height * 4;
+ let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.width * 4;
// If the image size is less or equal than the crop area we do nothing
if image_bytes_length <= crop_area_bytes_length {
return image_data;
Now,
|
To be clear, I get the same output and the same blank page without my patch applied. Please advise :) |
Alright, thanks! Wasn't sure whether the other problems would come before or after the panic. Pull Request coming in. |
…not height*height) (fixes servo#15386)
crop_area_bytes_length multiplies width and height (fixes #15386) <!-- Please describe your changes on the following line: --> `crop_image()` in component/canvas/canvas_paint_thread.rs calculated the crop_area_bytes_length variable by multiplying `height*height*4` It should multiply `height*width*4`, like so ```diff - let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.height * 4; + let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.width * 4; ``` --- <!-- 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 #15386 <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ ^--- Not entirely sure here ;) <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15423) <!-- Reviewable:end -->
I would like to work on this. Is drawing-images-to-the-canvas the correct position for the test? @highfive: assign me |
Hey @n0max! Thanks for your interest in working on this issue. It's now assigned to you! |
No, we don't support the OffscreenCanvas API yet. A test belongs in tests/wpt/web-platform-tests/2dcontext/drawing-images-to-the-canvas/ instead. |
I have some problems to write a test that fails without the fix. The error is only visible on a image with height > width and crop_rect.origin.x > 0. |
A data URL would work as well, but there's nothing wrong with adding new image files. |
Fix crop_area_bytes_length calculation and add tests <!-- Please describe your changes on the following line: --> - Fix crop_area_bytes_length calculation (the height was multiplied by itself) - Add tests for this error and for the case that the width is multiplied by itself --- <!-- 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 #15386 <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15929) <!-- Reviewable:end -->
Fix crop_area_bytes_length calculation and add tests <!-- Please describe your changes on the following line: --> - Fix crop_area_bytes_length calculation (the height was multiplied by itself) - Add tests for this error and for the case that the width is multiplied by itself --- <!-- 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 #15386 <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15929) <!-- Reviewable:end -->
http://entanglement.gopherwoodstudios.com/
The text was updated successfully, but these errors were encountered: