nextcloud / android

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

Battery draining on android #7663

Open Maxence-v opened 3 years ago

Maxence-v commented 3 years ago

Battery is completely drained on android, I'd like to send a screenshot of my stats on my samsung

Steps to reproduce

1. 2. 3.

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Server configuration

Operating system:

Web server:

Database:

PHP version:

Nextcloud version: (see Nextcloud admin page)

Contacts version: (see Nextcloud apps page)

Updated from an older Nextcloud or fresh install:

Signing status:

Login as admin user into your Nextcloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results here.

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder

Nextcloud configuration:

If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your instance's installation folder

or

Insert your config.php content here
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your Nextcloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';

Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

Client configuration

Browser:

Operating system:

CardDAV-clients:

Logs

Web server error log

Insert your webserver log here

Nextcloud log (data/nextcloud.log)

Insert your Nextcloud log here

Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log 
c) ...
skjnldsv commented 3 years ago

Hi, sorry, but what does it have to do with contacts?

Maxence-v commented 3 years ago

Oops sorry no idea, but my phone (s20 plus) is showing huge amount of battery used by the nextcloud app, I disabled battery optimization in android because I use auto upload, and I'm not uploading 24/7 so I don't understand the battery drained A friend of mine has a s20 plus too and he doesn't have this problem Screenshot_20201214-150050_Device care

skjnldsv commented 3 years ago

Moving to the android repo

Maxence-v commented 3 years ago

So no idea?

tobiasKaminsky commented 3 years ago

what device do you have? Have you enabled auto sync?

Maxence-v commented 3 years ago

Samsung s20 plus, before I had the Samsung note 10 plus, and I had the same problem.

Yes I have the "auto upload" feature activated

ezaquarii commented 3 years ago

Can you check logs on the server to see if you get a lot of PROPFIND requests coming from the device every 15 minutes? :)

yawicz commented 3 years ago

@ezaquarii, I do actually observe exactly the behaviour you describe with two different Android phones having two different user accounts, yes. I found those entries in the logs of my nginx server running Nextcloud and was wondering whether this should be expected/desired behaviour or not. Do you have an idea what's going on with those random directory, but very regular PROPFIND commands? On both phones, the app is completely closed (not stopped via the app settings, but closed from task manager) and auto upload is deactivated.

ezaquarii commented 3 years ago

@yawicz I don't know exactly - as I'm not expert on files sync component - but I can only speculate that it polls the server for changes. I'd additionally check the interval - if it's 15 minutes, that would correlate with default background task wakeup.

One option is to turn on battery optimization for that app - it should stop OS from waking the app and giving it network access frivolously.

Is this expected? Yes, because sync is implemented using polling. Desired - hell no, but the fix is not trivial, to say the least.

github-actions[bot] commented 3 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

jeffWelling commented 3 years ago

I hope this doesn't get closed because of inactivity, it's a real problem for android users, I'd be happy to help poke at this if there's more info that I can provide?

Maybe instead of just checking every 15 minutes, we could let the user configure this setting? I would be quite happy with a nightly upload, I don't need my phone to check every 15 minutes. I also understand the desire to avoid options overload as mentioned in another Issue comment, but IMO this warrants a user configurable option of some sort.

jeffWelling commented 3 years ago

I'm currently seeing this battery consumption issue.

Android Samsung model SM-G965W Android 10 NextCloud App 3.15.1

AutoUpload is enabled, but has caught up with everything needing to be uploaded.

tobiasKaminsky commented 3 years ago

Do you know how many files/images you have on your device? It scans and compares them to find those needed for upload.

LSchober commented 3 years ago

I have the same problem of high battery drain.

Google Pixel 4a 5G Android 11 NextCloud App 3.15.1 (F-Droid-Build) NextCloudPi 20.0.8 ~30GB videos & photos

AutoUpload is enabled, but has caught up with everything needing to be uploaded.

jeffWelling commented 3 years ago

Do you know how many files/images you have on your device?

~15K photos and videos for me, totaling about 60GB.

It scans and compares them to find those needed for upload.

Understandable, but it seems the default value perhaps doesn't work for people with large existing camera rolls, one solution here may be to just let the user configure the app to only check nightly, instead of continuously. Is there any chance such a feature could be implemented, perhaps with a simple checkbox in Settings?

Also open to alternative solutions, maybe just let the user decide how often to check?

Even with working from home, having the app drain battery this fast is a big obstacle for getting the rest of the family to adopt NextCloud, so I'd like to help get this fixed any way I can :)

tobiasKaminsky commented 3 years ago

@jeffWelling are all files uploaded? I currently fear that pending uploads is more draining battery than auto upload does.

Maxence-v commented 3 years ago

I thought the problem came from a large amount of files too. I had 20k files for 185GO, but then i reduced the files to 3k and i have still the same problem....

jeffWelling commented 3 years ago

In my situation, all files are eventually uploaded yes.

@tobiasKaminsky That makes a lot of sense actually. The last few days I'll take a photo of something in the morning to send to someone (garden growth), and it queues for upload but has to wait for me to charge the phone because that's what I config'd, and Android frequently asks me if I'll let it put the app to sleep because of how much battery it's using. I'll try resisting taking pics to see if the battery usage is different with nothing pending an upload, good thought!

LSchober commented 3 years ago

Can i provide any additional information to solve this problem?

Maybe instead of just checking every 15 minutes, we could let the user configure this setting? I would be quite happy with a nightly upload, I don't need my phone to check every 15 minutes.

@jeffWelling i really like your solution with making this configurable!

A crontab like config would be great :)

geistchevalier commented 3 years ago

I would also like to put my vote behind having a user configurable sync frequency + a sync now button. For my case, I only sync a few critical files to my phone (less than 5MB) that rarely gets updated, but the battery is draining faster than before I installed the app.

Google Pixel 4a Android 11 NextCloud App 3.15.1 from Google's play store a self hosted Nextcloud 21.0.0 server

MikeZuluUSA commented 3 years ago

Hi, I have been observing a heavy drainage since a couple days. Samsung S9 - Android - April Update Nextcloud Version 3.15.1 4 Auto Upload Folders

Haven't had the problem that extreme. Only a couple auto uploads a day. Up to 85% consuming battery!!!!! (See the screenshot)! No pending uploads.

tempFileForShare_20210403-171953

github-actions[bot] commented 3 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

Zorks commented 3 years ago

this is definitely not a stale issue and is an ongoing problem for android users.

Samsung Galaxy Note 8 Android 9 Nextcloud App 3.15.1 Nextcloud Server 20.0.3

Used to be able to leave my phone off the charger overnight and only lose 5% or so battery life. Ever since enabling auto upload, I've seen extreme battery drain from the Nextcloud app and an extremely reduced battery time for my phone.

Maxence-v commented 3 years ago

I found a workaround which isn't ideal but it's the best I got. I enabled battery optimization for the nextcloud app and time to time I launch the app to start the upload. So nextcloud isn't draining battery in the background.

Maxence-v commented 3 years ago

Best fix by nextcloud team would be :

mgubis commented 3 years ago

I am observing same battery drain as other users. I think, it is connected to auto-update mechanism. I've made all four synchronized folders to upload only when the phone is on charger. It has indeed prevented uploads themselves to happen, but the application regularly checks all the files whether there is anything to upload (even though all folder are configured to not upload on battery) - at the end it never uploads anything when on battery. Configuration option, which would make the Nextcloud check for new files only on charge would probably solve my issues.

github-actions[bot] commented 3 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

mgubis commented 3 years ago

I see there is no activity on this issue and it is about to be closed in 2 weeks. The problem is still there - would it be possible to offer configuration to prevent Nextcloud background operations when not connected to charger?

J4gQBqqR commented 3 years ago

Same issue here. Nextcloud is basically the biggest battery drainer in the background when I lay my phone overnight during sleep.

No auto sync is turned on, I sync contacts using DavX5, but DavX5 is using less battery overnight.

I don't have any clue what Nextcloud is doing in background, nor do I have any clue why it needs to do those things.

b-m-f commented 3 years ago

I too am experiencing this as of last week.

J4gQBqqR commented 3 years ago

In the latest version 3.16.1, Nextcloud simply refuses to be optimized by system. "System restricted background, system doze, battery optimization, system force stop" all fail to stop Nextcloud. The app keep itself running in the foreground. There is no way to stop it. It drains 20% battery during a day's use.

