AdguardTeam / AdguardForAndroid

Open bug tracker for Android version of AdGuard.
https://adguard.com/
1.37k stars 91 forks source link

Battery Drain #4960

Closed loca-lhost closed 8 months ago

loca-lhost commented 1 year ago

Please answer the following questions for yourself before submitting an issue.

AdGuard version

4.2.71

Environment

- OS:Android 13
- Device:Note 11 Pro 5G 
- Firmware:MIUI 14

Root access

What filters do you have enabled?

No response

What Stealth Mode options do you have enabled?

No response

Issue Details

I have observed over some period a huge battery drain. It can take upto 50% of my SOT for a period of 24 hrs if I use auto proxy mode. Currently it sits at 28%. Version 3 never crossed the 5% threshold for same period. Inside the apps statistics it's even worse as it spikes randomly especially if you manually check for update.

Expected Behavior

It shouldn't be draining battery. And the statistics is way off.

Actual Behavior

Battery statistics ib the app and android battery estimates are just beyond normal. Huge battery drain.

Screenshots

Screenshot_2023-09-06-02-37-23-677_com miui securitycenter Screenshot_2023-09-06-02-37-44-262_com adguard android

Additional Information

No response

androidacy-user commented 1 year ago

If an app is requesting a lot of ads, it will drain battery that android will attribute to Adguard. Make sure you don't have an app, like YouTube constantly requesting ads or something.

AlgorithmOfGithub commented 1 year ago

If an app is requesting a lot of ads, it will drain battery that android will attribute to Adguard. Make sure you don't have an app, like YouTube constantly requesting ads or something.

Same problem here, on versions 3.#.# not that much battery drain but i check issues sometimes none talk about it, i didnt open issue about it.

loca-lhost commented 1 year ago

Same usage but the drain wasn't noticeable. Even earlier version 4 was better amid the constant restarts

maxikuzmin commented 1 year ago

@AlgorithmOfGithub @loca-lhost could you be more specific about what apps you usually use? Does this happen if the phone is in sleep mode?

Rtizer-9 commented 1 year ago

@loca-lhost there are some issues with automatic proxy as of now in the latest nightly versions which results in connection getting lost and some apps gets stuck while doing some operations like whatsapp backup which triggers at 2AM, truecaller/whatsapp contact sync.

I would suggest to install Better battery stats (root)- either stable or the xda edition (free) and observe the apps which are holding partial wakelocks and firing more than expected alarms in their respective tabs. I have observed whenever this battery drain happens in automatic proxy it's either some app with numerous entries with some "job sync" wakelock or "overflow" wakelock.

This way you will have a much better idea of which app is actually causing the drain.

It's also entirely possible that some other app is responsible for this. And since you're already on root I would suggest forcing deepsleep using some app and also monitoring whether deepsleep is working or not.

maxikuzmin commented 1 year ago

@loca-lhost @AlgorithmOfGithub can you also export your settings and send them to devteam@adguard.com? Please include issue number 4960 in your email It would be good to understand what your settings are and observe the power consumption with your settings

maxikuzmin commented 1 year ago

@AlgorithmOfGithub @loca-lhost any news? Can you also clarify, is this problem recurring with VPN mode?

AlgorithmOfGithub commented 1 year ago

@maxikuzmin Hi, sorry for late answer. Let me answer fastly your questions. Note: all i test on new and old phones (huawei phones with custom rom and apps) 1-before adguard issue It kept draining the battery. so I researched the issues like; huawei android launcher, huawei system services, system interface. sometimes problem updates but when i check adguard statistics there is so much requests(like clear statistics after that 6-10k requests in 15-30 minutes). most of the requests came from DNS filter but i didnt find which app doing that. so i tried off 'Route traffic through Adguard' of app(huawei android launcher). Battery usage of the app started to decrease. also, if you try it on a slightly old and slow phone unroute the app you will see that the app runs smoother and faster. so question is most applications including system applications are route through to AdGuard maybe conflict eachother cause you cant optimized all apps around the world. I dont know actually. (i have not using constintly requesting app like youtube) 2-tried with custom adguard settings 3-issue on vpn mode and no root for me 4-how i can test i dont know but same phone just updated 3.#.# to 4.#.#. Battery usage increased. i didnt see on adguard statistics but phone battery statistics showed me it. (if i cant explain pls write, sorry for bad english)

loca-lhost commented 1 year ago

It quit stable in vpn and it hovers around 20 percent now. In auto proxy it goes beyond 30 percent

maxikuzmin commented 1 year ago

