Skip to content
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

Enable raqote as 2D canvas rendering backend by default #24470

Merged
merged 34 commits into from Dec 18, 2019

Conversation

@pylbrecht
Copy link
Contributor

pylbrecht commented Oct 17, 2019

This will enable raqote by default and make all WPT tests pass.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23431
  • There are tests for these changes
@highfive
Copy link

highfive commented Oct 17, 2019

Heads up! This PR modifies the following files:

@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 17, 2019

I will proceed working on this as described in #24422 (comment).
There are a lot of tests failing and I first have to get familiar with WPT and debugging, I guess.
So please bear with me!

@jrmuizel
Copy link

jrmuizel commented Oct 18, 2019

If you post test results I may be able to help with some of the problems.

@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 20, 2019

@jrmuizel, here's the output of ./mach test-wpt tests/wpt/web-platform-tests/2dcontext/ --release: wpt.log

@jrmuizel
Copy link

jrmuizel commented Oct 20, 2019

It looks like there are some panics inside of path building. This is presumably happening because the PathBuilder is being used after finish() is called.

@jdm
Copy link
Member

jdm commented Oct 23, 2019

@pylbrecht Currently get_current_point does:

let path = self.finish();

If we do:

let path = self.finish();
self.0 = Some(path.clone().into());

Then we should be able to avoid the current problems without needing to add a new API to raqote.

@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 24, 2019

Thanks for the alternative solution! WPT tests are currently running. I'll post a log as soon as the process finishes.

// edit:
Here's the new log file: wpt.log

@jdm
Copy link
Member

jdm commented Oct 24, 2019

If you push the code change we can run a test run on CI.

@jdm
Copy link
Member

jdm commented Oct 24, 2019

Some common failures:

  • assertion failed: g <= a (thread CanvasThread, at /home/palbrecht/.cargo/registry/src/github.com-1ecc6299db9ec823/sw-composite-0.7.0/src/lib.rs:480) (eg. /2dcontext/compositing/2d.composite.canvas.source-atop.html)
  • attempt to multiply with overflow (thread CanvasThread, at /home/palbrecht/.cargo/registry/src/github.com-1ecc6299db9ec823/sw-composite-0.7.0/src/lib.rs:456) (eg. /2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.strokeRect.html)
  • attempt to add with overflow (thread CanvasThread, at /home/palbrecht/.cargo/registry/src/github.com-1ecc6299db9ec823/sw-composite-0.7.0/src/lib.rs:456) (eg. /2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillRect.html)
  • dead end (thread CanvasThread, at components/canvas/raqote_backend.rs:580) (eg. /2dcontext/path-objects/2d.path.arcTo.ensuresubpath.1.html)

All of /2dcontext/shadows/ is expected because we don't implement shadows yet.

Failures like this one make me suspect that raqote might be using antialiasing, but we turn that off in tests in the azure backend:

  ▶ Unexpected subtest result in /2dcontext/path-objects/2d.path.clip.basic.1.html:
  │ FAIL [expected PASS] Canvas test: 2d.path.clip.basic.1
  │   → assert_equals: Green channel of the pixel at (50, 25) expected 255 but got 254
  │ 
  │ _assertPixel@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:39:5
  │ @http://web-platform.test:8000/2dcontext/path-objects/2d.path.clip.basic.1.html:32:1
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  │ _addTest/</<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:66:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  └ _addTest/<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:63:11

We should modify the DrawOptions to disable it when appropriate.

This failure looks like an issue that's exposed because we're now comparing floating point values when we did not used to, so it's actually a missing part of our DOM canvas implementation (filed #24540):

  ▶ Unexpected subtest result in /2dcontext/path-objects/2d.path.isPointInPath.nonfinite.html:
  │ FAIL [expected PASS] isPointInPath() returns false for non-finite arguments
  │   → assert_equals: ctx.isPointInPath(Infinity, 0) === false (got true[boolean], expected false[boolean]) expected false but got true
  │ 
  │ _assertSame@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:17:5
  │ @http://web-platform.test:8000/2dcontext/path-objects/2d.path.isPointInPath.nonfinite.html:23:1
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  │ _addTest/</<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:66:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  └ _addTest/<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:63:11
@jdm
Copy link
Member

jdm commented Oct 24, 2019

I think is_point_in_path may be still be incorrect and causing failures like:

  ▶ Unexpected subtest result in /2dcontext/path-objects/2d.path.isPointInPath.transform.1.html:
  │ FAIL [expected PASS] isPointInPath() handles transformations correctly
  │   → assert_equals: ctx.isPointInPath(10, 10) === false (got true[boolean], expected false[boolean]) expected false but got true
  │ 
  │ _assertSame@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:17:5
  │ @http://web-platform.test:8000/2dcontext/path-objects/2d.path.isPointInPath.transform.1.html:25:1
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  │ _addTest/</<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:66:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  └ _addTest/<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:63:11

It's possible that we are checking the points in the untransformed path, when we should be ensuring that the path has had any transformations applied to it before checking for the presence of a point in it.

@jdm
Copy link
Member

jdm commented Oct 24, 2019

There are various failures related to arc drawing that suggest that we're not doing it right:

  ▶ Unexpected subtest result in /2dcontext/path-objects/2d.path.arc.angle.5.html:
  │ FAIL [expected PASS] arc() wraps angles mod 2pi when clockwise and start > end+2pi
  │   → assert_equals: Red channel of the pixel at (50, 25) expected 0 but got 255
  │ 
  │ _assertPixel@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:38:5
  │ @http://web-platform.test:8000/2dcontext/path-objects/2d.path.arc.angle.5.html:29:1
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  │ _addTest/</<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:66:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  └ _addTest/<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:63:11
@jdm
Copy link
Member

jdm commented Oct 24, 2019

This failure shows that we're ignoring the Filter argument for draw_surface, and we should be including it with https://github.com/jrmuizel/raqote/blob/58cf1a43c02555cfa74571a6c12ed896d39d2dc9/src/draw_target.rs#L203 somehow.

  ▶ Unexpected subtest result in /2dcontext/image-smoothing/imagesmoothing.html:
  │ FAIL [expected PASS] Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) still works after repaints.
  │   → assert_array_equals: property 0, expected 0 but got 174
  │ 
  │ draw@http://web-platform.test:8000/2dcontext/image-smoothing/imagesmoothing.html:110:5
  │ @http://web-platform.test:8000/2dcontext/image-smoothing/imagesmoothing.html:114:5
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  │ test@http://web-platform.test:8000/resources/testharness.js:544:30
  └ @http://web-platform.test:8000/2dcontext/image-smoothing/imagesmoothing.html:98:1
@jrmuizel
Copy link

jrmuizel commented Oct 24, 2019

It would be good to know the parameters to SrcAtop::blend that cause the assertion to fail.

@jrmuizel
Copy link

jrmuizel commented Oct 24, 2019

Yeah, contains_point needs to use the transform.

@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 24, 2019

Thanks for the detailed feedback! I'll dig through it on the weekend. Maybe even by tomorrow, but I can't say for sure.

@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 26, 2019

After applying the transformation in contains_point() like this:

pub fn contains_point(&self, x: f64, y: f64, path_transform: &Transform2D<f32>) -> bool {
    self.as_raqote().clone().transform(path_transform).contains_point(0.1, x as f32, y as f32)
 }

Some of the tests' assertions succeeded, but not all. Especially this last one is still failing:

/2dcontext/path-objects/2d.path.isPointInPath.transform.1.html
  FAIL isPointInPath() handles transformations correctly - assert_equals: ctx.isPointInPath(71, 10) === false (got true[boolean], expected false[boolean]) expected false but got true

I tried changing the tolerance to 0., but without success.

bors-servo added a commit that referenced this pull request Oct 28, 2019
Return false from CanvasState::is_point_in_path for NaN/infinite values

Servo doesn't pass WPT test `/2dcontext/path-objects/2d.path.isPointInPath.nonfinite.html` when built with raqote (see [here](#24470 (comment))).
This change adds a missing check for NaN/infinite values in `CanvasState::is_point_in_path` and fixes this.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24540
- [X] These changes do not require tests because WPT tests cover it
@pylbrecht pylbrecht force-pushed the pylbrecht:raqote branch from a500d97 to 0545e2e Oct 29, 2019
@pylbrecht
Copy link
Contributor Author

