-
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
High CPU usage when playing GIFs #1029
Comments
You're saying you're displaying a list of images that are animated, I think it's normal to use some CPU power this case, especially if you have a GridLayoutManager. Glide decodes frames on the fly and this way it saves a lot of memory and also reuses the frames so no need for constant GC-ing. If you were to pre-load all Bitmaps of all frames (spike in CPU) and then use those memory-cached frames (low CPU) you would likely run into OOM. Consider displaying static images ( Alternatively stop playing GIFs after 10 seconds of no user interaction by doing setting a flag on the adapter (that the user didn't move) and calling |
I checked with LinearLayoutManager and 2 GIFs visible at a time the CPU usage is 30-40%. With GridLayoutManager and 10 GIFs visible (skips lot of frames but that okay) at a time it is 60-70%. I like your suggestion of playing GIF on tap and stop playing after some timeout. Should save some battery. Thanks |
This is really a game of compromise, CPU/battery or memory... both are scarce resources in Android. You should be able to call |
Thanks a lot for your helpful suggestions. |
I am displaying GIFs in a RecyclerView. Code:
If I keep the Fragment containing this RecyclerView open, very high amount of CPU (~40%) is used by the app. And the phone heats up if I use the Fragment for 1-2 minutes. Is it normal for GIFs? Am I doing anything wrong here?
The text was updated successfully, but these errors were encountered: