AdguardTeam / AdguardForiOS

The most advanced ad blocker for iOS
https://adguard.com/
GNU General Public License v3.0
1.43k stars 202 forks source link

Severe battery drain while idle #1899

Open ViRb3 opened 2 years ago

ViRb3 commented 2 years ago

Issue Details

This is likely the same issue as #1831. I don't know when it started, but my battery has been, for the past months, draining at least 30% overnight while the phone is idle/stand by. I disabled all apps' "Background data refresh", and the phone is always on strong signal Wi-Fi. I looked at the DNS logs first thing this morning and noticed that the same few reverse IP lookups are performed literally every 30 seconds, non-stop, forever. The IPs in question are all private IPs that do not exist on my Wi-Fi network.

Do you have any idea what could be causing this?

Thanks

Screenshot

Details

VGisHere commented 2 years ago

I can confirm same issue at my end. Before going to sleep, I see battery percentage roughly at around 30-35% On waking up nearly 6-7 hours later, I see battery percentage plunged to 10-15% and then I go on to check battery stats, I see AdGuard Pro with some background activity continuously during entire night.

Also, I’m using VPN method to block custom ads on yahoo, particularly, m.yap.yahoo.com. I’m not sure if this VPN method is behind the battery drain. @ameshkov

ViRb3 commented 2 years ago

I turned off AdGuard before going to bed last night, and my battery drain was cut in half, around 15% per 8 hours now, instead of 30%. I still don't think this is normal, and I suspect that the constant DNS queries are still happening, they just drain less battery when not going through the overhead of AdGuard. Does anybody have a clue what is causing these queries?

VGisHere commented 2 years ago

Apple continuously performs some DNS queries, if you turn on VPN mode without any surfing, in no time, you would be able to see a lot of DNS queries to/from Apple, which IMO, can’t be turned off unless you turn off mobile data and WiFi. The main issue would probably be that why AdGuard consumes so much battery ! I’ll try out Native mode and see if there is any improvement in terms of battery consumption.

ViRb3 commented 2 years ago

The DNS queries in my case are all private (local) IPs though, they have nothing to do with Apple. I did see some Apple queries, but they were happening MUCH less often.

VGisHere commented 2 years ago

My observation is that the Native approach does less battery drain than the VPN approach. And the only reason I'm using VPN approach is to block "m.yap.yahoo.com" ! I wonder which all sites break if they add this to their blocking list.

ameshkov commented 2 years ago

I looked at the DNS logs first thing this morning and noticed that the same few reverse IP lookups are performed literally every 30 seconds, non-stop, forever

This is actually a known issue, but it's not with the AdGuard app. We've seen it on AdGuard DNS and AdGuard Home before.

Sometimes bonjour service goes mad and starts doing these reverse lookups all the time. The only reliable way to make it stop is to reboot the device.

ViRb3 commented 2 years ago

Thanks a lot for your reply. I tried restarting my phone multiple times and I even wiped it, but the issue never stopped. But wow, this would explain why I was never able to solve it - all of my home is covered by AdGuard Home! I suspect you are blocking some domain in the adblock list that triggers this bug...

ViRb3 commented 2 years ago

For what is worth, I also have iMazing set up on my Mac to backup my device over WiFi every day, so that's probably keeping a constant bonjour connection too.

ameshkov commented 2 years ago

@ViRb3 hm, how long did it start to occur? The latest version of AGH does indeed breaks DNS service discovery so it might be the issue: https://github.com/AdguardTeam/AdGuardHome/issues/4120

On the other hand, it shouldn't matter much. I've seen pretty similar reports with other DNS software, even without any filtering whatsoever.

ViRb3 commented 2 years ago

It's been happening for a few months unfortunately, at least since 11/2021. I don't think it's that specific issue in AGH. I will try to do a lot more experiments over the next few days, and I'll include disabling AGH too.

NeutralGround commented 2 years ago

@ViRb3 Try changing blocked response TTL under low-level settings to a higher value, eg. 3600, seems to work for me. I have been searching around for a fix and this is my current solution. Something to do with bonjour discovery service, especially for custom DNS users.

ameshkov commented 2 years ago

Interesting, please let me know if this helps.

Tratosca commented 2 years ago

I'm actually facing high battery drains when device is idle on iOS 15.5 using the full tunnel mode for DNS blocking. Using a high TTL (7200s) didn't solve the issue. I'm using DNS over HTTPS with Cloudflare servers. iOS is constantly phoning home with ~800 requests to Apple names in only an hour !

NeutralGround commented 2 years ago

I'm actually facing high battery drains when device is idle on iOS 15.5 using the full tunnel mode for DNS blocking. Using a high TTL (7200s) didn't solve the issue. I'm using DNS over HTTPS with Cloudflare servers. iOS is constantly phoning home with ~800 requests to Apple names in only an hour !

How high? Need more details. For me, in the last 10 days it is 3%. Also, what is your blocking mode config? It is better to return 0.0.0.0 than REFUSED or NXDOMAIN as some apps may try to query further if latter.

Tratosca commented 2 years ago

I'm actually facing high battery drains when device is idle on iOS 15.5 using the full tunnel mode for DNS blocking. Using a high TTL (7200s) didn't solve the issue. I'm using DNS over HTTPS with Cloudflare servers. iOS is constantly phoning home with ~800 requests to Apple names in only an hour !

How high? Need more details. For me, in the last 10 days it is 3%. Also, what is your blocking mode config? It is better to return 0.0.0.0 than REFUSED or NXDOMAIN as some apps may try to query further if latter.

As I recently switched again to AdGuard VPN implementation after having used iOS system wide DNS profile I'm waiting for iOS to correctly report battery consumption after a few days but for now it seems to be around ~12%. I'm using the default mode (which return a 0.0.0.0 IP) and my 2 blocklists are also using 0.0.0.0 as returned IP for blocked hosts.

NeutralGround commented 2 years ago

How large are your blocklists?

Tratosca commented 2 years ago

How large are your blocklists?

I'm using BlackJack8´s "regular hosts.txt" rule with 14342 rules and a custom one with 184 rules.

NeutralGround commented 2 years ago

Could you share what are your most active domains/companies under activity page? Do switch to “all time”.

Also, how much battery drain do you experience after a night of shut eye?

Tratosca commented 2 years ago

Could you share what are your most active domains/companies under activity page? Do switch to “all time”.

Also, how much battery drain do you experience after a night of shut eye?

It's by far Apple with ~12300 requests in two days ! Akamai is the second with ~4500 requests. Most of the requests aren't blocked but only SSLized using Cloudflare DNS over HTTPS servers. This night was good actually even if some requests were made: the app is showing in the battery usage screen this way image

But I was in power saving mode. Will try next night in normal mode and keep you informed. Thanks for your help.