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

Port APNG tests to WPT, add test assertions. Fix #5546 #42893

Merged
merged 8 commits into from Nov 17, 2023
Merged

Port APNG tests to WPT, add test assertions. Fix #5546 #42893

merged 8 commits into from Nov 17, 2023

Conversation

svgeesus
Copy link
Contributor

@svgeesus svgeesus commented Nov 1, 2023

This is a port of https://philip.html5.org/tests/apng/tests.html see

These tests use setTimeout, which has been added to the lint.ignore. Most tests are reftests, and the reference is a png that captures the end state of the animation (created with apngasm disassembly).

A few are manual tests, those are in the manual sub-folder.

The tests are under /png/apng because APNG is now part of the PNG specification.

To help in reviewing, these are the animation durations of the test files (in 1/100 sec):

000.png     0 (not apng)
001.png     100/100
002.png     100/100
003.png     0 (not apng)
004.png     0 (not apng)
005.png     100/100
006.png     100/100
007.png     30/100
008.png     30/100
009.png     20/100
010.png     30/100
011.png     20/100
012.png     20/100
013.png     30/100
014.png     20/100
015.png     30/100
016.png     30/100
017.png     20/100
018.png     20/100
019.png     20/100
020.png     20/100
021.png     137/100
022.png     160/100
023.png     160/100
024.png     110/100
025.png     350/100
026.png     150/100 * inf
027.png     150/100 * inf
028.png     inf, crashes png file checker
029.png     inf, crashes png file checker
030.png     200/100 * inf
031.png     200/100
032.png     400/100
033.png     110/100
034.png     110/100
035.png     110/100
036.png     110/100
037.png     110/100
038.png     110/100

I did not yet port the "error in file" tests because those need more discussion:

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 1, 2023

@ProgramMax could you review?

@ProgramMax
Copy link
Contributor

@ProgramMax could you review?

Will do. Lot of new files so give me a sec. :)

The tests are under /png/apng because APNG is now part of the PNG specification.

In a separate pull request, should we move the existing /apng tests into /png/apng?

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 1, 2023

In a separate pull request, should we move the existing /apng tests into /png/apng?

Yes, my thought exactly. Firstly to do it, and secondly in a separate PR so as not to clutter up this one.

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 1, 2023

@ProgramMax

Lot of new files so give me a sec. :)

The support/nnn.png images are unchanged from the original test suite. The png files for the references are created by disassembling the test apng to a set of static png using apngasm.

Animation durations were calculated by examining the images in a modified version of PNG file chunk inspector which I extended to add APNG support and is the total of all the delays. Note that delays in the test PNGs are (mostly) in 1/100 sec while the delay in setTimeout is in ms, so 10x as large. I added an additional 1000ms delay on top to be sure the animation was complete before the comparison is made.

Tests on WPT should not use setTimeout unless absolutely needed (for example to test animation, as here) so as part of this PR all of those tests are whitelisted so the linter does not complain.

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 2, 2023

Actually it seems that https://www.nayuki.io/page/png-file-chunk-inspector has been updated to support APNG since I forked and updated a couple of years ago, so it can be used without modification.

Copy link
Contributor

@ProgramMax ProgramMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the html tag now a void tag? Shouldn't it be closed?
Is that to do with the timeout that removes the 'reftest-wait' class?

png/apng/acTL-plays-one.html and png/apng/acTL-plays-two.html both do not have a closing html tag. This is unlike png/apng/apng-blue-rect-checkerboard-ref.html, for example. There are also some which don't have any html tags at all.

Also, should these get the pixel color and assert the test passes? I'm guessing there is no great way to paint a specific frame of an APNG into a canvas to read it back, is there? Does it auto-capture and compare against some sort of gold master?

png/apng/fcTL-acTL-ordering.html Outdated Show resolved Hide resolved
@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 3, 2023

Is the html tag now a void tag? Shouldn't it be closed?

In XHTML it must be closed. In HTML5 it need not be.

Is that to do with the timeout that removes the 'reftest-wait' class?

Unrelated, except that apparently that class should be on "the root element" which is html.

png/apng/acTL-plays-one.html and png/apng/acTL-plays-two.html both do not have a closing html tag. This is unlike png/apng/apng-blue-rect-checkerboard-ref.html, for example.

