glide icon indicating copy to clipboard operation
glide copied to clipboard

WebpDrawable is not rendering last frame

Open HellyP16 opened this issue 1 year ago • 0 comments

When animation callbacks are registered, last frame is not getting rendered. It affects in some cases when user is supposed to see last frame for 2 3 seconds.

Glide Version: 4.16.0

Integration libraries: No

Device/Android Version: On all android devices, the issue persists, but same webp is running fine in iOS.

Issue details / Repro steps / Use case background: Create one webp, where last frame is different that second last frame(can be same frame as well but to distinguish both frames pls use different frames). Add some delay (3 seconds). Set loopcount as 1 programmatically. Attach animation callbacks via registerAnimationCallback. Now run the app and see the behaviour. Last frame is not rendering. Ideally it should.

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

Glide.with(imageView.context)
            .load(url)
            .listener(object : RequestListener<Drawable?> {

                override fun onLoadFailed(
                    e: GlideException?,
                    model: Any?,
                    target: Target<Drawable?>,
                    isFirstResource: Boolean
                ): Boolean {
                    return false
                }

                override fun onResourceReady(
                    resource: Drawable,
                    model: Any,
                    target: Target<Drawable?>?,
                    dataSource: DataSource,
                    isFirstResource: Boolean
                ): Boolean {
                    if (resource is WebpDrawable) {
                        resource.loopCount = 1
                        resource.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() {
                            override fun onAnimationEnd(drawable: Drawable?) {
                                super.onAnimationEnd(drawable)
                                imageView.setImageDrawable(null)
                                imageView.visibility = View.GONE
                            }
                            })
                    }
                    return false
                }

Layout XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:id="@+id/test_iv"/>

</LinearLayout>

Stack trace / LogCat:

no errors

https://github.com/bumptech/glide/assets/37337020/f0cf67d9-7571-4b3b-abc8-c556fc578734

https://github.com/bumptech/glide/assets/37337020/e09384bb-2fa8-4b08-b781-52ba36c2289e

HellyP16 avatar Apr 26 '24 07:04 HellyP16