Piwigo / piwigo-flutter-app

Piwigo mobile application for Android
GNU General Public License v2.0
83 stars 26 forks source link

version 2.0.3-beta uses too much memory and is often killed by Android #156

Open tanty opened 1 year ago

tanty commented 1 year ago

This is not new from this version. Has been happening for quite a while.

remi-martin commented 1 year ago

Hi, that sound strange. Did it worked properly before ? How many files are in the albums and what's their file type (jpg, png, heic, mp4, ...) ? In the app settings, what's the thumbnail size (medium, large, ...) ?

Also, can you give me more information about the device ?

That will help me to understand and maybe reproduce the issue...

tanty commented 1 year ago

Hi, that sound strange. Did it worked properly before ?

In my experience, the application has never worked very well. Before it may load an album but take very long time on getting the thumbnails and be able to scroll. Others, it just crashed.

How many files are in the albums and what's their file type (jpg, png, heic, mp4, ...) ?

It varies a lot. From tens to thousands.

I can reproduce with any album so, let's say, just a bunch of pictures (8?) and all of them JPEGs.

In the app settings, what's the thumbnail size (medium, large, ...) ?

Medium.

Also, can you give me more information about the device ?

That will help me to understand and maybe reproduce the issue...

Sony Xperia zx2c running LineageOS 19-20220902-NIGHTLY-xz2c

Is there any way I can get any debug information or logs from the app?

tanty commented 1 year ago

And just now, the application also crashed just by opening, going to the settings and clicking to the back arrow ...

remi-martin commented 1 year ago

I think this is related to the image cache. In order to find a solution I might need an access to your Piwigo (just as a guest), so I can try to reproduce it and locate the error.

tanty commented 1 year ago

My gallery is publicly available at: https://gallery.andresgomez.org/

If you need to log in with the minimal privileges, let me know how can I send you the credentials through a private channel.

remi-martin commented 1 year ago

Ok so I am abled to access your Piwigo but the app doesn't crash when I open the albums.

Maybe try to empty the cache from the app settings, or just reinstall it.

tanty commented 1 year ago

I've emptied the cache: same result.

I've reinstalled the application: same result.

Is there any way of getting logs or backtraces from the app?

tanty commented 1 year ago

BTW, by now I'm using 2.0.4

remi-martin commented 1 year ago

Which version of Android you are running ?

Sadly I don't know how to get the logs on a Flutter application like Piwigo NG.

tanty commented 1 year ago

Which version of Android you are running ?

Sony Xperia zx2c running LineageOS 19-20220902-NIGHTLY-xz2c

https://wiki.lineageos.org/devices/xz2c/

LineageOS 19 is based on Android 12L

Sadly I don't know how to get the logs on a Flutter application like Piwigo NG.

This may be a priority to be able to use a beta application. If it is beta and for users evaluation it looks critical to me that there should be a way of getting some logging information or, at least, be able to catch a crash stack trace.

tanty commented 1 year ago

So, after a quick session with adb logcat the problem seems to be that the application is not crashing but rather being killed by Android's lowMemoryKiller (which also kills plenty of other apps at the same time than killing Piwigo NG):

` 05-25 16:20:36.840 0 0 I lowmemorykiller: Killing 'iwigo.piwigo_ng' (32188), adj 0,
05-25 16:20:36.840 0 0 I : to free 1722272kB on behalf of 'UsbFfs-worker' (31715) because
05-25 16:20:36.840 0 0 I : cache 29712kB is below limit 73728kB for oom_score_adj 0
05-25 16:20:36.840 0 0 I : Free memory is -4392kB above reserved.
05-25 16:20:36.840 0 0 I : Free CMA is 668kB
05-25 16:20:36.840 0 0 I : Total reserve is 45728kB
05-25 16:20:36.840 0 0 I : Total free pages is 17972kB
05-25 16:20:36.840 0 0 I : Total file cache is 251876kB
05-25 16:20:36.840 0 0 I : Slab Reclaimable is 62696kB
05-25 16:20:36.840 0 0 I : Slab UnReclaimable is 252012kB
05-25 16:20:36.840 0 0 I : Total Slab is 314708kB
05-25 16:20:36.840 0 0 I : GFP mask is 0x24040c0
05-25 16:20:36.840 0 0 I : Indirect Reclaimable is 0kB
05-25 16:20:36.840 0 0 I : Free Swap 11292kB 05-25 16:20:36.840 0 0 I : queue len is 1 of max 1 reason:0x2 margin:-3548 05-25 16:20:36.840 0 0 I : psi full is 0 psi some is 0

[...]

05-25 16:20:36.925 0 0 I oom_reaper: reaped process 32188 (iwigo.piwigo_ng), now anon-rss:0kB, file-rss:1074336kB, shmem-rss:252kB `

Also, you can see plenty of these warnings:

05-25 16:29:42.730 5874 5904 I flutter : Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction

So, other than my phone could have more RAM (4G), often "only" ~700M free, it seems that the Piwigo NG app is not really handling well the amount of used memory. Probably, loading everything even if it is not visible to the user.

The oom killer only happens with this application. I don't usually see this happening.

remi-martin commented 11 months ago

Hi, this is because the app shows a lot of images and so I added a cache for that. The problem is that it is still taking too much memory on certain devices. I have made some small changes about this but it is hard for me to tell if it will be efficient.

remi-martin commented 11 months ago

I've made some changes to image display and cache for version 2.2.0.

Please feel free to try it out and see if it solves the issue.