That is allowed by HTML5.

Also, should these get the pixel color and assert the test passes? I'm guessing there is no great way to paint a specific frame of an APNG into a canvas to read it back, is there? Does it auto-capture and compare against some sort of gold master?

For a reftest, which most of these are, the WPT test runner auto captures and it is then compared to an auto capture of the reference file, both rendered on the same browser and platform to avoid differences in fonts or anti-aliasing. The reference is indicated by the rel="match" link. See
https://web-platform-tests.org/writing-tests/reftests.html

There are also some which don't have any html tags at all.

If they don't need the delay class on the root element then there is no need to type the html opening tag, the parser adds it automatically.

Copy link
Contributor

@ProgramMax ProgramMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Neat. TIL.
Looks good to me.

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 3, 2023

@jgraham @foolip it seems that review from @ProgramMax (PNG WG chair) is not sufficient despite being listed in META.yml. Could you add whatever is needed, please?

@svgeesus svgeesus requested a review from annevk November 6, 2023 19:36
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do the tests have such wildly differing timeout times? Can we reduce them somehow? This would make these tests take a long time to run and I worry that it might also make them flaky.

cc @jgraham

png/apng/timeout.txt Outdated Show resolved Hide resolved
png/apng/fdAT-split-zero-length.html Outdated Show resolved Hide resolved
png/apng/fdAT-split-zero-length.html Show resolved Hide resolved
@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 7, 2023

@annevk

Why do the tests have such wildly differing timeout times?

See the table of animation times in the original post, which are in 100ths of a second.

I added a one-second padding after the end of the animation, is that too much? The original page said:

For all these tests, wait at least a second after all the images have downloaded, before checking that the rendered output is correct.

@annevk
Copy link
Member

annevk commented Nov 8, 2023

So I looked at https://philip.html5.org/tests/apng/tests.html and it seems unfortunate we're losing the ability to generate these tests in the process of adopting them here.

Did you look at repurposing the script in some manner?

We have a number of existing places where we also commit the script used to generate the tests, e.g., https://github.com/web-platform-tests/wpt/blob/master/mimesniff/mime-types/resources/generated-mime-types.py.

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 8, 2023

Hi @annevk

Yes, I had looked at the perl script, sure. It uses Cairo to do the heavy lifting, and scrapes the all-in-one html file of the original tests to get a recipe for each test file. In the original test these are preserved in a special link like

data:text/plain,IHDR%20%3D%3E%20%5BW%2C%20H%5D%2C%0AacTL%20%3D%3E%20%5B1%2C%200%5D%2C%0AfcTL%20%3D%3E%20%5B0%2C%20W%2C%20H%2C%200%2C%200%2C%20100%2C%20100%2C%20DISPOSE%5FNONE%2C%20BLEND%5FOVER%5D%2C%0AIDAT%20%3D%3E%20%5Bcreate%5Fsurface%28W%2C%20H%2C%20%27green%27%29%5D%2C%0AIEND%20%3D%3E%20%5B%5D%2C

Which is url-encoded from the html source in a custom element,

<png>
IHDR => [W, H],
acTL => [1, 0],
fcTL => [0, W, H, 0, 0, 100, 100, DISPOSE_NONE, BLEND_OVER],
IDAT => [create_surface(W, H, 'green')],
IEND => [],
</png>

Agreed, it is certainly nice to be able to make those test images from a text description like that, particularly for more complex cases like

<div class="case">
<p>APNG_BLEND_OP_OVER repeatedly with nearly-transparent colours.
<p>This should be solid green.
<png>
IHDR => [W, H],
acTL => [128, 1],
IDAT => [create_surface(W, H, 'red')],
fcTL => [0, W, H, 0, 0, 10, 100, DISPOSE_NONE, BLEND_OVER],
fdAT => [1, create_surface(W, H, 'solid', 0, 1, 0, 1)],
(map {
    (fcTL => [2+$_*2, W/2, H, 0, 0, 1, 100, DISPOSE_NONE, BLEND_OVER],
    fdAT => [3+$_*2, create_surface(W/2, H, 'solid', 0, 1, 0, 0.01)])
} 0..126),
IEND => [],
</png>
</div>

