jesusrp98 / spacex-go

Simple yet powerful, open-source SpaceX launch tracker.
https://play.google.com/store/apps/details?id=com.chechu.cherry
GNU General Public License v3.0
880 stars 252 forks source link

Memory consumption is too high #37

Closed mneira10 closed 5 years ago

mneira10 commented 5 years ago

Environment

App version:

2.3.1

Android version:

Android 9 Pie (API 28)

Device information:

Xiaomi Mi 8 lite

Description

The memory consumption of the app can get up to 300Mb!!! (see memory profile of the app in the images section) This happens because the urls gotten from the spacex API correspond to images in flicker that can be 6k by 4k and are stored in cache with the widget CachedNetworkImage in cache_image.dart.

What you'd like to happen:

To lower memory consumption and still have a great image quality, one could reduce the size of the images a little bit or consider not storing them in cache.

Alternatives you've considered:
The easiest way to reduce the image size is to use flicker's API. Here is how one can change the url of the images to get a lower resolution. I will be issuing a pull request soon with code that shows how that can be easily integrated in your app.

Images:
image

mneira10 commented 5 years ago

Pd: It would be amazing if users could set the image quality! This way, they could choose if they want to sacrifice their data consumption or not.

jesusrp98 commented 5 years ago

Thank you very much for your feedback! I'm planning to add a new settings option, where users can select the resolution of the images from Flickr.

By default, image resolution would be high enough for mobile users - maybe medium or small.

If you think how this feature could be implemented, share it!

This will be included in the v2.5 release, scheduled for release in June, since I'd have to implement a new system which checks user preferences.

jesusrp98 commented 5 years ago

Which quality levels should I, in your opinion, implement? I'm going to use the Flickr URL API, as you suggested in the pull request.

As for the quality levels, I was thinking about adding just three:

At this moment, the app uses two kinds of quality:

Any suggest?

jesusrp98 commented 5 years ago

Image quality settings

mneira10 commented 5 years ago

The issue boils down to a trade off between image quality and memory consumption. I would prioritize user experience and start at the upper end with high quality images and gradually decrease the quality until it is no longer pleasing. From that point, if the memory consumption is still too high, further optimizations would need to be done.

On the other hand, I think the quality levels are good. The benefit is that they are not too hard or tedious to implement.

jesusrp98 commented 5 years ago

I've been working in the image_quality branch for a couple days now, and already pull all changes to the dev branch.

As describe in #44, there's now a new setting, where you can select image quality for all photos, stock & downloaded ones.

If I have some spare time in the coming days, I'd like to check the performance improvements this new feature brings to the table.

If you want @mneira10, you could check how this improves performance.

Thank you very much for your feedback, you've helped me improve this app!!