-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
AVIF codec support #61229
Comments
I'm guessing this will need support in the engine from Skia? If so I think the issue tracking it in chromium seems to indicate that is now at least initially available as support is shipping in Chrome M85. |
Right now, we're delegating to native platforms (except on Linux and Android) to decode formats we don't recognize - but there's no support for that (yet) for animated images. |
(so you would just get the first frame if the platform can decode at least that much) |
cc @cbracken |
I think it would be a great time to reconsider this as it was already implemented on Skia on April 2021 |
Could we get an update on the status of this please? |
Even though we may defer to native decoding, iOS 16 currently has some rendering issues with RGB AVIF files: https://www.reddit.com/r/AV1/comments/xd4v8w/avif_in_safari_on_ios_16_vs_google_chrome_on/ Not to mention, Android 12 only constitutes 13.5% of devices according to Android Studio (and I'm not entirely certain that AVIF support isn't dependent on device manufacturer configuration): If we're stuck with native decoding options, then it'll be years until we can use AVIF on Android without abandoning a significant chunk of users. |
Skia supports this if you ship a codec that can decode it. Shipping a codec adds non-trivial cost for all customers of Flutter. I don't have a good sense for how popular AVIF actually is. The strategy Flutter has had for a while at this point is just let the native platforms add support, and if they're not we're not. I'm not opposed to AVIF in principle (I don't really know enough about it), but I think the following would help to get consensus on whether Flutter should support this specially:
|
How many browsers support it doesn't really give us a good sense of how popular the format is. I'm also not clear on how much better it'd be to use AVIF images than say webp images in the same context in Flutter. AVIF appears to support HDR/10bpp images, but Flutter doesn't. |
Looks like Chromium and Skia use libavif, which appears to be AOM's reference implementation (though I might be missing something, haven't looked at this all the way through). It probably wouldn't be too hard to add an appropriate hash of libavif to the engine's DEPS file, create a build rule (probably based on Chromium's), add the gn argument for It would still help to know either how many customers are really hurting for this (as opposed to one ofthe other formats we already support). HEIC images, for example, are supported from Android P onward from what I recall. |
It's rapidly being supported by various platforms because of that wide support (since over 71% of users can render it). If someone's already generating AVIF files to serve to web users, then it'd be nice to also allow iOS and Android users to benefit from the same file size reductions. Speaking of which, AVIF has a decent improvement over WebP (I believe that's effectively 30% smaller): https://www.ctrl.blog/entry/webp-avif-comparison.html If you have an app that serves a lot of images, the benefits of AVIF could be significant at scale. Edit: |
Not only are compressed file sizes significantly smaller but the compressed image sharpness is far superior than that of webp (which is much softer). I'm migrating a large app to GCP + Flutter (~35m JPGs). At the moment I'm using webp but it would be a huge benefit to me to be able to use avif in terms of storage & bandwidth costs, and also for my users which would experience faster & sharper images. |
I would also like to see AVIF supported. Since the AV1 video format is increasing hugely in popularity, it makes only sense to add support for the corresponding AV1 image format (AVIF) better sooner than later. There is already significant hardware support, with hardware decoders being already present in most devices, hardware encoders coming with the next generation of cpus/gpus that's hitting the market right now (Intel ARC, AMD RDNA3, NVIDIA's latest cards), and webbrowser support enabled (e.g. in latest Firefox version). So the vast majority of end users can use hardware accelerated decoding as of now, and content creators will have access to hardware encoders very soon (read: this christmas). These new codecs are open, royalty-free and their compression capability is far superior to anything the old JPEG and H.264 (MP4) image and video codecs could do. And let's face it, while nobody wants to remove support for those, with content resolution increasing rapidly (e.g. 4K, 8K videos and higher megapixel cameras) the demands on storage are getting so high that the need for new, open, more efficient codecs is really there. They save bandwith and storage, and therefore money. Don't want to annoy anyone here, but if somebody could take some time off to implement AV1 & AVIF support in Flutter, this would be greatly appreciated! Thank you very much. |
People are encountering AVIF images more often. I see complains on Twitter that they downloaded an AVIF file from some website and that all their programs are not working with AVIF yet. Supporting AVIF is not difficult. In GIMP we use libheif (it has AVIF support too beside HEIC), in KDE and Qt applications (like Telegram Desktop on Windows/Linux) we use libavif. libavif is now maintained by people who work on libaom AV1 decoder/encoder and who integrated it into Google Chrome browser. libavif and libaom can be easily cross-compiled for armeabi-v7a and they work on Android (tried it myself). libavif & libaom are fuzzed on oss-fuzz, the code is reliable and well tested. If you need to know something about AVIF and/or the mentioned libraries, don't hesitate to ask me. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@dnfield I have been looking forward to the day that Flutter supports AVIF since I read this article in 2020. I would suggest reading it if you want to get up to speed. But there are newer articles since then. https://www.smashingmagazine.com/2021/09/modern-image-formats-avif-webp/ To answer your previous points.
Gaining traction every day since 2020. Now all the major browser vendors ship the decoding library. I can post an AVIF image to this post and chrome will decode it just fine. However Flutter will not. Flutter lead the charge on being at the forefront of mobile and I think its is a case where it should do the same.
It would be great if you can build the latest engine with skia avif flag enabled and let us know. However, the increase in size would be insignificant compared to the saving we would get if we could use AVIF in our applications. Apps are getting larger in size and part of this is the assets. We want to ship high quality graphics for multiple pixel densities but this takes up space. AVIF can actually help reduce the overall application deployment sizes.
As it ships as part of the chromium project (libavif) I assume it has the appropriate licenses. This is: 2-Clause BSD @kevmoo Since the image decoders will fall back to the underlying platform, I assume this means that Flutter on Web supports AVIF format. And really it makes sense for the other platforms to now adopt this format to better get cross platform support. For example; I don't really want to ship the same graphic in multiple formats to support web and desktop. Which means we end up supports the lowest common denom aka JPEG instead of the better sized AVIF. |
Hmm, it seemed like a small task even for an outsider, but the interactions between gclient and gn seem a little opaque to those not familiar with chromium tooling. One would have expected the DEPS of skia on libavif as well as skia's
Is flutter supposed to duplicate skia's third_party BUILD.gn files or is something broken? |
I just found out that Android 12 ships with AVIF support. Can the flutter-engine take advantage of this? I can see AVIF being popular with Flutter developers, if the engine supported it, the community could put together supporting tooling. @tvolkert I see this is a P3, but it looks like its a simple addition and would have a lot of gain. Any chances on understanding size cost to the engine for including it? (Not sure who heads up the engine team, if that's still you or not) |
@slightfoot If Android 12 supports it, thenit should "just work" on Android 12 devices and up. We fall back to platform based decoding for formats we don't ship support for natively. @kennylevinsen - You need to have libavif in the Just note that Skia uses |
@dnfield created a test project and have AVIF working on Android. The issue still remains if you wanted to use AVIF it wouldn't be just for one platform. |
If anyone wants to use Avif until Flutter supports it, I have created a package you can try. https://github.com/yekeskin/flutter_avif |
This is so critical for my current use case. I have to convince my client that they go with webp because Flutter doesn't support this format right now. |
Use case
AVIF aims to be the successor of jpg on the web and is growing very fast. AVIF images also compress with much better results then jpg. So it would be very good for flutter applications to support AVIF.
Proposal
Add AVIF codec support to flutter.
The text was updated successfully, but these errors were encountered: