bitwarden / android

Bitwarden mobile app for Android.
https://bitwarden.com
GNU General Public License v3.0
6.17k stars 786 forks source link

High battery consumption caused by Autofill Service #51

Closed jerryn70 closed 7 years ago

jerryn70 commented 7 years ago

Need some tweaks to reduce battery consumption.

kspearrin commented 7 years ago

Can you provide some information as to why you believe bitwarden is abnormally consuming your battery? We have not yet had this report. Is it tied to use of the autofill service?

jerryn70 commented 7 years ago

Without opening or using bitwarden the battery consumption is increasing in time to time.

jerryn70 commented 7 years ago

Well here is the battery consumption comparison between other password managers & bitwarden . ●Lastpass ●Dashlane ●PassKeep2Android ●Bitwarden

After boot (battery between 90% - 99%) -Lastpass used : 1.3% -Dashlane : 2.1% -keepass2android : 0.3 -bitwarden : 5.2%

Battery between (5% -15%)

-lastpass : 7.3% -dashlane : 9% -Keepass2android : 5.2% -Bitwarden : 16.2%

.I think bitwarden is always connected to net server and while others connect only when their is new entry or edit. Next day After the phn boot i kept the phn ideal for 1 hr without opening bitwarden and checked the battery consumption of apps, bitwarden scores the top consumption of 3.2%. You need to do something about this.

My phone: moto x play Stock marshmallow 6.0.1 Non rooted

kspearrin commented 7 years ago

I suspect some of this has to do with the autofill service running. Can you try your tests with autofill turned off?

jerryn70 commented 7 years ago

When i turned off auto fill, battery consumption is reduced .

kspearrin commented 7 years ago

Ok, that makes a little more sense. Do you have the autofill services turned on in the other apps you are comparing bitwarden to?

jerryn70 commented 7 years ago

Yes auto fill is turned ON in other apps when i compared. The other thing that i noticed is, all other apps optimize battery (reduce consumption) itself when phn is in ideal or they didn't find any auto fill columns for a while. But bitwarden is increasing its battery consumption time to time.

jerryn70 commented 7 years ago

picsart_04-22-10 29 01 picsart_04-22-10 29 52

@kspearrin see the difference . Auto fill is enabled on both .

jerryn70 commented 7 years ago

screenshot_20170428-203053 screenshot_20170428-203030 screenshot_20170428-203017 Only bitwarden has push notifications process, maybe this causing high battery consumption

kspearrin commented 7 years ago

Possibly. Can you try stopping it to see if it helps for you?

jerryn70 commented 7 years ago

I have tried but no use still consumption is increasing

kspearrin commented 7 years ago

Yes, it is most likely the autofill service then. There are two things that are weird here:

  1. You are the only person who has ever reported that this is causing battery issues for them.
  2. Our implementation is basically exactly the same as Keepass2Android, yet you are saying theirs is not causing any problems for you.

Will have to continue to investigate.

jerryn70 commented 7 years ago

See the difference between bitwarden n keepass2android screenshot_20170428-220458

jerryn70 commented 7 years ago

There is no battery drain if i disable auto fill accessibility

punassuming commented 7 years ago

I have noticed this as well, on both rooted and unrooted devices.

punassuming commented 7 years ago

When rooted, I was tracking bitwarden at around 5% drain.

jerryn70 commented 7 years ago

Yes I'm the only person reported battery consumption issue, maybe others are not concerned about battery life or maybe they didn't notice the consumption rate. The thing i noticed is bitwarden's cpu usage (battery consumption) is increasing in every minute. While keepass2android cpu usage (battery consumption) increase only when we browse sites or use apps .
I think bitwarden looks for password box ever time even if the phn is in ideal , at the same time keepass2android looks for password box only if we open apps or sites .

These are my assumptions. I'm not a dev or tech .

But still im wondering how lastpass manages to make very low battery consumption. I think the use extra script for accessibility auto fill service.

I Hope you will fix the battery issue in the next release.

kspearrin commented 7 years ago

@jerryn70 does it still drain the battery even if the phone is asleep?

jerryn70 commented 7 years ago

Yes, but at that time consumption is slower .

While phones screen is ON and not using any apps or anything it consumes 1% in every 1 minute.

While browsing sites or using any apps 1% to 5% consumption in every 1 minute

While sleep 1% consumption in every 2 minutes ....

kspearrin commented 7 years ago

@jerryn70 I have pushed a new build (550) to the beta channel on Google Play store. Can you try it out and see if any improvements?

jerryn70 commented 7 years ago

@kspearrin i have tried but there is no difference. Still same as the current stable version

walrus543 commented 7 years ago

@jerryn70 I have the same issue on my device: screenshot_20170502-110327

jerryn70 commented 7 years ago

@kspearrin @Primokorn all my test shows bitwarden uses doubles the battery of keepass2android . If kP2A uses 10% bitwarden will be 20% or above. And we cannot compare bitwarden's consumption with lastpass because last pass is very good in battery saving. You can see comparison between lastpass on my previous post. Here is the result of latest bitwarden with KP2A screenshot_20170504-172116 01

kspearrin commented 7 years ago

Thinking about this more, real optimizations will only come if we reduce the number of times the service scans the screen looking for password fields. Currently this happens every time the app detects that there is a change to the screen (a lot!).

What if we changed it so that the notification was always present and when the user taps the notification, only then do we scan the screen to collect username/password field data? That way screen scanning is on demand instead of happening all the time.

The downside to this is of course that the app will no longer be as intelligent about offering the notification only when it can actually help.

punassuming commented 7 years ago

I think in a way this might be how LastPass works sometimes. There are always cases where I have to click the notification in order for it to determine what the auto fill.

Is there a way to get it to scan the window periodically or in the first 5 seconds and then stop?

Is there a way when not rooted to disable individual services an app uses?

punassuming commented 7 years ago

Can we scan only when keyboard is opened? That would be a good time to guess that we are inputting login info.

kspearrin commented 7 years ago

@ralesi Only scanning with keyboard open is a possibility. We could make it a setting?

jerryn70 commented 7 years ago

@kspearrin 'Scan only when keyboard is open' is a good idea. Or we can use lastpass type auto-fill "scan only when we click on username/password box" . I think that's why lastpass has very low battery consumption.

ep2017 commented 7 years ago

I've also noticed this.

I'd be fine with having to click on either a Quick Tile or Bitwarden in the notification shade for it to scan the page/app for a login form.

In LastPass, I often have to click on the password field for it to trigger the popup telling me that I have an option to auto-fill. It's convenient, but I would imagine this still taxes the battery on some level.

My preference would be to have to manually click on a button to get the auto-fill option - saving the greatest amount of battery life.

jerryn70 commented 7 years ago

@kspearrin As you said the service scans the screen looking for password fields everytime when the app detects screen changes. My question is this, is the screen scanning rate is same as keepass2android or higher.?

If it is higher, then we can reduce it to the level of KP2A , because KP2A didn't failed to show autofill notification in all my test. Reducing scanning rate may reduce battery usage .

kspearrin commented 7 years ago

@jerryn70

As far as I know, our implementation is identical to KP2A.

I will release a beta sometime soon with some changes that you can test for me.

jerryn70 commented 7 years ago

@kspearrin just tag me when new beta is available. I will test n report back.

kspearrin commented 7 years ago

@jerryn70 Will do. I plan to start working on it soon. Thanks for the testing thus far.

kspearrin commented 7 years ago

@jerryn70 Can you send me an email at https://bitwarden.com/contact so that I can send you some custom builds to try?

kspearrin commented 7 years ago

@jerryn70 and others:

Here is a custom build that tests the strategy we discussed above about always showing the notification and only scanning for password fields whenever the autofill is attempted.

https://ci.appveyor.com/api/buildjobs/4gby8sxkvhjh5b10/artifacts/com.x8bit.bitwarden-767.apk

Please let me know if it helps at all.

jerryn70 commented 7 years ago

@kspearrin The ways we discussed

1, Always show notification :- scan for password fields when we click on the notification.

2, Scan only when keyboard is opened.

3, Scan when we click on password field (like laspass)

So the 1st method is created . And iam testing it. Do you have plan for method 2 and 3 ?

kspearrin commented 7 years ago

No plans for 2 or 3 yet. I first need to understand if scanning for passwords like we are going in the live app is actually what is causing battery issues. The test build should confirm that for us.

ep2017 commented 7 years ago

I've been testing the new build since last night and there's a huge difference now - basically zero battery life with general use. The feature works exactly as expected.

I did have to set the notification (through Android) to "Low Priority) to get rid of the persistent icon and drop it lower on lists of notifications showing on the notification shade. But those are personal preferences.

kspearrin commented 7 years ago

@ep2017 I may be able to adjust that priority programmatically. What does the priority do to the notification (I'm not an Android user)?

ep2017 commented 7 years ago

@kspearrin "Never make sound or vibrate. never peek and LED. Hide from lock screen and status bar. Notifications will be shown at the bottom of the notification center."

That's the official tool tip. Private Internet Access VPN operates in "low priority" mode and it helps to unclutter things!

jerryn70 commented 7 years ago

@kspearrin Success 😀😀 screenshot_20170527-215359 01 screenshot_20170527-215411 01

kspearrin commented 7 years ago

Great! Any issues using the autofill that you have found?

jerryn70 commented 7 years ago

@kspearrin I mainly concentrated on the battery consumption ,and i didn't noticed any issues . Well I will investigate more in coming days.

Can you please remove the app icon from the notification bar.? See screenshot 2017-05-27-22-40-51

ep2017 commented 7 years ago

@jerryn70 You can remove the icon now by setting Bitwarden to low priority for notifications as I described above (at least until this is an option to do it in the app).

jerryn70 commented 7 years ago

@ep2017 i don't know how to do that. this is the default settings in my phone. In on stock marshmallow. Can you plz guide me . screenshot_20170528-094126

ep2017 commented 7 years ago

@jerryn70 Ah,looks like Nougat makes it easier. screenshot_20170528-002009

jerryn70 commented 7 years ago

@ep2017 But users below android 7 has no way to get rid of it.

jerryn70 commented 7 years ago

@kspearrin Till now there is no issues on the test version. When I tap on the notification it will correctly shows the matching result. The only problem I noticed is bitwarden icon on the notification bar. Check my above post for its screenshot.

ep2017 commented 7 years ago

@jerryn70 I'm sure the feature will be added in-app. I'm using that method because it's a temporary option in Nougat. I also don't like persistent icons for most things.

walrus543 commented 7 years ago

I think this issue shouldn't be closed.

This fix isn't perfect: • it adds a persistent notification (one more line in the notification panel and I already have my firewall, VPN and Privacy Guard) • seeing the notification was a way to see if a browser is supported. No notification in Firefox => bitwarden won't work.

3, Scan when we click on password field (like laspass) This is the best solution that you should try to implement IMO.