nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.25k stars 1.76k forks source link

Improve power usage by not trying to do stuff in background during flight mode #13008

Closed SvenLieber closed 2 months ago

SvenLieber commented 5 months ago

Is your feature request related to a problem? Please describe.

There is a high battery usage by Nextcloud even when I am in flight mode. When I am already on a lower battery it can happen that the phone turns off at night and I don't even have an alarm in the morning which is frustrating. I am aware that there are obvious solutions which I also list below. But I still think that there could be also a technical solution in which the Nextcloud app behaves more smart.

Describe the solution you'd like

I am aware that I explicitly turned of the "power save check" in Nextcloud to let auto-upload work efficiently. However, for moments when I (also explicitly) turn the phone into flight mode I would expect Nextcloud to be smart and "knowing" that there currently is no Internet and thus no reason to perform auto-uploading or other background tasks. I am not an Android developer, so I don't know if it is technically possible to fix this issue. But I would imagine some sort of check that Nextcloud only wakes up and tries to do uploads when the phone is not in flight mode.

Describe alternatives you've considered

Both technical solutions to manually turn on power saving and later torn it off again seem a bit overkill considering that this need to be done every time.

Additional context

I am aware that in the example shown in the following screenshot there is already a low battery. Something that some people might even consider a very low battery. But still, without active apps, a battery level of around 25% should be enough to survive the night if in flight mode.

nextcloud-power-draining-flight-mode

joshtrichards commented 5 months ago

Hi @SvenLieber - Since many of these issues are specific to not only specific Android OS versions, but many other variables (some which are unknown or we'd have addressed them can you share:

I completely believe you're experiencing this, but as a point of reference I do not on my Pixel 7 and I never charge it overnight either.

Nextcloud to be smart and "knowing" that there currently is no Internet and thus no reason to perform auto-uploading or other background tasks.

There really shouldn't be anything to upload if these are just media folders.

Are there any queued up or processed items in the Uploads tab overnight?

Since it's unclear what is triggering the usage, it would be potentially helpful to maybe gather logs from the device to see what it's constantly trying to do too (if you're able): https://github.com/nextcloud/android?tab=readme-ov-file#logs

SvenLieber commented 5 months ago

Hi @joshtrichards,

my apologies for not including more context information. Because I used the enhancement issue template and not the one for bugs, I missed adding it.

For auto-upload I only have custom folders, because I started to use the SD card as default storage for WhatsApp and my Camera. Those folders weren't auto-detected after I moved them to the SD card (this also leaves me with a mixed photo/video destination folder for my camera, because the type of media is not something to select for custom-folders. Anyway, this is another problem).

Other notable things:

Occasionally I also see the Preparing auto upload notification, but nothing is happening https://github.com/nextcloud/android/issues/12596 I checked that bug report before opening this issue, but apparently I missed the fact that a decrease in battery is also reported. I have the feeling it is related after all. Sorry for not checking more in detail.

I'd love to gather logs, but unfortunately I don't have a suitable setup at the moment (no root privileges on phone nor computer). But I have a linux VM running in Hyper-V. I could try to run adb from that. But I think this is not straightforward from what I can see from the Google search results.

JonasMayerDev commented 4 months ago

Currently, we collect the changed files all the time and only the upload process (which is independent) checks if the file is ready for upload. So we scan the file system regularly even when flight mode is active. Currently, the advantage of that is that when for example you are on vacation and not in Wi-Fi, take a lot of images, it already collects files while not in WIFI and can directly start uploading once in WIFI. Else it could take some time (in theory about 20min but in reality with background restrictions often more than 1h) until the images are collected and ready for upload. Changing this to the behavior you suggested (not scanning file system while phone is in air plain mode / not meeting the folder requirements) would be "easy" but I am not sure if we should...?