@loca-lhost do you have a Huawei too?

loca-lhost commented 1 year ago

Xiaomi

maxikuzmin commented 1 year ago

@loca-lhost @AlgorithmOfGithub @Rtizer-9 does this repeat with Local VPN mode?

Rtizer-9 commented 1 year ago

@maxikuzmin as far as I can recall, I think it does. At the moment I'm not using VPN mode because obviously why not "root proxy" when you have it and also vpn mode shuts down automatically a lot overnight.

AlgorithmOfGithub commented 1 year ago

@maxikuzmin , for me work on local vpn, the issue persist with last nightly and beta versions, i dont know how it works but maybe the issue is not about mode. I read that rewriting every line of code on 'total reengineering' that you wrote about version 4.0. What did change ?

Rtizer-9 commented 1 year ago

I think that this is somehow related to that doh using that stale connection for too long bug. It's not exactly ag perhaps that drains the battery but the apps that get stuck like I mentioned above. I can see lots and lots of entries with "job" and Android wakeup alarms with the most being "job.deadline" intent.

maxikuzmin commented 1 year ago

@Rtizer-9 @loca-lhost @AlgorithmOfGithub in 3 days of using AdGuard I haven't seen this problem. But I tested on Pixel 5 with Android 14, maybe the problem is in the system. Could you please send your logs? I hope you have Debug mode enabled :) Mail for sending logs is the same devteam@adguard.com don't forget to specify issue number 4960 Let's see if we can figure out the problem

Rtizer-9 commented 1 year ago

I'm using this whole setup with Wireguard kernel mode so I'm not really sure what's exactly causing the problem and if it would be of any use to you.

To solve the problem I'm using persistent keep alive in both ag and Wireguard (I thought this would stop frequent disconnection and keep the connection alive) and I'm not seeing any battery drain since many days.

PS: I'm on Android 13 not 14.

maxikuzmin commented 1 year ago

@loca-lhost @AlgorithmOfGithub do you still continue to have severe battery drain? @AlgorithmOfGithub have you now disabled Huawei Android filtering? Has the battery consumption become less?

loca-lhost commented 1 year ago

On automatic proxy it still drains. Vpn mode is tolerable

AlgorithmOfGithub commented 1 year ago

@maxikuzmin, 1-on my side, when I disable the redirect some Huawei applications on Adguard, battery consumption decreases.(vpn mode) 2-I have to use an old Huawei phone for a certain time, and the information I will transfer will not be healthy. cause battery not good. Note: information that i transferred before for new huawei phone (huawei nova 10 pro (android))

maxikuzmin commented 1 year ago

@AlgorithmOfGithub @loca-lhost @Rtizer-9 I've been watching my device for a long time, but the problem has never recurred. It may depend on the configuration, or some apps that may not have internet access, and other factors. Could you please observe Recent activity? Maybe some apps are making a lot of requests and consuming power

Rtizer-9 commented 1 year ago

I'm also not having any issues for the past few weeks.

maxikuzmin commented 1 year ago

@AlgorithmOfGithub @loca-lhost any news?

loca-lhost commented 1 year ago

It's better now. Been a while since I used http proxy. Using vpn mode now.

AlgorithmOfGithub commented 1 year ago

@maxikuzmin

Hi, i removed some apps from phone like huawei ai which working back that i dont need, battery usage down but adguard app usage didnt change. Maybe problem about my settings or usage of phone cause none talk about it until know so no any news

maxikuzmin commented 1 year ago

@AlgorithmOfGithub @loca-lhost

It may depend on the configuration, or some apps that may not have internet access, and other factors. Could you please observe Recent activity? Maybe some apps are making a lot of requests and consuming power

what about it?

AlgorithmOfGithub commented 1 year ago

@AlgorithmOfGithub @loca-lhost

It may depend on the configuration, or some apps that may not have internet access, and other factors. Could you please observe Recent activity? Maybe some apps are making a lot of requests and consuming power

what about it?

There is so much "maybe" what you think, like i said still so much using battery with default config on it even new huawei phone.

maxikuzmin commented 1 year ago

@AlgorithmOfGithub this is one theory why there may be increased battery consumption. If we can determine if there are apps with more requests, we can figure out how to solve the problem. Otherwise, it's pretty hard for us to figure out the problem without understanding the causes and steps to reproduce. Unfortunately, this problem is not recurring on our end. It is likely that the problem could be in the "system" apps from the device manufacturer that are installed by default

AlgorithmOfGithub commented 1 year ago