Why is the battery usage of Nextcloud Android client becoming worse and worse during this year? I am not using it to sync or auto upload anything, how can it drain so much battery?

TvT82 commented 3 years ago

I am experiencing the same issue. Nextcloud is by far the biggest battery consumer on my phone (Samsung Note 10 Plus, Android 11). Auto-upload is enabled, but only when charging. I will turn on Battery Optimization and will give feedback if it helps. This problem is present for at least 1 year. I guess it will only get fixed if you buy premium subscription. So you should consider getting a subscription or change the product. Good luck to all of us, hope enabling battery optimization will fix it...

J4gQBqqR commented 3 years ago

For anyone having the same issue with me browsing this issue: If you have your phone rooted, you can turn off services using the "App Manager" app in F-droid. https://f-droid.org/en/packages/io.github.muntashirakon.AppManager/

Here is screenshots of services that I turned off to keep Nextcloud from draining my battery. Before turning these services off, Nextcloud cannot be "forced stopped", "dozed", killed. After turning them off, I can kill Nextcloud from the foreground and background once and for all. I don't know why Nextcloud Android is made in this way. It behaves like those Chinese app which cannot be killed and drains a lot of battery.

Screenshot_20210818-084701_App_Manager

Screenshot_20210818-084730_App_Manager

Screenshot_20210818-084722_App_Manager

Bernie commented 3 years ago

I am seeing a similar issue. In addition to my phone's battery, I am experiencing an issue where unnecessary PROPFIND requests from the android client keeps waking up my nextcloud server each time it occurs.

I attached my phone to adb to capture log messages via USB, and found this related to the OfflineSyncJob:

08-24 21:20:09.133  4071  3543 D OfflineSyncJob: /: enter
08-24 21:20:09.151  4071  3543 D OfflineSyncJob: /: currentEtag: 612438bbb5b8b
08-24 21:20:09.158  4071  3543 D OwnCloudClient #0: REQUEST PROPFIND /remote.php/webdav/
08-24 21:20:09.160  4071  3543 V NativeCrypto: SSL shutdown failed: ssl=0x701d3608c8: I/O error during system call, Broken pipe
08-24 21:20:09.162  4071  3543 D AdvancedSslSocketFactory: Creating SSL Socket with remote ***my.server.location***:443, local null:0, params: org.apache.commons.httpclient.params.HttpConnectionParams@2745e80
08-24 21:20:09.162  4071  3543 D AdvancedSslSocketFactory:  ... with connection timeout 5000 and socket timeout 40000
08-24 21:20:09.163  4071  3543 I ServerNameIndicator: SSLSocket implementation: com.google.android.gms.org.conscrypt.Java8FileDescriptorSocket
08-24 21:20:09.163  4071  3543 I ServerNameIndicator: SNI done, hostname: ***my.server.location***
08-24 21:20:18.979  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 4071 ;value= 0
08-24 21:20:18.981  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 3513 ;value= 0
08-24 21:20:18.989  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 4071 ;value= 1
08-24 21:20:18.990  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 3513 ;value= 1
08-24 21:20:27.859  4071  3543 D OfflineSyncJob: /: eTag unchanged
08-24 21:20:27.862  4071  3522 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=42d9dce1-bbec-454d-abbd-7943d396e661, tags={ timestamp:1629738398124, com.nextcloud.client.jobs.OfflineSyncWork, *, name:periodic_offline_sync } ]
08-24 21:20:27.870  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 4071 ;value= 0
08-24 21:20:27.871  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 3513 ;value= 0
08-24 21:20:27.892  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 4071 ;value= 1
08-24 21:20:27.893  1231  1613 D FastTrack: setFastTrackState: pid = 4071 ;tid= 3513 ;value= 1

I don't understand why the Nextcloud android client wants to reach out to my server each time. I do not have any offline folders setup with the client. I would expect it not to ping my server unless there was actually something to sync.

github-actions[bot] commented 2 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

mgubis commented 2 years ago

The problem still persists. It is quite a pity, that there is no feedback from devs about this issue. As a consultant, I had a request from the customer side to give report about Nextcloud deployment in their enterprise and this is what keeps them from purchasing the license with support.

My phone is on battery 25 hours now, Nextcloud drained 26,9% of battery, Background activity is 2h26m and all auto-upload folders are configured as: "Only upload when charging". I am using Always On Display and I often see Nextcloud icon showing for couple of seconds when the phone is sleeping and is off charger.

github-actions[bot] commented 2 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

J4gQBqqR commented 2 years ago

No, this not solved. Please stay away stale bot.

Without automatic sync etc. configured, Nextcloud continues to draw 20% battery per charge. Screenshot_20211020-073103_Settings_1

williamJmelton commented 2 years ago

I am also having this issue despite turning auto upload off. For what it's worth, i'm using micro G on A12 pixel 5

Popkornium18 commented 2 years ago

Currently Nextcloud is draining about 20% battery per full charge which means I can't get through a full day without charging.

TwisX commented 2 years ago

Also having this issue. No response from the developers regarding this and other issues is very frustrating. I realize it's an open-source project and that top-tier support isn't to be expected, but glaring issues like this shouldn't be ignored.

Shedhappens commented 2 years ago

I've got the same issue Nextcloud using 26% of battery! With 0 minutes active. On Samsung S9 with all latest updates and fresh installs after factory reset.

McPeterBlinckers commented 2 years ago

I have a same problem ... drain 51% Samsung Note IV Android 6.0.1 Nextcloud client (test with Play Store and F-Droid) 3.18.0

BrudiBanani commented 2 years ago

App is draining like 20-40% of battery.... Asus Zenfone 8 Android 11 Nextcloud client 3.18.0

Can i provide any information that will be helpful? Is the problem of this issue already clarified?

sid3windr commented 2 years ago

Same here, nextcloud app is eating 40-60% of my OnePlus 6T's battery since I installed the app. I migrated from Owncloud, where auto upload simply was not working. It is working on Nextcloud, but at a significant expense.

Issue open over a year without even an attempt at resolution? :(

jeffWelling commented 2 years ago

This is an open source project, and I fully understand we have no right to expect a fix.

Keeping that in mind, since this has been open for so long I've begun to wonder if this is something that the developers of the nextcloud android app feel isn't correctable without changes from android? If that's the case I hope someone can find sometime to share those details here so that we can try up-voting an android issue or two to voice our support for fixing/improving upstream.

Are more details needed to help reproduce or narrow in on the problem? Is there a bug bounty for this that I can contribute to perhaps? I'd like to help but I don't even know where to begin, and I have no android development experience yet.

frankyfranks commented 2 years ago

Same issue here. Nextcloud is draining my android phone battery. Auto upload is set to activate only when phone is on charge. I regularly see Nextcloud sync messages during the day when the phone is not charging. Phone Samsung S8 Nextcloud Android app version 3.19.0 Nextcloud server on Linux docker v 23.0.2 Can I provide any further information required to help resolve this common issue?

Everything on Nextcloud is working fine except this major issue for me. I was hoping to migrate my family from Google cloud services to Nextcloud but cannot until the battery drain issue is fixed.

tobiasKaminsky commented 2 years ago

I regularly see Nextcloud sync messages during the day when the phone is not charging.

The app syncs in background downloaded files, so that they are up to date. This is done when in wifi only.

It checks for eTag changes and thus should not be cpu/battery intensive, unless you have many big files synced, which change regularly.

frankyfranks commented 2 years ago

I regularly see Nextcloud sync messages during the day when the phone is not charging.

The app syncs in background downloaded files, so that they are up to date. This is done when in wifi only.

It checks for eTag changes and thus should not be cpu/battery intensive, unless you have many big files synced, which change regularly.

tobiasKaminsky - thanks for your response. Perhaps my expectations how Nextcloud syncs are incorrect? I was expecting Nextcloud to only sync when my phone is charging and hence reduce the battery usage to a minimum. On my Android Nextcloud app I use the following settings - In settings, auto upload, for each folder I have "only upload on unmetered WiFi" and "only upload when charging" both ticked. As recommended I disabled the battery optimization, whilst the sync does work fine I find the battery utilisation by Nextcloud to be very high. For now I've enabled the battery utilisation for Nextcloud and this has solved the battery drain issue but will no doubt stop Nextcloud from syncing in the background and I'll have to manually open Nextcloud to sync, not an ideal solution.

tobiasKaminsky commented 2 years ago

Auto upload is different from the sync/update of download files, which I mentioned.

Can you check how many files / folders you have "on device"?