-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use 'pixelated' as fallback of 'crisp-edges' in object-position tests #53930
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
base: master
Are you sure you want to change the base?
Use 'pixelated' as fallback of 'crisp-edges' in object-position tests #53930
Conversation
1c5db12
to
65cf9f3
Compare
In general, shouldn't that be considered a Chrome bug, and annotated locally as expected-failure or expected-fuzz in Chromium's source tree rather than in the test itself? The intent in these tests is that there shouldn't be small pixel differences, since we're scaling the same image to the same target-size in all cases, and
I'm willing to believe it's not useful for some of the cases (maybe for Also, looking at your PR, it looks like some of the testcases where you're adding fuzz are testcases that Chromium currently passes on wpt.fyi, so I wonder if some of the patch's fuzz is in fact accounting for your |
For example, your PR is adding substantial fuzz ( |
Looking at the actual current Chromium failures that wpt.fyi shows for these tests (-001 tests, -002 tests), I'm seeing two different categories of issues: (2) For PNG images: It looks like Chrome is incorrectly doing some antialiasing when scaling up an image in these tests, and perhaps doing it an inconsistent way, despite Screenshot of -002 version, in compare-view, to highlight the differing region and what the pixel-differences look like (purpleish in the left half, greenish in the right half): There's a similar issue here where the reference case seems to be doing more color-blending than the testcase: |
For the two issues I noted above:
|
Aha -- it occurred to me that maybe Chromium might lack a way to annotate expected-fuzz (from e.g. Chrome-specific bugs/optimizations/etc) outside of the test itself -- asked in https://matrix.to/#/#wpt:matrix.org and it seems that is indeed not something Chromium's WPT-running/annotating infra supports right now. Jonathan Lee kindly filed this ticket to add this ability for Chromium: https://crbug.com/434057608 In the meantime, I guess we're stuck using the meta tag inside the test itself to encode any Chromium-specific expected fuzziness, which means the existing fuzzy annotations (which exist for that reason) are ~fine and can be updated as-needed; but my notes in #53930 (comment) still stand as a reason this current PR seems off-track, unless I'm missing something. |
First of all, I agree that there are at least 2 issues in Chrome that make these tests to fail in cases unrelated to the property being tests, which is mainly object-position: 1- the With this PR I just wanted to look for alternatives to make these tests useful in Chrome without requiring big implementation changes. In the case of the issue 1, I guess it's going to be implemented eventually, I it may take time. The issue 2 is trickier and I've been told that it's a long-standing issue in the Chrome rendering pipeline that it's going to be hard to get rid of. So, even with the crisp-edge feature implemented, I'm not sure we would get rid of all the small pixel differences. In fact, the original tests had already a few "fuzzy" tags in some tests.
I agree the crisp-edges has an impact visually, but as far as I understand, it doesn't affect to the test itself, as long as the scaling effects is similar in both, the test and the reference file. This seems to be the case in most of the tests for Firefox at least (I believe it's also the case for Safari). If we can agree on this, we can provide a solution for the failing tests cases; either we change the offset values or assume the differences with the fuzzy tag. These are the test failing in Firefox just after removing the 'image-rendering: edge-crispy' feature (see the PR for details): /css/css-images/object-fit-contain-png-001c.html 1 / 1 0 / 1
Umm, interesting. This shouldn't be the case, given that the image-rendering property is parsed as invalid in Chrome, so it shouldn't take any effect. Let me study those cases a bit more.
I think these 2 tests fail in Safari when removing the 'edge-crisy' feature. These would be one of those cases I mentioned we should analyze better, and either assume the pixel difference or change the offset to avoid it. Regarding the amount of pixels, I believe it's so much because it fails in the same area for all the 7 the cases defined in the test. But yeah, I agree it may cause that we miss some legit test failures, though.
Yeah, that's true, although I think it the issue about 'object-fit' not being applied it was affecting "embed" only, but I'll check it again. Anyway, I agree this is a legit bug in Chrome and will be reflected as such in wpt-fyi.
These are the cases I would like the test to avoid detecting, given that the main goal of the tests is to determine if the object-position property is applied correctly. I agree that we may miss some failures caused by tiny errors in the position calculations, but perhaps it's something that we can verify with testharness based tests instead. |
MDN says it's supported under a nonstandard name Testing that briefly locally, I'm not sure if that helps, but I think
Those fuzzy tags were added by another Chromium engineer I think, as part of a Chromium rendering implementation change that introduced some Chromium-specific fuzziness here. (These tests didn't have any fuzzy tags when they were added to WPT, in 2b2a359 ).
It definitely affects the validity of the test. The default "auto" image-upscaling-behavior is unspecified and is allowed to be context-dependent (e.g. might be a bit different for video vs. img vs. canvas). Browser engines do take advantage of this flexibility, as can be seen by the fact that some of these tests fail in a fuzzy way in Chromium (without a recognized Only when specifying
The point is also to confirm that |
tl;dr to make these tests perform better on Chromium, I'd be happy swapping all
...for:
Maybe this largely addresses your concerns? If there's still substantial fuzziness/failures at that point, I'd be curious to learn more. (But hopefully any failures at that point are pretty minimal.) I think (Pixelated allows unspecified UA-defined smoothing when scaling to a non-integer value -- which includes downscaling -- as resolved in w3c/csswg-drafts#5837 and specced in https://drafts.csswg.org/css-images-3/#valdef-image-rendering-pixelated . This is what I was alluding to a bit more hand-wavily in my previous comment when I said " |
Yeah, using I agree it sounds like a valid fallback for the engines not implementing 1- It implies using kInterpolationNone in the HTMLCanvarPainter class, which as far as I could understand would mean applying not interpolation algorithm at all when scaling the image. In summary, I agree that using "pixelated" as a fallback would be the best solution to solve the interop issues, at elast until Chrome implements "crisp-edges". I'm not an expert on the Chrome graphics codebase, so I'm going to study a bit more the implications of using "pixelated" and probably asking some Google folks for a review. In any case, thanks a lot for your feedback Daniel. |
Hooray! Maybe/hopefully that means the already-existing fuzzy annotations in the tests themselves can be removed, too.
That's intentional & fine, I think - these tests are specifically meant to assert that the sizing & positioning of the image (as influenced by
I see. If that means that Chromium's typical user-facing codepath isn't getting exercised by these tests, then that might be a reason to add additional copies of these tests, without |
Sure! Thanks for the discussion & being willing to reevaluate this. :) |
Setting The The "Display List codepath" is nothing to worry about here I think, since that should only apply when printing AFAIU. |
Oh, I guess the |
65cf9f3
to
fd89fdc
Compare
This is certainly what happens in the case of the SVG tests; for instance:
|
I have changed the title and the commit, so that this PR just adds 'pixelated' as fallback. It seems it helps to get rid of a bunch of interop issues, at least for now. If @dholbert, @fsoder and @annevk accept the change we could merge this and I'd investigate the other issues (eg, SVG pixel differences and lack of support in elements) in a different PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! One request - could you adjust the template versions of these tests in the tools
subdirectory here? If we ever wanted to regenerate these tests, we'd want to have those templates up-to-date.
(I'm also surprised the object-position
tests didn't already have image-rendering: crisp-edges
- I guess when I added these tests, they didn't need that in Firefox. But they do do some image-scaling and hence may need that.)
The tests fail in Chrome due to small pixel differences between the background-image used in the ref files and the different elements used to test the object-position, like canvas, img or video.
The use of 'image-rendering: crisp-edges' helps to reduce the impact of the different scaling algorithms implemented in the engine's rendering pipelines. However, some web engines don't implement the 'crisp-edges' features; this is the case of the Chrome browser.
It seems using 'pixelated' as fallback solves most of the PNG related test cases.