francoisfds / BikeSharingHub

Shared bikes for Android
GNU General Public License v3.0
18 stars 10 forks source link

250 MB of cache map tiles in my external memory #31

Closed Altonss closed 1 year ago

Altonss commented 2 years ago

BikeSharingHub is storing 250MB of cache map tiles on my external SD card. This seem to be a bug of the app, because such an amount of cache is just too big :laughing:

francoisfds commented 2 years ago

Hello, is it "cache" or "user data" ? If it is cache you can safely click the "clean cache" button on the Android Settings of the app.

On my phone indeed there is around 100Mo of user data, I think this huge amount of data must be the map tiles that are cached by osmdroid (the images of the map). This behaviour allows to browse portions of the map that have been previsouly visited without contacting the tile server again. Currently you cannot erase the "user data" safely because if you do, you will loose your app's setup (bikesharing networks, favorites stations).

In "Openbikesharing" the tiles were stored on a directory that is accessible by the user (/storage/emulated/0/osmdroid). This means that the user could use the file manager to erase this data on his own. However this is not the case in "BikeSharingHub" because I removed the STORAGE permission. In consequence, the app cannot write (neither read) in the user accessible storage. If this leads to problems in user storage, this behaviour must be reconsidered in order to give more control for storage management.

Altonss commented 2 years ago

Hello, is it "cache" or "user data" ? If it is cache you can safely click the "clean cache" button on the Android Settings of the app.

It is actually considered as "user data", despite being cached map tiles

francoisfds commented 2 years ago

After verifications, the osmdroid library allocates a maximum of 600MB to store map tiles. If you browse a wide area, you could increase the space used until then, which could be a problem for devices that don't have much space.

Even if we don't browse map offline because the stations data would be out dated, storing map tiles is important to avoid contacting openstreetmap servers too often (they have limited resources). I noticed that the app "Vespucci" offers the users the possibility to set the maximum space needed to cache map tiles, I think this behaviour is what we need : allowing to set for example between "20MB" and "600MB", with a default value of 100MB. What do you think ?

Altonss commented 2 years ago

Even if we don't browse map offline because the stations data would be out dated, storing map tiles is important to avoid contacting openstreetmap servers too often (they have limited resources). I noticed that the app "Vespucci" offers the users the possibility to set the maximum space needed to cache map tiles, I think this behaviour is what we need : allowing to set for example between "20MB" and "600MB", with a default value of 100MB. What do you think ?

I totally agree with you! Having too much cache is not usefull indeed as to have up to date bike data the phone needs to be connected to the internet. But not stressing too much the openstreetmap servers and reducing the amount of bandwidth needed is also important. So 100MB and the ability to customize the cache value seems fine to me! Maybe a way to clear the cache would be good also, I don't know. Maybe the cache size setting is enough :)

francoisfds commented 2 years ago

A way to clear the cache could be good, I will see (if the user set a value which is less than the current cache used, may be the best thing to do is to clear automaticaly).

Another thing, you said that the cache was stored in your external memory, not your internal memory ? (this doesn't seem to be a default behaviour)

Altonss commented 2 years ago

Another thing, you said that the cache was stored in your external memory, not your internal memory ? (this doesn't seem to be a default behaviour)

Yes this is because I moved the app to external storage

francoisfds commented 1 year ago

In the new release a cleaning routine is triggered each time you enter the map : the cache exceeds 100 MB, it is trimmed to 20 MB. If you want to clear the cache, just change this value from 20 to 0 in the advanced settings.

francoisfds commented 1 year ago

The clean-up is quite slow : for example 180 MB took me 7 minutes (the most old data in cache is erased first, in order to keep the most recent).

Altonss commented 1 year ago

It works :) Thanks a lot! I will close the issue as it's fixed :)