bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.68k stars 6.12k forks source link

When using RequestOptions, webp animations cannot be displayed. #5441

Open whitestarlau opened 3 months ago

whitestarlau commented 3 months ago

Glide Version: 4.16.0

Device/Android Version: Xiaomi 14,Anroid version 14

Use Detail:When RequestOptions is not set, it works fine. But after setting it, it doesn't work.

Glide load line / GlideModule (if any) / list Adapter code (if any):

        val options = RequestOptions().fitCenter()

        Glide.with(this)
            .load("https://oss-console-img-demo-cn-hangzhou-3az.oss-cn-hangzhou.aliyuncs.com/example.gif?x-oss-process=image/resize,w_200/format,webp")
            .apply(options)
            .placeholder(R.color.black)
            .into(binding.image)

Stack trace / LogCat:

2024-08-23 10:57:19.341 13550-13550 Glide                   com.example.notificationtest         I  Root cause (1 of 1)
                                                                                                    java.lang.IllegalArgumentException: Unable to convert android.graphics.drawable.AnimatedImageDrawable@b990125 to a Bitmap
                                                                                                        at com.bumptech.glide.load.resource.bitmap.DrawableTransformation.transform(DrawableTransformation.java:55)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onResourceDecoded(DecodeJob.java:578)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob$DecodeCallback.onResourceDecoded(DecodeJob.java:642)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:60)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:539)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:503)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:489)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:434)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:399)
                                                                                                        at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:100)
                                                                                                        at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:62)
                                                                                                        at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:77)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:277)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)
whitestarlau commented 3 months ago

I see the implementation of GifDrawableTransformation in the code, but the webp animation does not seem to have a corresponding implementation?

spocky commented 2 months ago

You can replace with optionalFitCenter to make it work. cf: https://github.com/bumptech/glide/issues/4943