-
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
Glide gif CPU consumption #1604
Comments
Hello @TWiStErRob! Excuse me for upping this but I really need to understand it. Do you have some spare time to answer me? |
At the moment gif frame decoding simply is CPU intensive. Using transformations that upscale can dramatically increase CPU usage, but even just decoding frames with no downsampling or transformations is expensive. The Android framework has a library called framesequence that will decode animated GIFs and WebP images. It's relatively simply to integrate it with Glide. If you do write the integration and would like to contribute it, I'd welcome the pull request. One option without relying on an external library would be to cache each frame of GIFs in our disk cache. Doing so requires passing previously the previous frame into our GifDecoder each time we start a new frame load so that we can initialize the decoder with the previous frame. If you'd like to work on that I'd be happy to try to point you in the right direction and would welcome a pull request for that as well. |
@sjudd Thank you for your answer. I understand these issues. But it's not that I asked :( |
You asked "What could you advice me to prevent excess CPU consumption?". Is that the question you're referring to, or did you mean to ask another? If you did mean to ask that one, I believe I addressed it, but feel free to ask for clarifications. |
The "framesequence" library doesn't come included as a library in the system directory. Did you mean that it instead should be added as a jni lib to glide itself? I'd be willing to do it, but wanted to clarify. |
@radixdev Yes, it would be another integration library (similar to the okhttp, volley and other libraries in integrations/). Here's a link to the library I'm referring to. I'm not sure if it's released just as code, or if it's actually part of a publicly released library somewhere, I'll try and look in to it: https://android.googlesource.com/platform/frameworks/ex/+/android-7.1.1_r6/framesequence/. |
That's what I found too. After trying to get that library to work, it seemed like it's only a code release and not a system library natively found on devices. The .so is only 25 KB though, so it wouldn't be that large of a file size hit to integrate it. |
Hello.
I have an adapter with gifs (important: it's inherited from BaseAdapter, not RecyclerView.Adapter). It contains gifs loaded from
original
url.Tested using Samsung A5 2016 - Android 6.0.1 - 2134 and with a total of 3 sent GIFs, only 2 were in focus and the app the CPU usage was at 50 - 65%. When all 3 GIF were in view, CPU consumption did not change.
Tested also with 15+ GIFs and CPU was at 99%.
In ideal world I would use
RecyclerView.Adapter
andRecyclerView.Adapter.onViewRecycled
method to clear ImageView. But it's impossible due to current implementation.What could you advice me to prevent excess CPU consumption?
The text was updated successfully, but these errors were encountered: