mpcjanssen / simpletask-android

GNU General Public License v3.0
545 stars 124 forks source link

Options for sync (Nextcloud) #1014

Open lucker999 opened 5 years ago

lucker999 commented 5 years ago

Hello Mark,

I would like to propose a couple option to improve battery drain. Currently the app is the most consuming battery in my phone! I run it on Android 5.1 without Gapps and sync with my Nextcloud installation. It wakes my phone about 4 time per hour and BBS shows that it is responsible for 27% of battery drain. I'm not sure, but I guess it doesn't allow the phone to sleep (need more testing on this): after I install the app the sleep CPU state dropped from 92-94% to 55%.

I think that problem is with constant connection to nextcloud (the reason I don't run nextcloud app on the phone...). But we do need the sync. So, please consider to add the following options:

  1. Time to sync and time to not. I prefer to sync only on weekdays and only in work hours. I do not need to sync the tasks when I sleep or somewhere relaxing
  2. Choose the sync interval. Currently, I guess, I could live with a sync once a day (e.g. at morning), but instantly (see point 3) upload the changes I made in the phone
  3. Delay with instant upload. Sometimes it takes time to reflect all tasks one need to add/edit in the app. So, I would prefer have a "delay to sync" option, which would count from the last editina task. OR when the app closed / phone screen off.

Whit this options I could set the battery drain close to the zero in background and very light when actually using your awesome app.

Cheers!

mpcjanssen commented 5 years ago

Before implementing complicated sync scheduling schemes, i would like to understand why the battery drain is so high. Sync uses an android alarm manager, this shouldn't prevent sleep.

Do you have spotty network coverage? Whenever the phone comes online, simpletask syncs again. Maybe this is causing the drain.

aubreyz commented 5 years ago

I'm using the dropbox version. I just checked and simpletask accounts for <1% of my battery usage (I use it directly for at least an hour a day). It shows as "Battery optimisation" on.

lucker999 commented 5 years ago

Please excuse me or the delay with response. First of all I have to gather proofs: I laid the phone without use at home for the largest part of the day (see screenshots). Usually the Garmin app and bluetooth are miles ahead of the other apps by consumption.

Moreover, I have close to this results with Simpletask app even when I forbid autostart of the app in security settings (it's Meizu feature, embedded in the firmware; similar to android battery optimisation and app permission from 6.0 and 7.0)

@mpcjanssen Do you have spotty network coverage?

No, all my whinging is for the drains while the phone is connected to the stable wifi network. I have a quite similar picture with nextcloud client, that's why I do not use it on the phone.

S90825-204038 S90825-204042 S90825-204614

EDIT: inserted screenshots

aubreyz commented 5 years ago

None of the screenshot links are connected to live images. Your last paragraph suggests a nextcloud issue rather than a simpletask one? Some googling does suggests that nextcloud (and Meizu) are related to a lot of battery problems on some phones. though I have used neither.

mpcjanssen commented 5 years ago

@lucker999 : Simpletask uses the same library as the official nextcloud client, so if you have problems with the client that might explain. You could check the logging to see if something weird shows up (Settings->Other->View debug log)

lucker999 commented 5 years ago

@aubreyz None of the screenshot links are connected to live images.

corrected

@aubreyz Your last paragraph suggests a nextcloud issue rather than a simpletask one? Some googling does suggests that nextcloud (and Meizu) are related to a lot of battery problems on some phones. though I have used neither.

For all I know, there are some cases in which android nextcloud app works flawlessly, and some in which it drain battery. Last time I checked the nextcloud forum regarding the issue (about 3-4 months ago) developers answered that they can do nothing about it and suggested to accept that it could or couldn't work correctly.

I know about this attitude toward the nextcloud app, but I started the thread with hope, that in this case the user wouldn't be discriminated by the phone they have. Sure, there are plenty other brands and models except Meizu which behave differently than pure android. And that is the reason I suggested to implement the schedule for sync. There is no other open source task app, that support MYN and sync across devices, but the current issue make it unusable. I would very appreciate (and sure many other people) to be able use the app without charging my phone like iPhone.

@mpcjanssen check the logging to see if something weird shows up

This is in the log:

--------- beginning of main W/linker ( 4462): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6ffffffe arg 0x808 W/linker ( 4462): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6fffffff arg 0x2 W/linker ( 8377): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6ffffffe arg 0x808 W/linker ( 8377): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6fffffff arg 0x2 W/linker (30986): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6ffffffe arg 0x808 W/linker (30986): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6fffffff arg 0x2 W/linker (16957): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6ffffffe arg 0x808 W/linker (16957): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6fffffff arg 0x2 W/linker (18676): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6ffffffe arg 0x808 W/linker (18676): /system/lib64/libfilterUtils.so: unused DT entry: type 0x6fffffff arg 0x2

smichel17 commented 5 years ago

The high battery usage is probably because Simpletask uses RTC_WAKEUP and ELAPSED_REALTIME_WAKEUP instead of RTC and ELAPSED_REALTIME alarm types, here:

https://github.com/mpcjanssen/simpletask-android/blob/19d9804d9766d3d0c691ec1d88b4a9477bf5568c/app/src/main/java/nl/mpcjanssen/simpletask/TodoApplication.kt#L139

https://github.com/mpcjanssen/simpletask-android/blob/19d9804d9766d3d0c691ec1d88b4a9477bf5568c/app/src/main/java/nl/mpcjanssen/simpletask/TodoApplication.kt#L152

More likely the second one, since the first is only firing once per day.


I'm not sure why it would only be an issue on Nextcloud, though.

mpcjanssen commented 5 years ago

@lucker999 the 4 wake ups per hour are expected (the battery drain isn't). I will make a test build without background sync to see if this changes the battery drain and confirm that that is the issue instead of the actual sync draining. Simpletask always checks the remote file when it's activated so it should not make much of a difference.

mpcjanssen commented 5 years ago

@lucker999 can you try with: https://www.mpcjanssen.nl/artifacts/app-nextcloud-release-no-bg-sync.apk

lucker999 commented 5 years ago

@mpcjanssen thanks for the link. As expected, for more than 6 hours no trace of the app in battery stats as well as in BBS. The sync performed very fast when I launch the app. No delay whatsoever (frankly this somehow surprised me)