koral-- / android-gif-drawable

Views and Drawable for displaying animated GIFs on Android
Other
9.51k stars 1.78k forks source link

Gif slows down when starts multiple times in a row #800

Closed Alice2828 closed 1 year ago

Alice2828 commented 1 year ago

I have got GifImageView in xml and this is in code on init: var gifDrawable = GifDrawable(resources, R.drawable.pig_animation) - get gifDrawable from resources gif.setImageDrawable(gifDrawable) - set drawable to gifImageView with id "gif"

After button click:

gif.visibility = View.VISIBLE gifDrawable.start()

val delay = gifDrawable.duration.toLong() - i get a time of gif animation to play exactly one loop and show loader during this time

postDelayed({ gifDrawable.stop() gif.visibility = View.GONE ... }, delay)

AFTER click, button is not enabled, so I am calling clickListener again exactly after the gif duration time. However, gif slows down and stops in time of this fixed duration, but just in the middle of gif playing. And every time it slows more and more. How can I use recycle, or somehow free resources to remove slowing down of gif?

koral-- commented 1 year ago

Could you create a complete sample project which reproduces this issue? You can fork this repo and modify the sample project.

koral-- commented 1 year ago

Closing due to inactivity.