but given that the PNG files are all there, and those are what people have been using since 2007 to test APNG (in browsers, and in APNG consuming or generating tools) I wanted to have the exact same one here in WPT. For example I see the original files as part of a PR for APNG read support in libspng

So I deferred any further investigation until there was a need to generate similar files which were not part of the original suite.

Note that the filename is not stored in the recipe, it just uses sequential three-digit numbers as the name; so any insertion of new ones need to be at the end to avoid breaking earlier tests.

I'm happy to put the perl script and the original source.html into a resources directory for archival, which is probably a good idea in case the original site goes down for some reason. Also the perl script has a comment with the copyright and the license (which allows free re-use) which is another good reason to have it.

Note that, as I said in the first message, the original suite includes a bunch of tests on broken images, which I plan to add here after

is resolved because we do not have browser interop there. Chrome follows the original (Mozilla) APNG spec there while Firefox does not :) and the spec is arguably unclear on the error recovery in some cases and needs t be tightened up.

That conversation would probably be easier if the original files were the subject of discussion, too.

@svgeesus
Copy link
Contributor Author

svgeesus commented Nov 8, 2023

I'm happy to put the perl script and the original source.html into a resources directory for archival,

Done with 9e1fd74 and I added a README too

@svgeesus
Copy link
Contributor Author

@annevk does that satisfy your concern about regenerating images?

@annevk
Copy link
Member

annevk commented Nov 12, 2023

Thank you! Might need to rebase and force push to make the bots happy. Failing that we'll have to ask an admin.

@svgeesus
Copy link
Contributor Author

Thanks @annevk
The lint task seems non-terminating

@annevk
Copy link
Member

annevk commented Nov 13, 2023

Right, hence my recommendation to rebase (on top of latest in master) and force push this branch.

@svgeesus
Copy link
Contributor Author

chris@SuperNomad:/mnt/c/Users/chris/Documents/GitHub/mywpt$ git fetch origin
chris@SuperNomad:/mnt/c/Users/chris/Documents/GitHub/mywpt$ git rebase origin/master
Current branch apng is up to date.
chris@SuperNomad:/mnt/c/Users/chris/Documents/GitHub/mywpt$ git push --force
Everything up-to-date

@svgeesus
Copy link
Contributor Author

Failing that we'll have to ask an admin.

Who would that be, perhaps @jgraham @zcorpan @foolip

Rebase resulted in zero changes so force-push did not result in any commit.

@annevk
Copy link
Member

annevk commented Nov 16, 2023

It sounds like you didn't get do git checkout master; git pull or some such as rebase would pretty much always result in something happening on a project of this size.

@svgeesus
Copy link
Contributor Author

So I am not comfortable force pushing to master on a project of this size and importance. Link sometimes getting stuck is a bug, not an issue with the content of this PR and I prefer a WPT admin look into that and fix it.

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 16, 2023

You most definitely shouldn't force-push to master. The lint appears to have failed legitimately:

INFO:lint:
INFO:lint:There were 1027 errors (CR AT EOL: 1027)
INFO:lint:You must fix all errors; for details on how to fix them, see
INFO:lint:https://web-platform-tests.org/writing-tests/lint-tool.html
INFO:lint:
INFO:lint:However, instead of fixing a particular error, it's sometimes
INFO:lint:OK to add a line to the lint.ignore file in the root of the
INFO:lint:web-platform-tests directory to make the lint tool ignore it.
INFO:lint:
INFO:lint:For example, to make the lint tool ignore all 'CR AT EOL'
INFO:lint:errors in the png/apng/resources/source.html file,
INFO:lint:you could add the following line to the lint.ignore file.
INFO:lint:
INFO:lint:CR AT EOL: png/apng/resources/source.html

@annevk
Copy link
Member

annevk commented Nov 16, 2023

I wasn't suggesting to force push to master. I was saying that it sounded like you hadn't pulled from master as git rebase yielded no up-to-date changeset while it should have.

@svgeesus svgeesus merged commit 9027ea4 into web-platform-tests:master Nov 17, 2023
19 checks passed
@svgeesus svgeesus deleted the apng branch November 17, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants