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

Some animated WebP images are broken when applying transformations #9

Closed
alvingao opened this issue Aug 15, 2018 · 2 comments · Fixed by #10
Closed

Some animated WebP images are broken when applying transformations #9

alvingao opened this issue Aug 15, 2018 · 2 comments · Fixed by #10

Comments

@alvingao
Copy link
Contributor

When applying transformations to some animated WebP images, the result animation looks broken.

For example, with the following code:

Glide.with(this)
        .load("https://mathiasbynens.be/demo/animated-webp-supported.webp")
        .apply(new RequestOptions().optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(new CircleCrop())))
        .into(imageView);
// Dependencies
def GLIDE_VERSION = "4.7.1"
implementation "com.zlc.glide:webpdecoder:0.0.8.${GLIDE_VERSION}"
implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"

The result looks like this:

glide_webp_decoder_demo

Without applying transformations, the images are ok and the animation looks perfect.

@alvingao
Copy link
Contributor Author

I'm aware that the WebpDrawableTransformation class has an unstable warning in the code comment, but transformations are required for my use case, so I looked into this.

The problem has nothing to do with the WebpDrawableTransformation class itself, but is caused by the way WebpDecoder handles its frame bitmap cache.

When transformations are applied, the original bitmap returned by WebpDecoder#getNextFrame() might be put back into the bitmap pool, and shouldn't be used any more. But in the getNextFrame() method, it's also cached into mFrameBitmapCache and used later, which is why the result looks broken.

I have a fix that caches a new copy of the bitmap into the frame cache and solves the problem. I will create a pull request soon.

@zjupure
Copy link
Owner

zjupure commented Aug 16, 2018

@alvingao This is a known issue. Thanks for your investigation and solution. I have verified your PR and it works fine. I will merge it into the respository.

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

Successfully merging a pull request may close this issue.

2 participants