-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
GIFs animate slowly with Glide 4.2 #2471
Comments
same as me. Can you give me some advise about the hand on code to load gif with 4.2.0? call my 18221650910 from china? |
I'm not able to reproduce this on a Nexus 5X on 7.1.1 if I download the gifs you've pointed to. The GIFs are however pretty small. Can you attach the files you're having trouble with directly to the issue to make sure we're testing using the same exact data? Can you also provide the XML or at least the dimensions of the view you're loading into? |
Hmm, I think I must have made a mistake in my original issue report. I just tried building a sample app with a jarjar'd version of 3.7 and an unmodified 4.2 together in the same app which loads the same GIF into two adjacent ImageViews using two different versions of Glide, and I'm also not able to reproduce this. What I am seeing, however, is that GIFs render in slow-motion with both Glide 3.7 and 4.2 on Android 5.0 and Android 6.0 devices (a Nexus 5 and OnePlus One, respectively), but render at normal speed on an Android 8.0 device (Pixel). I tried a sample app with a single 3.7 or 4.2 production dependency, loading a single GIF, and the results are the same. Things render fine (with both 3.7 and 4.2) on an Android 8.0 device, but not an Android 5.0 or 6.0 device. Here's a sample layout I'm using:
The Glide 4.2 code:
|
Thanks for the follow up. That makes sense. The GIF decoder we use isn't necessarily as fast or optimized as it could be. We've fixed a few cases where it was slower than it needed to be, but there may be more relatively simple changes we could make. Otherwise it might require a more fundamental restructuring. One other idea we've been looking in to is adding support for rastermill/framesequence or another third party gif decoder as an integration library. |
I ran into this issue on a Nexus 5 running 6.0.1. When running the debug Build Variant gifs perform poorly. Once I switched to release, gifs began performing as expected. Hope this helps out... |
I haven't found anything huge so far but two things worth noting:
More to come as I find it. If anyone else has any suggestions or can reproduce any particularly bad cases, I'd welcome the help. |
@ssessa Are you using proguard? Do you have optimizations enabled? If you disable proguard but otherwise leave you release variant the same, do you still see GIF performance improve on those builds? |
Cuts ~40% off of frame rendering times on API 23 emulators and devices. Progress towards bumptech#2471.
These small additive changes might save ~5-10% decoding some GIFs, depending on the vagaries of the particular file. Progress towards bumptech#2471.
It adds complication and data copying and doesn’t seem to make much of a difference in multiple low/high end devices or emulators. If it seems like I/O might be a blocking issue, we can try just copying the file into a byte[] in the ByteBufferGifDecoder the same as we do for the stream decoder and wrapping it in ByteBuffer. Progress towards bumptech#2471.
I've pushed a series of (hopefully) safe changes. Referencing the intermediate arrays in local variables seems to make a really large difference on API 23 devices, though I don't see the same difference on API 26. The rest of the changes are much smaller improvements. I have a couple of larger fixes including automatic pausing of detached animatables and an option to cache color table indices for all GIF frames (one byte per changed pixel per frame vs four bytes per pixel for all pixels per frame if we cache the entire frame). I may hold off on those until 4.5 to give us some more time to test. GIFs are difficult to test and there's lots of expected but not to spec behavior that can make things that seem like they ought to be safe unsafe. |
Realised that we are looking at the wrong place on this GIF issue. Problem isn't with Glide, but it how Android is recognising the
In fact, because the API that Giphy uses for that image was specify the TLDR
|
Hi, I have the same problem too.
But we can't found these APIs in Glide 4. |
For me The test is not only on glide , i also try to play this gif with the default way the device offered. But if i choose another gif (400*300, 7.2MB), it performance perfectly on all devices above. So try to compress your gif or choose play it as movie will partly solve this problem. Sorry for my poor English, I'll repeat my words in Chinese gif动画帧率低的问题应该不只是glide的问题,各位如果能把设备信息和gif信息一起贴上来可能会更快的明确问题是关于设备还是这个库。 最终我的解决方案是用movie来播放gif,这样可能会导致丢帧,但是至少时间长度是一致的 |
I tried this,
But it still plays in slow motion in RecyclerView.
|
Any update on this? |
GIPHY wrote a blog post explaining the details of how Fresco handles GIF better and to quote the post.
|
Pretty major issue, this should be fixed somehow in the next release! |
I have the same problem , i recomended change to Fresco , its more fast and complete compared to Glide |
@skyfit2 Do you know if Fresco allow playing GIFs from a url like Glide does? |
@takaoandrew For the size of this library, it better be.... |
Adding crossfade on local image drawable worked for me.
|
Also experiencing this on most devices I have tested it on, from Galaxy s10 to nexus 5. It is much more subtle on higher end devices but is still noticeable. |
Have you tried with Glide 3.7.2? |
Wow..... just tried doing some rewrites to go back to 3.7.0 and gif performance dramatically improved (night and day difference). This makes me chuckle because they cited improved Gif performance as one of the reasons to upgrade to 4 (I started with 4). I have been sticking with Glide 4.2 because performance got a lot worse in the 4.3 update though I have been testing each version afterwards to see if it gets better and it hasn't. Here is what I have found: |
@andrewcking Can you please show a sample, so that I could see the difference? |
Visually? There are some examples above but here is what I am seeing in terms of performance difference between 3.7 and 4.9 download.zip This is on a galaxy s10 displaying 4 low-res optimized gifs and 3.7 blows 4.9 out of the water. |
@andrewcking I meant as projects, but visually I see on your sample that there is a difference... |
I've tested on nexus 4,5,5x and galaxy s8,s10 and then also on OnePlus 6. It is noticeable on all devices at least for my use case. I don't know the android version of each device but it ranges from android 5 on the nexus 4 to android 9 on the galaxy devices. Note these gifs are all local on the device (not loading from the internet). I don't have a project implementation I can share but my glide calls between 3 and 4 are pretty similar 3.7
4.+
|
@andrewcking OK I've tested it myself on LG G5 with Android 8. Attached sample project, using what you guys wrote. While I don't see much issue on how fluid it plays, here are the results in CPU usage via the profiler: 4.9.0: 3.7.0: How did you perform the test? |
Wow was just wondering how good Glide performance was with gif's and this thread just opened my eyes, guess I'll jump onto the Fresco bandwagon for smooth gif playback |
@droidluv Where exactly? Please show a sample showing the issue |
@droidluv technically, Glide 3.7.2 was ok |
I don't have a sample anymore, I encountered a stutter/slowdown when my backend started sending a gif accidentally instead of an image, on a Galaxy On6, and I am using the latest version of Glide (4.9.0), I am hesitant to add Fresco though because of it's much larger size, but saw above that Fresco performed better than Glide with its native code usage, I'll try to generate samples soon enough to compare because a new requirement to support gif playback is incoming. |
Can you please put a sample of the best Glide , the newest one, and of Fresco? |
@AndroidDeveloperLB I am attaching the videos below differentiating Fresco and Glide, this slowdown seems specific to only certain devices like I have encountered the Glide slowdown in two Samsung phones but works fine on everything else including other Samsung phones like the Galaxy S7, even though Fresco gives a uniform GIF experience throughout every device, Glide has better performance advantages when dealing with complex images and recyclerviews, like fresco doesn't even support PNG resizing (we can do some downsampling but..) when dealing with complex lists of images and gifs Glide wins hands down, I just switched back to Glide even though I might have to deal with slowed down GIFs in some devices This comparison is between the newest glide and the latest version of Fresco |
@droidluv This is of the newest Glide, right? |
@AndroidDeveloperLB Its on the latest Glide 4.9.0, I haven't tried the 3.x glide because I didn't want to go back to an older version, the code is just a basic vertical Recyclerview with horizontal list's of GIF's and PNG's, Also please do note my point, the slowdown happens only on CERTAIN devices, one such model is the Galaxy J7 Pro, with Android Pie(Android version 9) and OneUI 1.1 and is the stock OS, if you want I can try and generate logs from that device, if I could but I suppose the video should talk for itself, the other device was also a Samsung, a Samsung Galaxy A series device, I can get more info about that device as well if needed, and I'm fairly sure the slowdown is happening on some other devices as well, Fresco seemingly works smoothly everywhere though regarding GIF playback. |
@droidluv Please share the project of Fresco. |
I found a case. Gif is showing slowly when I using "wrap_content" for width and height of ImageView. There is no problem if I use with static width and height such as "80dp". Try this.
Also, Gif loader this (Glide 4.10.0);
|
I have similar problem with high frame rate GIFs (50fps). 30fps GIFs play as they should. For comparison - MIUI Gallery plays all GIFs smoothly. Glide 4.13.2 |
Step 1. Make your gif height/width as small as possible, remove extra large background |
None of the above solutions other than the following comment #2471 (comment) |
Setting fixed height & width worked for me. Don't use wrap_content or 0dp in constraint layout. |
Here is a screen capture of two gifs playing w/ Glide 3.7:
Here is a screen capture of the same two gifs playing w/ Glide 4.2:
This happens with any gif that I've tried, here's an example:
https://media.giphy.com/media/3ohjV3cQ9lvPeCVLOg/giphy.gif
Glide Version: 4.2.0
Integration libraries: None
Device/Android Version: Nexus 5, OnePlus One, Pixel
The text was updated successfully, but these errors were encountered: