rethink-app icon indicating copy to clipboard operation
rethink-app copied to clipboard

Battery life on Android 12

Open michaelblyons opened this issue 4 years ago • 10 comments

Rethink is routinely 25%+ of my battery usage across all apps since upgrading to Android 12. Right now it's actually 37% since last charge.

If there's something I should be doing, please advise. 😃

michaelblyons avatar Nov 02 '21 13:11 michaelblyons

Hi there 👋

We haven't done battery profiling at all. #9

It is plausible that the app is worse on Android 12. We do not have any Android 12 devices with us. Will profile once we get them (it is long overdue anyway).

One thing you could check is: Could it be also that some other app you use is doing more network on A12 / after a recent update? Since that increases RethinkDNS' battery consumption too as it has to analyse that many more connections and network packets.

I use Android 11 and haven't seen 25%+ drain unless I also use Firefox (that is to read/browse on my Android) regardless of the Android / Firefox / RethinkDNS version.

ignoramous avatar Nov 04 '21 12:11 ignoramous

It is plausible that the app is worse on Android 12. We do not have any Android 12 devices with us. Will profile once we get them (it is long overdue anyway).

Understood. And worth noting: I did not have this problem on Android 11. I don't remember stats, but I believe Rethink was down in single-digit percents.

One thing you could check is: Could it be also that some other app you use is doing more network on A12 / after a recent update? Since that increases RethinkDNS' battery consumption too as it has to analyse that many more connections and network packets.

Maybe. Looking at the network log, there are lots of calls to ye olde 1.1.1.1, 8.8.4.4, etc. from "ANDROID," many with the white label at the left that I think may mean whitelisted...?

unless I also use Firefox (that is to read/browse on my Android) regardless of the Android / Firefox / RethinkDNS version.

I also use Firefox, and perhaps 1-2 hours a day, 😅 but Firefox is explicitly whitelisted in Rethink. I use the more granular permissions of uBlock Origin when I'm in Firefox.

I'm happy to answer any other questions.

michaelblyons avatar Nov 04 '21 15:11 michaelblyons

I did not have this problem on Android 11. I don't remember stats, but I believe Rethink was down in single-digit percents.

We only have Android 11s to test on, and the drain we see is single digits too, though it does get into high 20s depending on other apps in-use during that time. Not sure if Android 12 itself may be a cause of worry here, and so, I'll keep this bug open until such a time we are able to profile the app's energy use.

Maybe. Looking at the network log, there are lots of calls to ye olde 1.1.1.1, 8.8.4.4, etc. from "ANDROID," many with the white label at the left that I think may mean whitelisted...?

Tap on the entry. Likely these requests are being proxied. Some app do plain DNS over TCP to bypass content-blocking clients like pDNSf and Blokada which do not handle DNS over TCP (rethinkdns, netguard, trackercontrol, intra do handle these). Some client do plain DNS over UDP which is proxied by rethinkdns too.

To see the domains that were proxied, you'd have to navigate to DNS Logs and find which DNS queries sent at the exact same time these requests were proxied. Likely those DNS queries were blocked, and hence a flurry of requests to 8.8.8.8 / 1.1.1.1 endpoints from those confused apps that thought they bypassed content-blocking. In my experience, such desperation to connect is endemic to apps that embed InMobi and Gamooga SDKs (though, likely there could be more spyware SDKs that have now resorted to DNS over TCP and do not expect to be blocked).

That said, these flurries may or may not be related to battery drain you're seeing :D To allow apps to do their own DNS, disable Prevent DNS leaks from RethinkDNS Settings.

I'm happy to answer any other questions.

If you're comfortable answering them (in public):

  • Stock ROM or a custom ROM?
  • If custom, which ROM?
  • What's the make / model of your Android?
  • Do you notice difference in other apps and their energy / background use?
  • Have you been playing too many video games on your Android, of late? ;)

(or, over email: mz at cel zero dot com)

Firefox is explicitly whitelisted in Rethink

Excluding an app would exempt it from RethinkDNS' tunnel (whitelisting only exempts it from Firewall rules but not DNS rules) and exempt it from causing RethinkDNS to use more network resources on its behalf (since it no longer "reads" any of the excluded app's packets / connections).

ignoramous avatar Nov 04 '21 16:11 ignoramous

  • I have stock Android 12 on Pixel 3a.
  • I haven't specifically noticed a difference in other apps. Mostly what I noticed was a difference between the 2.5+ day charge on Android 11 and the ~26 hour charge on A12.
  • I do not typically play video games, though I did fire up Among Us for 40 minutes maybe 10 days ago.
  • My usage is generally
    • reading 1-2 emails
    • 5-15 XMPP/SMS messages
    • podcast during morning routine
    • 1-2 hr internet via Firefox morning and evening
    • Every few days watch a video or check the moon phase

Last 24 hr battery usage reported:

  • RethinkDNS: 36% (Total: 23 hr 36 min)
  • Firefox: 17% (Total: 1 hr 18 min, BG: 1 min)
  • AntennaPod: 5% (Total 45 min, BG: 9 min)
  • K-9 Mail: 2% (Total 23 hr 36 min)

System:

  • Screen: 11% (Total: 1 hr 53 min)
  • Phone Idle: 9% (Total: 23/36)
  • Android OS: 5%
  • WiFi: 5%

The early morning flurry seems indeed be linked to some blocked DNS lookups. If they manage to get port 53 as whitelisted system ANDROID, does that mean it works? Or not?

Since then there have been a bunch of gvt1.com DNS lookups, which the internet assures me are normal; and many play services requests. I believe Play Store has done some updating.

michaelblyons avatar Nov 04 '21 16:11 michaelblyons

Thanks. Your usage doesn't seem out of normal at all (for ex, I probably use Firefox on Mobile for 8hrs+ / day bar the weekends).

In such a case, it may be RethinkDNS is doing some background work probably endlessly and aimlessly draining the battery. Restarting the RethinkDNS process (force stop, then start) should fix the drain. Of course, we need to weed out any such endless work leaks... I don't know if there's a way to inspect running processes on production builds of the app (which is what users run), so unless we hit such an issue ourselves (on developer builds) and get to inspect the process, it might be a difficult proposition to fix such issues. Our in-app log generation and profiling is pretty poor :( one of these days, we'd get that in order (by v1 a year or two away?), but the priority is addressing the feature gaps, first.

If they manage to get port 53 as whitelisted system ANDROID, does that mean it works? Or not?

Plain DNS queries on port 53 aren't whitelisted, but proxied through rdns (and hence subject to DNS blocklists) when Prevent DNS leaks is enabled. If not, they're simply let through (absent of any DNS blocking). ANDROID appears in the logs because we don't really know which app's making those connections, it appears to rdns as if ANDROID is making those (it could also be a bug in our code, but that's unlikely). If it isn't clear, let me know, I'll try to explain it in a different way...

ignoramous avatar Nov 04 '21 17:11 ignoramous

Restarting the RethinkDNS process (force stop, then start) should fix the drain.

Success! Rethink is off the top-spenders list today.

michaelblyons avatar Nov 06 '21 02:11 michaelblyons

Glad. Thanks for reporting back!

For us, it is then most likely RethinkDNS was working aimlessly in the background draining things. Not good :(

ignoramous avatar Nov 06 '21 11:11 ignoramous

I have to force-quit every day or two. Reopening for tracking.

michaelblyons avatar Nov 12 '21 13:11 michaelblyons

Okay, I've got some work for you to do to help us get to the bottom of this (since it doesn't happen on our devices we haven't been able to troubleshoot this ourselves):

Do you know to run adb commands? If so, can you email us outputs from:

# note down rethinkdns pid aka process-id
adb shell pidof com.celzero.bravedns
<prints-some-4-or-5-digit-number>
# example: 11092

# dump thread state for 1min or so
# plonk in the <pid> from above (without angled brackets)
adb shell top -H -b -p <pid> | tee /tmp/rdnst.txt
# example: adb shell top -H -b -p 11092 | tee /tmp/rdnst.txt

# fetch batterystats well into one or two days in to the drain.
# batterystats reset when the device is at 100% charge, so
# make sure you do not charge up to 100% in the interim
adb shell dumpsys batterystats > /tmp/batstats.txt

Btw, if you're adventurous, you can analyse your android's battery stats yourself: https://developer.android.com/topic/performance/power/setup-battery-historian

:D

ignoramous avatar Nov 13 '21 16:11 ignoramous

~~This might be premature, but I haven't had the drain since the Android 12 January update.~~

Edit: Phooey. 6 days later had to force-quit it again. But 2 weeks is better than every 1-2 days.

michaelblyons avatar Jan 22 '22 15:01 michaelblyons

See also #587

ignoramous avatar Oct 14 '22 13:10 ignoramous

Continuing to track in #587

We haven't even profiled battery use, so it is both likely and unlikely Rethink does something egregious on just Android 12...

ignoramous avatar Oct 20 '22 13:10 ignoramous