koral-- / android-gif-drawable

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

black screen phenomenon #822

Closed mshandan closed 1 year ago

mshandan commented 1 year ago

Hello, I have encountered some issues while using it. Mainly using the seekToFrame() method, there will be a black screen phenomenon.

koral-- commented 1 year ago

Please attach the reproducer project.

koral-- commented 1 year ago

Could you create a repository for that? Don't forget to include the affected GIF file.

mshandan commented 1 year ago

hello,I wrote a simple repository that can basically reproduce the phenomenon of lag, which is a white screen phenomenon.

https://github.com/mshandan/demo

mshandan commented 1 year ago

I look forward to your reply very much. I'm not sure if my writing is incorrect. This phenomenon has indeed caused me a lot of trouble.

koral-- commented 1 year ago

OK thanks, I'll check that.

koral-- commented 1 year ago

It seems to be the same issue as https://github.com/koral--/android-gif-drawable/issues/267#issuecomment-206962158 You can modify your Handler like in the linked comment.

mshandan commented 1 year ago

Okay, I'll take a look

mshandan commented 1 year ago

I'm very sorry, I can't understand what this "source" means? I don't know how to associate GifImageView in XML with this. Can you provide a detailed explanation?

ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); ExecutorHandler handler = new ExecutorHandler(executor); gifDrawable = new GifDrawableBuilder().taskExecutor(executor).from(source).build();

koral-- commented 1 year ago

source is resoruces, R.mimpap.<id> in your case. Instead of using XML, associate the drawable with view in the code: gifImageView.setImageDrawable(gifDrawable)

mshandan commented 1 year ago

Okay, where should I control the changes in gif frames? I tried to add logic to modify gif frames in ExecutorHandler, but it doesn't seem to change the playback of gifs?

koral-- commented 1 year ago

I've deleted a duplicated comment. You don't have to add any logic to modify frames. Here are the only modifications: https://github.com/mshandan/demo/compare/main...koral--:demo:main

mshandan commented 1 year ago

Sorry, it's possible that I didn't describe my problem clearly. I now need to implement a function that changes the display of gif based on a parameter. If the value is large, the gif will play to the back, and if the value is small, the gif will fall back to the front. In short, gif has 60 frames. When my parameter is 5, frame 5 is displayed, and when my parameter is 40, frame 40 is displayed.

mshandan commented 1 year ago

Using ExecutorHandler, I feel that the playback of gif is indeed very smooth, but this is not the feature I need, which is very regrettable.

koral-- commented 1 year ago

Ok now it seems I understand. I'm afraid you can't achieve smoother seeking using this library. The frames of a gif can contain only a difference between the actual frames which user sees. So in order to render the 100th frame it may be needed to render all the 99 frames before.

koral-- commented 1 year ago

I'm closing this issue as it seems to be answered, but you can still comment if needed.