Syncthing-Fork v2 uses far too much battery over v1

I am experiencing this issue on a Pixel 9a with Android 16 (GrapheneOS). Over the last weeks I first git bisected the wrapper and then syncthing native. The commit causing this issue is 9d425b05880236928c561da0b7152e41d795a5ac in Syncthing Native. It uses a new library, anet to fix some methods regarding network interfaces and addresses for Android 10+.

Instead of downgrading to v1, I found this workaround which resolves the issue for me: Disabling Settings -> Syncthing Options -> Local Discovery. I’d be interested to hear if this workaround works for other people here having this issue.

I am still trying to figure out if the root cause is in the commit that I found (or rather the anet library) or if the root cause is in another part of the Local Discovery feature and the fix for Local Discovery on Android 10+ only made the issue visible on newer Android versions.

15 Likes

Good catch! I wonder if it’s a bug in the anet library or if it’s simply because we’re waking up the radio every 30 seconds :thinking:

2 Likes

Thanks for the workaround. This solves the issue completely for me, because I use DNS instead of discovery anyway.

I hope that a solution is found soon to fix it for everyone.

1 Like

Thank you so much! This brings battery consumption back to less than 1 % over the whole day!

Where can I learn about the different discovery methods? I did not really find anything comprehensive via search.

2 Likes

I’ve read the technical documentation on the Global Discovery Protocol and the Local Discovery Protocol.

I’m not using DNS records, but global discovery works even for local connections, as the clients share all of their IPs with the global discovery server.

2 Likes

Were you able to verify your patch? I’d just like to rule out that there’s a bug in the anet implementation and we’re just putting bandaid on it.

When I disabled Local Discovery on Pixel 9a my phone is Disconnected (Remote Devices) on desktop app. I have to use Android tile: Enable for 5 minutes to sync to my desktop. After that app starts syncing and Pixel 9a is Up to Date (Remote Devices).

My Run Conditions:

Run on Wi-Fi - enabled

Run on specified Wi-Fi - enabled

Battery consumption is less than 1% per day.

Before that my battery consumption was about 25% when I have enabled Local Discovery.

As I understood, you need to leave global discovery enabled when disabling local discovery to still have the benefit of automatic syncing when online.

You could configure each Remote Device by IP and avoid needing to turn Discovery on at all. Remote Device / Edit / Advanced.

Thanks for all the progress that has been made on this. I am currently running syncthing in termux and with local discovery disabled, battery consumption goes back to being negligible when on wifi. When I’m on 5G however, Android again reports elevated use and the battery is drained notably quicker. Is anyone else experiencing this now?

For the future it might be better to not rely on fixed delays for discovery and let the wrapper trigger this on network changes.

1 Like

Should I enter IP address in Advanced section / Addresses in Remote Device only?

Should I change desktop app Settings/Connectiones too? Uncheck Global and Local Discovery?

Should I change Syncthing Options on Android too? Uncheck Global and Local Discovery?

I would suggest you enter the IP addresses or FQDNs on each side (I use Syncthing over Tailscale, so I use my Tailscale DNS for this). I would recommend that you experiment with turning off Local and Global Discovery on the Android side.

I have tested the change for a few hours, and the battery draining seems to be less (~15% instead of ~30%), but still significantly higher than without local discovery (<1%).

Regarding anet, I took a look at the code, and I did not find anything suspicious that could be the cause. Most of the code seems to be copied from the GoLang’s net library, and some syscalls were changed as they are no longer available on newer Android versions.

This could be the same problem if your 5G interface has the broadcast and/or multicast flag, as local discovery advertisement is attempted on all interfaces where the running flag and broadcast or multicast flag is set.

Unfortunately my connection is refused on Remote Device. I used tcp address and info is described in red.

I have to use Android tile: Enable for 5 minutes to sync to my desktop again. I will live with this small inconvenience and lack of automaticity :slight_smile: But low battery consumption is a priority.

I’m confident this is fixable. Screenshots?

Thanks for your reply. To check that I understand you correctly, this can happen even when Local Discovery is turned off? Given what we know now, is there another way I can prevent it?

As a side-note: I’ve now added all my devices to a wireguard vpn, so I’m gonna try using IPs without discovery too.

To add to the above: unfortunately, even with only static IP addresses configured and Local Discovery, Global Discovery, NAT traversing and relays disabled, battery consumption goes up considerably when on 5G, without syncthing apparently doing anything.

Do you have Run on mobile data enabled? I didn’t yet check if I have the issue without wifi, but I’d expect syncthing to not run with that option disabled.