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

WebpDrawable is not rendering last frame #5400

Open
HellyP16 opened this issue Apr 26, 2024 · 0 comments
Open

WebpDrawable is not rendering last frame #5400

HellyP16 opened this issue Apr 26, 2024 · 0 comments

Comments

@HellyP16
Copy link

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
WebpExampleErrorCase.mp4
WebpExampleExpectation.mp4
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

1 participant