syncthing-android architecture: background service

Hi,

I’m currently looking into syncthing (for syncing photos) and trying to figure out how it works.

As far as i can understand, syncthing-android runs the syncthing binary in a service, all the time. I have some experience trying to run something all the time on android, and I know it is not easy. :wink: From my experience, sooner or later, your service can get killed, even when taking all the precautions on a well behaving rom. My app ran just fine for years, currently using a foreground service, but even then it started getting killed somewhere end of 2023. Since my rom or app didn’t change, I suspect a google play policy or something the like.

The current recommended way of doing big background tasks is using WorkManager and syncthing in theory could be a good fit. I started browsing the code but couldn’t find any reference. I also understand that it is not a trivial fit as syncthing is designed to be run as a always running daemon process in the background. So I was a bit worried that syncthing would not work reliably on android (i.e. the service would get killed after some time). On top of that, having a daemon run all the time, might be a waste of resources (tbh I did not check how much the daemon process consumes). So I started looking into alternatives. I found the nextcloud project and they seem to be using workmanager, which is great, but at the same time, the app does so much more than I need, uses slower protocol and requires a server (and maybe a rpi would even be too slow). Back to syncthing :wink:

I had already noticed that the app is in maintenance mode and that there exists a fork (syncthing-fork by @Catfriend1 ). At first, I was very confused, and in general try to stick to “official” projects. But it seems @Catfriend1 has used JobScheduler to address exactly those worries I had. Those changes are not merged upstream.

My question is: is my assessment somewhat accurate? Dare I tag @imsodin ? :slight_smile:

If so, will the main project ever adapt the JobScheduler/WorkManager approach? The maintenance disclaimer on the front page seems to indicate otherwise. Then again, it recently seems quite active (or is it mainly translations?). IMHO, syncthing-android can only survive if it adapts those changes. I don’t know the history of the fork, but ideally it would merge back into a single project, combining forces. I know, easy to say :wink:

I will now start testing the fork project but at the same time am a bit worried about its continuity (no offense @Catfriend1 , I really appreciate your work) as it seems to be a one-man project and much smaller community. Also, does it keep up to date with upstream fixes…?

Looking forward to your replies,

matthias

3 Likes

Yep, quite a few contributions lately, maybe drive-by, maybe some will keep contributing - who knows. Nothing huge though.

The app however works, for a lot of users. That’s basically my main motivation to keep maintaining it: Make syncthing available to android users. Catfriend1’s fork at times announced departure from google play, due to their annoying policies and often arbitrary judgements (I can very much relate) - afaik at the moment it is in the play store again? Anyway point remains: The “official” one doesn’t see much development, but is kept up to date and available.

On it’s own (by me): No. Given a quality PR with an explanation of the what and why of the change I don’t see why not.
Actually even the “by me” part could change, if you give me a strong enough incentive (not $$$, but convincing me of what the pressing need and what the remedy is ), but I have strong doubts that will happen (e.g. info so far was convincing enough to give an answer, but not to check out what any of it means :slight_smile: ). Also as always, no promises.

2 Likes

Besides that, Nextcloud on Android isn’t comparable to Syncthing because it doesn’t actually sync in the background. You can download files and you can push them back up to the server on demand, but changes on either side are not synced automatically.

I’m not sure what the reason for this is. It’s a different design than the desktop client, which is a normal automatic sync client like Syncthing. Maybe they struggled with getting the background service to work reliably as you mentioned, or maybe they knew it would be difficult and no one has stepped up to do the work yet. All I know is that it’s a frequently requested feature.