pylbrecht commented Oct 29, 2019

Regarding antialiasing: setting it to None by default (23cef5d) did not make the mentioned test (/2dcontext/path-objects/2d.path.clip.basic.1.html) pass. My implementation may be just plain wrong, though.

About the ignored filter argument of draw_surface(): as far as I understand, there are these two cases:

  1. imageSmoothingEnabled == false => use nearest neighbour interpolation
  2. imageSmoothingEnabled == true => apply some sort of smoothing algorithm

Neither of them is implemented yet, correct?
If so, what would be a fitting algorithm?

Furthermore regarding arc_to(): we run into some dead ends inside PathBuilder::get_current_point(). I started debugging this, but my next lecture is in 20min. I'll keep you updated.

@pylbrecht pylbrecht force-pushed the pylbrecht:raqote branch from 23cef5d to 089a323 Oct 29, 2019
@jdm
Copy link
Member

jdm commented Oct 29, 2019

With respect to the antialiasing question, there are other uses of DrawOptions::new() in that file, so try changing the antialiasing member for all of them.

As for the filter question, I linked earlier to the Image variant of the Source enum, which contains a FilterMode enum. We don't have the filter information available when the source surface is created (although we do have the repeat x and y info, so we should fix the TODO there), but we can steal the implementation of DrawTarget::draw_image_with_size_at for our DrawTarget::draw_surface and pass appropriate arguments there.

@jdm
Copy link
Member

jdm commented Oct 29, 2019

@jrmuizel All of the azure backends have code to invert the transform and apply it to the point for their ContainsPoint implementations. Should the raqote backend do something like that as well?

@jrmuizel
Copy link

jrmuizel commented Oct 29, 2019

@jrmuizel All of the azure backends have code to invert the transform and apply it to the point for their ContainsPoint implementations. Should the raqote backend do something like that as well?

Yeah, that's a better thing to do than transforming the path.

@jdm
Copy link
Member

jdm commented Oct 29, 2019

Reading 2d.path.clip.basic.1.html, I translated it into a unit test for raqote and filed jrmuizel/raqote#91. It looks like my antialiasing guess was incorrect and it's a bug related to compositing inside raqote when there is clipping present.

@pylbrecht pylbrecht force-pushed the pylbrecht:raqote branch from 21c17f9 to 38a3f87 Oct 29, 2019
@pylbrecht
Copy link
Contributor Author

pylbrecht commented Nov 1, 2019

It would be good to know the parameters to SrcAtop::blend that cause the assertion to fail.

What parameters exactly? I looked through the involved operations and the only thing I've found in that context was DrawOptions::blend_mode.

@jdm
Copy link
Member

jdm commented Dec 18, 2019

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

Testing commit 4f4c32f with merge 7b10f77...

bors-servo added a commit that referenced this pull request Dec 18, 2019
Enable raqote as 2D canvas rendering backend by default

<!-- Please describe your changes on the following line: -->
This will enable raqote by default and make all WPT tests pass.

---
<!-- 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
- [ ] These changes fix #23431

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 18, 2019

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

Testing commit 4f4c32f with merge ab92000...

bors-servo added a commit that referenced this pull request Dec 18, 2019
Enable raqote as 2D canvas rendering backend by default

<!-- Please describe your changes on the following line: -->
This will enable raqote by default and make all WPT tests pass.

---
<!-- 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
- [ ] These changes fix #23431

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 18, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

Testing commit 4f4c32f with merge dcdf910...

bors-servo added a commit that referenced this pull request Dec 18, 2019
Enable raqote as 2D canvas rendering backend by default

<!-- Please describe your changes on the following line: -->
This will enable raqote by default and make all WPT tests pass.

---
<!-- 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
- [ ] These changes fix #23431

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2019

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing dcdf910 to master...

@bors-servo bors-servo merged commit 4f4c32f into servo:master Dec 18, 2019
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
bors-servo added a commit to servo/saltfs that referenced this pull request Dec 21, 2019
Add pylbrecht to try users.

@pylbrecht is working on replacing azure with raqote in servo/servo#24470 and running the full WPT suite on CI is often useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.