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

AVIF Image Rendering Issues on Android 12+: Black Backgrounds #5140

Open
vignesh-em opened this issue May 16, 2023 · 5 comments
Open

AVIF Image Rendering Issues on Android 12+: Black Backgrounds #5140

vignesh-em opened this issue May 16, 2023 · 5 comments

Comments

@vignesh-em
Copy link

Glide Version: 4.14.2

Integration libraries: none

Device/Android Version: Samsung Galaxy M52 / Android 13

Use case background:

Android 12 introduces support for AVIF images. So starting Android 12, Glide should be able to decode AVIFs without avif-integration library. However, when used without the avif integration library, the avif images are sometimes not rendered or rendered with a black background (the image has transparent parts).

I also tested this on a Pixel 6 Pro running Android 12. The image did not render.

I am not sure whether this is a platform issue or an issue with the way glide processes avif images but I do see the devices have a decoder that supports video/av01 format.

The sample project can be found here.

food-avif-vs-webp (2)

@vignesh-em vignesh-em changed the title AVIF Image Rendering Issues with Glide in Android 12+: Black Backgrounds AVIF Image Rendering Issues on Android 12+: Black Backgrounds May 16, 2023
@vignesh-em
Copy link
Author

@vigneshvg, do you think the platform decoder is having trouble decoding AVIF images? Including the glide avif integration library fixes this issue (it is now using the decoder provided by the integration library).

@vigneshvg
Copy link
Contributor

@vigneshvg, do you think the platform decoder is having trouble decoding AVIF images? Including the glide avif integration library fixes this issue (it is now using the decoder provided by the integration library).

The platform decoder does NOT support alpha transparency. The platform decoder also has other limitations (it only supports 8-bit and 10-bit YUV420 AVIF images). Android 14 removes some of those limitations (but transparent images are not supported still).

If you need to use transparent images (or any other AVIF feature not supported by the platform), you would have to use the AVIF Glide Integration library. Also, note that the underlying decoder used by the integration library had a bug with transparent images which was fixed in #5128.

There hasn't been a Glide release with that patch included yet. So you may want to update your local build.gradle to use the specific version of the libavif dependency. Please see https://bumptech.github.io/glide/int/about.html#how-do-i-use-a-specific-version-of-okhttp-volley-or-other-third-party-library for instructions on how to do this. You will want to include org.aomedia.avif.android:avif:0.11.1.3c786d2.

Hope that helps. Please let me know if you have any other questions.

@AndroidDeveloperLB
Copy link

@vigneshvg

Wait, there is an addon-library of loading AVIF via Glide even on old versions of Android?
Where?
And how do I use it?
Does it have a good license that doesn't force me to have all in open source?

@vigneshvg
Copy link
Contributor

@vigneshvg

Wait, there is an addon-library of loading AVIF via Glide even on old versions of Android?

Yes there is! That is exactly what the Glide AVIF integration library does (i.e.) if you use the integration library, it will bundle an AVIF decoder along with your app and it will work the same irrespective of the version of Android that the app is running on.

Where? And how do I use it?

It is fairly straightforward if you are already using Glide. See here for details: https://bumptech.github.io/glide/int/avif.html

Does it have a good license that doesn't force me to have all in open source?

I don't know the exact answer for this. It uses libavif underneath. So you would have to check about the licensing yourself.

@AndroidDeveloperLB
Copy link

@vigneshvg Thank you. Hope to check it out some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants