Android: high idle CPU usage since 0.9.3

Hello,

I am unable to use Syncthing-Android versions newer than 0.9.2. Having the application sit at the main activity causes CPU utilisation to climb to 35-40% and stay that high. Scrolling the folder/device list becomes nearly impossible. It was bad enough in 0.9.3, as visible in my video here. However, it is worse in 0.9.4/5, even to the point that I get Android’s “application not responding” prompts.

When viewing Syncthing’s status in the web UI (through a separate browser, not the “Web GUI” option in the menu), CPU utilisation stays around a very comfortable 0.5%.

I am experiencing this on an HTC Desire 310 dual running Android 4.2.2 and an LG G Pad 7.0 running 5.0.2, both with 1 GiB RAM. I have tried wiping the application’s settings and starting from scratch. It gets to the same point after adding two devices and two folders (I normally have a few more).

I believe that my issue may be related to the GUI update interval change in this commit. However, I do not see anyone else reporting a problem like mine. I’m out of ideas at this point.

What are the most useful logs I could upload to help debug this? Thanks in advance for any help!

I suppose your device is too slow for the frequent updates, but I’m also surprised no one else has reported it. Do you get this problem only while a sync is running, or also when Syncthing is idle? And is the CPU usage caused by Syncthing itself, or by the android wrapper?

I suppose we should just change the update interval to 2 seconds. But I’m not sure what the best value is, and I’d rather not add another preference.

It also happens when idle. If what is displayed in the web UI only takes into account only the Syncthing daemon’s usage (~0.5%), then it must be the wrapper.

I have attached Android’s log output with Syncthing-Android’s main activity open on the device. What struck me is a pattern of

E/DSQN    (28609): unable to retrieve src ip address
E/DSQN    (28609): src addr is not same with wlan's ip address
E/DSQN    (28609): unable to retrieve src ip address
E/DSQN    (28609): src addr is not same with wlan's ip address
E/DSQN    (28609): unable to retrieve src ip address
E/DSQN    (28609): src addr is not same with wlan's ip address
D/libc-netbsd(21556): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
D/libc-netbsd(21556): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0
D/libc-netbsd(21556): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
D/libc-netbsd(21556): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0

being logged around a hundred times per second and, periodically, another line I found interesting:

I/Choreographer(21556): Skipped 61 frames!  The application may be doing too much work on its main thread.

ST-Android.zip (169.9 KB)

Those logs aren’t from Syncthing. If you also get them when Syncthing is not running, they probably don’t matter.

Will look at the full log in a few days when I’m back on my laptop.

I couldnt find anything unusual in the full log, except the lines you mentioned. Do you also get these lines when Syncthing is not running? Anyway, they are not (directly) caused by Syncthing, but are caused by some problem in your Android version.

I’ve changed the gui update interval to 2s, hope that fixes your problem.

I personally found that any kind of sync related error makes Syncthing binary work extra hard and end up causing a lot of cpu usage.

I wish that there was a way to make Syncthing more forgiving with sync errors. For instance we could decrease the sync frequency when errors are produced. I had cases where syncthing would literally drain my full battery in less than an hour.

I get these lines as long as Syncthing-Android is running. If I quit the app (swipe away in task manager), the Syncthing service keeps running, but these messages stop.

As for getting the proper logs from Syncthing, are there any specific debug options I should use? All I get from within the app is this:

--------- beginning of main
--------- beginning of system

No the logs are fine, this just seems to be an oddity with your Android. Maybe you can find something if you google those logs, and maybe an Android update would fix it.

Hello,

A big +1 to this issue.

I didn’t understand at first, but I have been dealing with ALL what is mentioned in the OP, for ~ a week now. I managed to export the settings, went back to 0.9.4 and imported them, to no avail. Now I’ll try to go back to 0.9.2 which seems to be the last smooth-working one, hoping the Syncthing version will be able to communicate with the latest that is on my five or six other devices (0.14.20+).

Last but not least, pls let me insist that it is not related to the power of the device, as I’m running a OnePlus 3 (6GB RAM, Snapdragon 820).

Thanks for your insights.

1 Like

not sure if this is exactly what I’m experiencing, but CPU is definitely higher than normal even when idle. on idle the CPU usage is roughly 50-60%, but when scanning it’s even higher. no syncing is going on and if so, it’s very small… definitely cannot leave syncthing running in the background without sapping my phone’s battery so I only turn it on/off at certain times of the day to sync.

This change only makes a difference if the app is open and in the foreground. If you see higher CPU usage in other cases, that’s a different issue.

As far as I can remember, I have always let Syncthing run in background. Excepted intense indexing and syncing sequences for huge files/folders, it has very little impact on my battery. Moreover, in my precise case, it is not the battery that is concerned, rather how unresponsive the app becomes (be it in the foreground or in the background) until I have to kill the process.

I’ve been struggling with this for a while, since around 0.9.3. I was hoping the changes to permit disabling weak hashing would solve it, but seemingly not. The UI stalls for so long Android asks if I want to kill it, and using a resource monitor (OS Monitor) I can see Syncthing constantly using around 25% CPU time, 24/7. All of the folders are marked as Idle and it’s not doing any chat with other devices, as the problem persists with WiFi off.

I’ve tried enabling foreground priority, keeping CPU awake, enabling legacy hashing etc. Trying to revert to 0.9.2 but it seems the APK doesn’t exist on F-Droid any more - is there somewhere I can get a hold of it? (That doesn’t look very dodgy!)

You can enable the “F-Droid Archive” repository in the client to access old versions.

1 Like

You cant downgrade without uninstalling the app. Make sure there is always syncthing config backup.

1 Like

If you have the Android SDK set up on your computer, you can use this command:

adb install -r -d package.apk

The -d flag forces installation of the package file, even if it constitutes a version downgrade.

2 Likes

Perfect, thanks!

0.9.6 works very well for me. Thanks a lot!