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

The Gif load problem, can't display well #1059

Closed
atenjin opened this issue Mar 16, 2016 · 10 comments · Fixed by #1323
Closed

The Gif load problem, can't display well #1059

atenjin opened this issue Mar 16, 2016 · 10 comments · Fixed by #1323
Assignees
Labels
Milestone

Comments

@atenjin
Copy link

atenjin commented Mar 16, 2016

Hi, I load a gif image from local
The gif:
Image
and other gifs:
Image
Image

I use
int source = R.drawble.xxx;
Glide.with(this).load(source).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
to load those Gifs

But I find the gif1 and gif2 can't display very well, though the gif can display on the phone, but it flick(flash , twinkle, glint sorry I'm not a English speaker, I don't know how to express it well, all in all the Gif1 and Gif2 in glide are not playing well, It seems that the last frame doesn't disappear)

However the 3rd Gif is normal.

I'm confused about the question, I try many gifs and find it seems that when the gif's background is transparent it will appear(not for all, just some of them)

I use Glide 3.6.1
and also find this problem in 3.7.0

But when I choose another gif lib like:
koral--/android-gif-drawable
it display all gifs very well.

So I help to solve this problem.
Thank you very much!

@TWiStErRob
Copy link
Collaborator

I think what you see is #836, the fix is done for v4, but needs to be copied into v3, this is tracked in #970. Please confirm that the "screenshot" in #836 is similar to your "flash".

There's also a possibility of using external libraries to display stuff, see #805.

Tip: don't use .diskCacheStrategy(SOURCE) for local images, that will duplicate the file (in APK, and on SDcard) without any performance benefit. Use NONE for local GIFs.

Tip: use adb screen record /sdcard/demo.mp4, then adb pull /sdcard/demo.mp4, then upload at http://ezgif.com/video-to-gif to make a "moving screenshot" that you can embed on GitHub/StackOverflow.

@atenjin
Copy link
Author

atenjin commented Mar 16, 2016

Thank you very much for you answer, I will check soon.
But I have another question:
I use .diskCacheStrategy(SOURCE) because I think I load gif is too slow, so I find the issue #600

so I use .diskCacheStrategy(SOURCE) in my code

Depending on what you say, I should use .diskCacheStrategy(SOURCE) only in network gif? But NONE for local gif? (To be honest, I think if I don't use .diskCacheStrategy(SOURCE) for local gif, It loads too slow...)

and also think for you next tip~

@TWiStErRob
Copy link
Collaborator

Yes, you see it correctly, it's weird for opening a stream from APK to be slow, I have no idea about that. You can try putting the image in raw or assets, but I don't think it'll make a difference.

Wait... by NONE I mean to explicitly call .diskCacheStrategy(NONE); if you don't call that method at all (omit it from code), it's the same as .diskCacheStrategy(RESULT) which is known to be slow for gifs.

@atenjin
Copy link
Author

atenjin commented Mar 17, 2016

@TWiStErRob
I try you advice today. For a directly method, I use 4.0.0-SNAPSHOT to try my gifs.
I follow the guide in Snapshots
and use glide:4.0.0-SNAPSHOT in gradle

dependencies {
compile 'com.github.bumptech.glide:glide:4.0.0-SNAPSHOT'
compile 'com.github.bumptech.glide:okhttp-integration:2.0.0-SNAPSHOT'
}

and the Glide code change to

 int source = R.drawable.xxx
   Glide.with(this)
           .load(source)
           .into(imageView);

I tried the first Gif , it seems become normal
image
gif1

(The upper image is loaded by android-gif-drawable and the under image is loaded by Glide)

But when I tried second Gif, it look like what I said before “flash or glitter in some frame”
this is link
image2
gif2

It seems that there are also some bugs in v4 :(

@TWiStErRob
Copy link
Collaborator

Can you try with .diskCacheStrategy()? You may be seeing #1061 which was just reported. I think the v4 format is something like: .apply(new RequestOptions()....)

@atenjin
Copy link
Author

atenjin commented Mar 17, 2016

@TWiStErRob
I'm so sorry... I used in this way

Glide.with(this)
.load(source)
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(imageView);

But It's still like this:
image

It's the local image so I use DiskCacheStrategy.NONE

@TWiStErRob TWiStErRob added this to the 3.8.0 milestone Mar 17, 2016
@TWiStErRob
Copy link
Collaborator

Hmm, it looks like sometimes only half of the frame is decoded, maybe the Bitmap is displayed while it is still decoding, which would be really weird.
Notice there's also a frame where the guy's head is black-ish.

@TWiStErRob
Copy link
Collaborator

@jkingdom check out #1093.
Thank you for reporting this issue, and sorry for saying it's a dupe.
It turns out this was a well-defined issue, thanks for all the screenshots as well it helped a lot!

@TWiStErRob
Copy link
Collaborator

Fixed in #1093, should available as 3.8.0-SNAPSHOT.

@TWiStErRob TWiStErRob self-assigned this Mar 26, 2016
@atenjin
Copy link
Author

atenjin commented Mar 28, 2016

Thank you very much for you help! ! !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants