[wpt-sync] Sync PR 12187 - Add support for fuzzy matching in reftests.
Categories
(Testing :: web-platform-tests, enhancement, P4)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: mozilla.org, Unassigned)
References
(Blocks 1 open bug, )
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 12187 into mozilla-central (this bug is closed when the sync is complete). PR: https://github.com/web-platform-tests/wpt/pull/12187 Details from upstream follow. James Graham <james@hoppipolla.co.uk> wrote: > Add support for fuzzy matching in reftests. > > This allows fuzzy matching in reftests in which a comparison can > succeed if the images are different within a specified tolerance. It > is useful in the case of antialiasing, and in other scenarios where > it's not possible to make an exact match in all cases. > > Differences between tests are characterised by two values: > > * The maximum difference for any pixel on any color channel (in the > range 0 to 255) > > * The maximum total number of differing pixels > > The fuzziness can be supplied in two places, according to whether it's > a property of the test or of the implementation: > > * In the reftest itself, using a <meta name=fuzzy> tag > > * In the expectation metadata file using a fuzzy: key that takes a > list > > The general format of the fuzziness specifier is > > range = [digits, "-"], digits > fuzziness = [ url, "-" ], range, ";", range > > The first range represents the maximum difference of any channel per > pixel and the second represents the total number of pixel > differences. So for example a specifier could be: > > * "10;300" - meaning a difference of up to 10 per color channel and up to > 300 pixels different in total (all ranges are inclusive). > > * "5-10;200-300" - meaning a maximum difference of between 5 and 10 > per color channel and between 200 and 300 pixels differing in total > > The definition of url is a little different between the meta element > and the expecation metadata. In the first case the url is resolved > against the current file, and applies to any reference in the current > file with that name. So for example > > <meta name="fuzzy" content="option-1-ref.html:5;200"> > > would allow a fuzziness of up to 5 on a specific channel and up to 200 > opixels different for comparisons involving the file containing the > meta element and option-1-ref.html. > > In the case of expectation metadata, the metadata is always associated > with the root test, so urls are always resolved relative to that. In > the case as above where only a single URL is supplied, any reference > document with that URL will have the fuzziness applied for whatever > comparisons it's involved in e.g. > > [test1.html] > fuzzy: option-1-ref.html:5;200 > > would apply the fuziness to any comparison involving option-1-ref.html > whilst running the set of reftests rooted on test1.html. To specify an > exact comparison for the fuzziness, one can also supply a full > reference pair e.g. > > [test1.html] > fuzzy: subtest.html==option-1-ref.html:5;200 > > in which case the fuzziness would only apply to "match" comparison > involving subtest.html on the lhs and option-1-ref.html on the > rhs (both resolved relative to test1.html).
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
PR 12187 applied with additional changes from upstream: e45b651d2b0a4d0b8f239723b8bb9836ad18d9a5, 6146d600fd84c043ee3ce70e59f9abe1b8252d99
Assignee | ||
Comment 2•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=24e0be3c66278e4de57dcdd40f69efd4cc981822
Assignee | ||
Comment 3•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=4ad3b06c7b981f44e800be93ced4e8700f11867b
Assignee | ||
Comment 4•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=1f6a019d96ec6d10721d39bc52b19ca853f88119
Assignee | ||
Comment 5•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=3d3a0cfff41c1f375562b3ad2bd1ff8038712081
Comment 6•5 years ago
|
||
When we've got this support, list-style-021.xht is one test that really needs this annotation. Maybe it can be annotated as part of this bug, even, to serve as a sanity-check that the fuzzy functionality is working?
(I've just marked it as disabled in bug 1383451, but it really wants a fuzzy(8,1) annotation, for 1px differing by up to 8 in every color channel, with rgb(255,255,255) != rgb(247,247,247))
Comment 7•5 years ago
|
||
James, do you know what is blocking this from landing?
Comment 8•5 years ago
|
||
Syncing is currently blocked on figuring out why we suddenly started getting a lot of blank screenshots in reftests e.g. https://hg.mozilla.org/mozilla-central/raw-file/tip/layout/tools/reftest/reftest-analyzer.xhtml#logurl=https://queue.taskcluster.net/v1/task/VFoS_nw5R56dODTC8E3i9w/runs/0/artifacts/public/logs/live_backing.log&only_show_unexpected=1
Comment 9•5 years ago
|
||
Hi, James,
Do we have any progress on this bug? Because there are lots of WebVTT wpt tests need this fuzzy feature.
Thank you!
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
There isn't a more recent try run, but I expect this to land this week.
Comment 12•5 years ago
|
||
Sorry to poke on this bug again, just want to know is there any good progress we got for landing this one?
Thank you!
Comment 13•5 years ago
|
||
Pushed by james@hoppipolla.co.uk: https://hg.mozilla.org/integration/mozilla-inbound/rev/18fb7bd95d12 [wpt PR 12187] - Add support for fuzzy matching in reftests., a=testonly
Comment 14•5 years ago
|
||
bugherder |
Comment 15•5 years ago
|
||
Is there a way to use fuzzy matching with platform selection like used here https://searchfox.org/mozilla-central/rev/14dc5b7d8a6da1854b2f9f33f1da77a97368cd54/testing/web-platform/meta/css/css-backgrounds/child-move-reveals-parent-background.html.ini ?
Comment 16•5 years ago
|
||
Yes, you can.
Platform selection via the is/expression syntax is a generic feature not tied to any specific field.
For general docs on the fuzziness specification see https://searchfox.org/mozilla-central/source/testing/web-platform/tests/infrastructure/metadata/infrastructure/reftest/reftest_fuzzy.html.ini#2 for an example or the documentation [1], [2].
Bit generally you should be able to do something like:
fuzzy:
if os == "linux": 10;1-20
if os == "mac": 5;10
or with whatever values are appropriate.
No doubt the docs could be improved, so let me know what problems you run into.
[1] https://searchfox.org/mozilla-central/source/testing/web-platform/tests/tools/wptrunner/docs/expectation.rst#203-214
[2] https://web-platform-tests.org/writing-tests/reftests.html#fuzzy-matching
Comment 17•5 years ago
|
||
I think it would be a good idea to post a PSA about this feature in dev.platform.
Comment 18•5 years ago
|
||
Hi, James,
I've added the fuzzy
keyword on some wpts, but it seems not work at all [1]. Is there any thing I miss?
Thank you.
Comment 19•5 years ago
•
|
||
(In reply to Alastor Wu [:alwu] from comment #18)
I've added the
fuzzy
keyword on some wpts, but it seems not work at all [1]. Is there any thing I miss?
One guess: it looks like in your fuzzy annotations, you're repeating the test name, like here in your try commit:
--- /dev/null
+++ b/testing/web-platform/meta/webvtt/rendering/cues-with-video/processing-model/align_center.html.ini
@@ -0,0 +1,2 @@
+[align_center.html]
+ fuzzy: align_center.html:maxDifference=2;totalPixels=5000
^^^^^^^^^^^^^^^^^----(I think this is the problem)
I think you're supposed to use the reference name in the fuzzy annotation. (The test name is already present in the brackets, so it'd be redundant to list it again.)
I think (?) the idea is that tests can have multiple references (though they don't often), so to handle that correctly, you have to clarify which reference you're referring to in the fuzzy annotation. Or something like that. You don't have to clarify which testcase you're referring to, because the testcase has already been mentioned.
Comment 20•5 years ago
|
||
(Sorry I often miss comments on these bugs because for [reasons] I get bugmail for all PRs we're syncing and so it tends to get filtered away).
Yeah, so if you just don't put any filename then the annotation should get applied to all comparisons in that test. In the typical case that's fine because there's only one comparison. However wpt reftests are complex because tests can have multiple allowed renderings and you can build up chains of references for a single test. So for those complex cases it can be necessary to specify which part of the chain the fuzziness applies to. In that case, if the ref is only used once or the fuzziness applies every time it's used, you can simply name the ref (as a relative path from the test) using the <key>:<fuzzy> syntax you used above. In the most complex case where you want to identify a specific comparison you can use the full <lhs><reftype><rhs>:<fuzzy> form, where <lhs> and <rhs> are the relative paths from the initial test to the files being compared and <reftype> is either == or !=.
The tl;dr summary of all of that is that for your case you probably just want to write maxDifference=2;totalPixels=5000
, but dholbert is also correct that for more precision you need to specify the ref not the test.
There is a proposal to reform the way that complex reftests work in wpt which might hekp avoid some of this complexity; see [1] if you would like to give feedback on that.
I also noticed that there was a bug in the code comment explaining this; apologies if that caused the confusion.
Description
•