@maxikuzmin, if there is a problem, probably other users will notice this too with updates. Thanks for handle, i will send the data from a more stable phone.

maxikuzmin commented 1 year ago

@AlgorithmOfGithub how are your observations? Are you seeing a large amount of requests from any applications?

AlgorithmOfGithub commented 1 year ago

@maxikuzmin hi, I dont see any extra requests from any application. However it seems like it is receiving extra requests and consumes battery on the phones I use. As I said, I will send you the information when I get a new and stable phone.

maxikuzmin commented 12 months ago

@AlgorithmOfGithub I continue to monitor power consumption on several devices, so far no anomalies unfortunately. I hope to get logs from issue users via AdGuard VPN to understand the issue in more detail. Please, if you have this happen again, upload the logs too

Rtizer-9 commented 12 months ago

@maxikuzmin I'm using Adguard with another proxy app and was facing ag crashes after screen off. I turned on ag watchdog and set it to highest=300s which resulted in "check alive" alarm from ag which triggers a lot and probably forces the system to come out of sleep, which results in ~1%/hr battery drain overnight.

When I again disabled watchdog, drain is back to ~2% overnight.

From my experience I've seen these kinds of battery drain with ag :

  1. You're using an app and somehow a connectivity issue happens (maybe due to a nightly issue) and then the app keeps trying but this whole cycle keeps going on which can be seen as "overflow" partial wakelock as I've mentioned earlier in this thread.

  2. Watchdog turned on

In the above cases your phone's natural idle drain too comes into place which you might also be counting and attributing completely to ag.

  1. Again a natural idle drain (happens when the phone has issues with deep sleep) with no interference from ag whatsoever but the user completely attributing it to ag.
AlgorithmOfGithub commented 12 months ago

@maxikuzmin I wanted to write when I experienced difficulties in daily use and saw a similar status information. Thanks for your interest despite the lack of information.

maxikuzmin commented 11 months ago

@AlgorithmOfGithub @Rtizer-9 we've received enough logs from AdGuard VPN. We are investigating this issue, thanks!

maxikuzmin commented 11 months ago

@AlgorithmOfGithub @Rtizer-9 we found what the problem is. It will be fixed in an upcoming update. Thank you very much for your information! At the moment, the problem is AdGuard VPN

maxikuzmin commented 11 months ago

@AlgorithmOfGithub @Rtizer-9 please test this in AdGuard VPN 2.7 Beta 1 released today or wait for the release version tomorrow, please let us know the results

Rtizer-9 commented 11 months ago

Umm...I never talked anything about ag vpn. Isn't this issue about ag Android?

maxikuzmin commented 11 months ago

@Rtizer-9 we had a power consumption issue due to the penultimate version of AdGuard VPN having too frequent integration mode checks. We fixed that and it should have fixed the power consumption issue. Are you not using AdGuard VPN? Battery drain only when using AdGuard?

maxikuzmin commented 11 months ago

@Rtizer-9 many people have already been helped by this solution with AdGuard VPN 2.7

AlgorithmOfGithub commented 11 months ago

@maxikuzmin hi, for me yes, issue for using adguard but probably my problem about my phone, just want to say it

maxikuzmin commented 11 months ago

@AlgorithmOfGithub @Rtizer-9 is this still happening when using the latest versions of AdGuard 4.3.1 and AdGuard VPN 2.7?

AlgorithmOfGithub commented 11 months ago

@maxikuzmin hi, i dont use adguard vpn, yes still drain battery but problem is my phone so thanks for still attention.

Rtizer-9 commented 11 months ago

@maxikuzmin yes I only faced battery issue with main ag app (I don't use VPN app) and as I've mentioned earlier it's been days since I faced battery drain specifically due to ag.

rak-rak commented 11 months ago

@AlgorithmOfGithub @Rtizer-9 is this still happening when using the latest versions of AdGuard 4.3.1 and AdGuard VPN 2.7?

Issue is happening for me on two devices Samsung S22+ / Tab S9 (Android 14 stock) with Adguard 4.3.1 and Adguard VPN 2.7.8.

Adguard VPN is disabled, but there is high battery consumption.

AlgorithmOfGithub commented 11 months ago

As I said before, if there is, this problem will occurs for more users with new updates, except for me. i hope not problem.

maxikuzmin commented 10 months ago

@AlgorithmOfGithub @rak-rak @Rtizer-9 we're looking into it, we're gonna need some time

enakr commented 10 months ago

CRM #858809 - logs sent to devteam@adguard.com