Bug 17022 - Add APNG support
: Add APNG support
Status: NEW
Product: WebKit
Classification: Unclassified
Component: Images
: 528+ (Nightly build)
: All All
: P3 Enhancement
Assigned To: Nobody
http://wiki.mozilla.org/APNG_Specific...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-26 09:26 PST by José Jeria
Modified: 2015-02-28 01:02 PST (History)
33 users (show)

See Also:


Attachments
Add APNG support, re-bundle libpng with APNG patch (945.32 KB, patch)
2009-05-28 20:11 PDT, Mark Steele
no flags Details | Formatted Diff | Diff
v01_apng_webkit.patch (22.76 KB, patch)
2013-03-13 10:13 PDT, Max Stepin
abarth: review-
Details | Formatted Diff | Diff
v02_apng_webkit.patch (23.60 KB, patch)
2013-04-04 15:32 PDT, Max Stepin
benjamin: review-
Details | Formatted Diff | Diff
v03_apng_webkit.patch (75.58 KB, patch)
2014-08-06 14:36 PDT, Max Stepin
no flags Details | Formatted Diff | Diff
v04_apng_webkit.patch (75.45 KB, patch)
2014-08-09 08:12 PDT, Max Stepin
no flags Details | Formatted Diff | Diff
v05_apng_webkit.patch (99.67 KB, patch)
2014-08-11 09:30 PDT, Max Stepin
no flags Details | Formatted Diff | Diff
v06_apng_webkit.patch (85.04 KB, patch)
2014-08-11 09:57 PDT, Max Stepin
buildbot: commit‑queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-11 for mac-mountainlion-wk2 (555.80 KB, application/zip)
2014-08-11 13:44 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion (745.79 KB, application/zip)
2014-08-11 14:30 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion (567.74 KB, application/zip)
2014-08-11 15:22 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion (601.23 KB, application/zip)
2014-08-11 16:30 PDT, Build Bot
no flags Details
v07_apng_webkit.patch (85.66 KB, patch)
2014-08-12 07:27 PDT, Max Stepin
maxstepin: review?
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description José Jeria 2008-01-26 09:26:20 PST
Please add APNG support to WebKit. Firefox and Opera already supports this.
Comment 1 Mark Rowe (bdash) 2008-01-26 11:09:57 PST
WebKit uses the platform's underlying image libraries for format support, so APNG would need to be implemented there for WebKit to decode it.  This would require ImageIO on Mac/Windows to support it (<rdar://problem/5618737>), and QImage for Qt.  Only the Gtk and wx ports make use of the bare basic image decoders in the WebKit source tree.
Comment 2 Mark Rowe (bdash) 2008-01-26 11:15:04 PST
Closer inspection shows that our in-tree PNG decoder is just a wrapper around libpng.  For the Gtk and wx ports to support APNG we would need libpng to support it.
Comment 3 Christian Dywan 2008-01-30 08:10:06 PST
Incidentally there are patches available for libpng to support apng, but they are still waiting for approval. Time will tell whether WebKit needs to ship a fork of libpng or upstream supports this in the future.

http://littlesvr.ca/apng/
Comment 4 Mark Steele 2009-05-28 20:11:43 PDT
Created attachment 30764 [details]
Add APNG support, re-bundle libpng with APNG patch

Rough patch to PNGImageDecoder to support APNG.
Bundle libpng with APNG patch.
A few things are missing/broken, but basic support works on Webkit/GTK+
Comment 5 Alexey Proskuryakov 2010-08-11 02:28:35 PDT
Bug 43828 tracks APNG support in Safari (as mentioned above, that's blocked on ImageIO).
Comment 6 Jared Grippe 2011-04-12 18:01:01 PDT
want!
Comment 7 Max Stepin 2013-03-13 10:13:50 PDT
Created attachment 192943 [details]
v01_apng_webkit.patch

If external libpng supports APNG extension, ask libpng to decode animation frames. 

Some Linux distros (Arch, Gentoo, Mageia, etc) ship with apng-patched libpng as a system library. With this patch WebKit would take advantage of that and request libpng to read APNG frames.
Comment 8 Adam Barth 2013-03-20 22:55:22 PDT
Comment on attachment 192943 [details]
v01_apng_webkit.patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192943&action=review

We shouldn't land this patch unless one or more WebKit work wishes to enable this code.  If we're going to accept this patch, we'll also need a number of tests.

> Source/WebCore/ChangeLog:3
> +        [GTK] [wx] Add APNG support

This issue is not specific to the GTK and wx ports, so it shouldn't have these prefixes.

> Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp:108
> +#ifdef PNG_APNG_SUPPORTED

This should read:

#if ENABLE(APNG)

Also, all the code introduced to support APNG should be behind this compile flag.

> Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp:241
> +    , m_frameIsHidden(false)
> +    , m_curFrame(0)
> +    , m_loopsCount(0)
> +    , m_delayNum(1)
> +    , m_delayDen(1)
> +    , m_dispose(0)
> +    , m_blend(0)

All this state as well.
Comment 9 ManDay 2013-04-01 09:30:35 PDT
Please do NOT add "apng" support to Webkit. "gif" was a first mistake in design of the web - these days luckily being replaced by proper video one after another. Adding apng works against the combined efforts to build a clean (flash free, GIF free) web where images are images (displayed by webkit itself) and animations are animations (displayed by gstreamer or a similar library which specializes on rendering animations).

Seperation of responsibilities and specialization is the foundation of open source and provides clean, stream-lined concepts. The PNG-developers do not disapprove of apng without a reason.
Comment 10 Christian Dywan 2013-04-01 10:07:58 PDT
(In reply to comment #8)
> We shouldn't land this patch unless one or more WebKit work wishes to enable this code.  If we're going to accept this patch, we'll also need a number of tests.

From Midori's perspective, I'd encourage enabling APNG - if WebKitGTK/ Epiphany team agree. In Archlinux it could work out of the box.
Comment 11 Max Stepin 2013-04-04 15:32:14 PDT
Created attachment 196541 [details]
v02_apng_webkit.patch

New code is now in 

#if ENABLE(APNG) && defined(PNG_APNG_SUPPORTED)
#endif

Also added this ENABLE_APNG flag into Source/WTF/wtf/FeatureDefines.h
Comment 12 Benjamin Poulain 2013-04-04 15:44:03 PDT
Comment on attachment 196541 [details]
v02_apng_webkit.patch

No tests?

Did any port actually agree to maintain this? If not, there is no point.
Comment 13 Allan Sandfeld Jensen 2013-04-07 13:40:55 PDT
(In reply to comment #11)
> Created an attachment (id=196541) [details]
> v02_apng_webkit.patch
> 
> New code is now in 
> 
> #if ENABLE(APNG) && defined(PNG_APNG_SUPPORTED)
> #endif
> 
> Also added this ENABLE_APNG flag into Source/WTF/wtf/FeatureDefines.h

I would suggest setting ENABLE_APNG based on defined(PNG_APNG_SUPPORTED), that way you don't have to check for both, and ENABLE_APNG will only be set when APNG is supported.
Comment 14 Allan Sandfeld Jensen 2013-04-11 02:32:05 PDT
(In reply to comment #12)
> (From update of attachment 196541 [details])
> No tests?
> 
> Did any port actually agree to maintain this? If not, there is no point.

Hopefully it will not require much maintaince. Though it will need tests, and someone should run a bot with it enabled. I guess for GTK and Qt it will depend on the libpng available on the system.
Comment 15 Max Stepin 2014-08-06 14:36:17 PDT
Created attachment 236137 [details]
 v03_apng_webkit.patch

I rewrote the APNG support code, please take a look.
     
This version decodes APNG using only standard libpng (turns out it's possible).
     
I also added test files: a dozen small animations that would play once, and finish asap. After a short delay a pixel-test can be compared against the expected result. It covers most of the apng features at different png colortypes.
     
I'm going to ask GTK port people, and will try to contact other ports too.

     
P.S. Safari's own implementation of APNG might benefit from the test suite too.
Comment 16 Benjamin Poulain 2014-08-06 17:36:06 PDT
I think you could convert the test to a ref-test instead of a pixel test. Tests should have a description and explanations of what is tested and how.
Comment 17 Max Stepin 2014-08-06 21:26:33 PDT
OK. I was looking at LayoutTests/fast/images/png-suite/test.html 
as an example. But I can convert it into a reftest.
Comment 18 Max Stepin 2014-08-09 08:12:12 PDT
Created attachment 236335 [details]
v04_apng_webkit.patch

Now with reftest. All animations included in the reftest should play once and stop at the last frame. After that, compare the result against reference static PNGs.
Comment 19 Max Stepin 2014-08-11 09:30:32 PDT
Created attachment 236373 [details]
v05_apng_webkit.patch

Previous patch was formatted incorrectly. Fixed now.
Comment 20 Max Stepin 2014-08-11 09:57:11 PDT
Created attachment 236375 [details]
v06_apng_webkit.patch

Really fixed now. Sorry, I'm new to this.
Comment 21 Build Bot 2014-08-11 13:44:43 PDT
Comment on attachment 236375 [details]
v06_apng_webkit.patch

Attachment 236375 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6305820962717696

New failing tests:
fast/images/animated-png.html
Comment 22 Build Bot 2014-08-11 13:44:50 PDT
Created attachment 236396 [details]
Archive of layout-test-results from webkit-ews-11 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-11  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 23 Build Bot 2014-08-11 14:30:28 PDT
Comment on attachment 236375 [details]
v06_apng_webkit.patch

Attachment 236375 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4795727104442368

New failing tests:
fast/images/animated-png.html
Comment 24 Build Bot 2014-08-11 14:30:40 PDT
Created attachment 236402 [details]
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-03  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 25 Build Bot 2014-08-11 15:22:46 PDT
Comment on attachment 236375 [details]
v06_apng_webkit.patch

Attachment 236375 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5712234470703104

New failing tests:
fast/images/animated-png.html
Comment 26 Build Bot 2014-08-11 15:22:58 PDT
Created attachment 236406 [details]
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-06  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 27 Build Bot 2014-08-11 16:30:35 PDT
Comment on attachment 236375 [details]
v06_apng_webkit.patch

Attachment 236375 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5681974278619136

New failing tests:
fast/images/animated-png.html
Comment 28 Build Bot 2014-08-11 16:30:47 PDT
Created attachment 236412 [details]
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 29 Max Stepin 2014-08-12 07:27:45 PDT
Created attachment 236444 [details]
v07_apng_webkit.patch

It appears that mac target doesn't use WebKit's internal image decoders, so I'll going to skip that test, just for mac.
Comment 30 Max Stepin 2014-08-19 05:00:24 PDT
Comment on attachment 236444 [details]
v07_apng_webkit.patch

I'm adding "review?" flag, since EFL is ok with enabling it as experimental feature. See here:
https://lists.webkit.org/pipermail/webkit-efl/2014-August/thread.html

I'm willing to help with the maintenance, the code is well tested and clean, so I don't expect any issues.
Comment 31 zone 2015-02-27 20:42:23 PST
+1

Add APNG support. 

Max's patch works. And he's willing to maintain. 

Takes away all excuses not to.
Comment 32 Benjamin Poulain 2015-02-28 01:02:55 PST
(In reply to comment #31)
> +1
> 
> Add APNG support. 
> 
> Max's patch works. And he's willing to maintain. 
> 
> Takes away all excuses not to.

This is for GTK right?

Has anyone contacted the GTK folks to get a review on this patch? WebKit-GTK has a mailing list: https://lists.webkit.org/mailman/listinfo/webkit-gtk