-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syncthing becomes disconnected while android is sleeping #327
Comments
Does the adb command in the article help? https://github.com/Catfriend1/syncthing-android/wiki/Android-TV-preparations |
I don't need It seems syncthing-fork is disconnected from my desktop computer whenever there are changes in folder settings or whenever I add folders. I suspect sycnthing-fork crashes on certain conditions. Is syncthing-fork going to sleep anyway after android sleeps for a while? |
Thanks for the log. Ok there's a crash in it... Maybe that's already fixed in master I recall this fixed a few days ago but unsure if the fix works. I'll compile you a test APK during the next dev session and upload it here so you can check if it fixes the problem. |
Ref: #322 |
The crash is a separate issue. The issue I want to solve is that I cannot predict or control when syncthing-fork wakes up while android is dozing. Does syncthing-fork wake up when periodic scanning happens for each directory? |
If the activity crashes the doze exemption will not work... Need to check this |
If the activity doesn't crash, when does syncthing-fork wake up while android is dozing? |
It stays awake (doze exemption) or it never wakes up. There's no maintenance window the app subscribes to. |
Perhaps, should I keep syncthing-fork in recent app list in order to allow syncthing-fork to run in the background? I have a habit of closing every app in recent app list very often. Or, is the Go process unaffected by Doze or Doze exemption? |
@crocket : Yes, you shouldn't swipe it away as some Android's handle this as force-close and abort the service.
|
Is it possible to separate the Go service from syncthing-fork app? |
This is found on the forum as it's often been discussed. Search for sdcard issue. |
https://github.com/syncthing/syncthing-android/wiki/Frequently-Asked-Questions#what-about-sd-card-support doesn't seem relevant to my issue. Or, were you referring to https://forum.syncthing.net/t/when-does-syncthing-synchronize-while-android-is-sleeping/12862 ? I discovered that my nexus 5 connects to my desktop computer on random intervals while android is dozing. |
https://forum.syncthing.net/t/syncthing-can-not-write-to-sdcard/12773/9 Roadmap, to avoid spending my dev time in discussing.
|
Here's my incomplete conclusion from my investigation. I might be wrong because I don't write android apps. According to https://developer.android.com/training/monitoring-device-state/doze-standby#restrictions According to https://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases From https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze |
I installed com.github.catfriend1.syncthingandroid_gplay_v1.0.1.4_cdcdc3c1.apk and tested it. Connection was severed temporarily after adding, removing, or sharing a folder on my computer or nexus 5. But, there was no crash. I don't know what caused the crash in the first place, though. |
Good observation! Matches my knowledge about what I've already researched. thanks for writing the summary :). |
Connections are restored soon after temporary disconnections caused by adding, removing, or sharing folders. Partial wakelock option is permanently disabled in syncthing-fork, but it can be enabled in syncthing. When partial wakelock is enabled in syncthing-fork, should it prompt users to disable battery optimization for syncthing-fork, too? It seems to me that you need to disable battery optimization to utilize partial wakelock for continuous sync. Or, is it enough to disable battery optimization and uncheck "Respect Android battery saving setting"?
|
The wakelock thingy in the official app is outdated and only works before android 6.x . That's why it was disabled in the fork permanently on higher versions. You can't bypass doze except whitelisting the app from doze which is what syncthing fork enforces during the welcome wizard. "Respect Android battery saving setting" is unrelated to the sleep topic as its the power save mode the phone enters e.g. when the battery percentage gets below 20%. From what I reaf between the lines: your issue is solved. Temporary disconnects after changing the config (folders, devicwles etc.) are expected. |
My conclusion is that if you are not going to use partial wakelock, disabling battery optimization doesn't change anything. My suggestion
|
@crocket I believe what you're saying but other tickets say this isn't correct according to user reports. Wifi lock for example has no impact when android 7 is dozing. On 7.1 it may have but there, disabling battery optimization solves the issue. I use the app myself quite heavily and - may this be manufacturer or ROM specific - it worked without disconnects on my phones >= 7.1. If you'd like to help and contribute code, we can start digging deeper into the can of worms testing with your specific device. Partial wakelocks were ignored on my tests in the past which leaves me unsure. Testing here myself, disabling power optimization definitely was a requirement for syncthing to keep connected. |
"Stop the welcome wizard from prompting users to disable battery optimization" I wont do this unless we have a better working code in place. Most users of official got used to and thought they can reduce battery usage by not exempting from doze which was optionally - and it led to a bunch of failing to connect syncthing instances. I'm not opposed to improve it but thinking of all that different Android's out there I guess it's a move from 70% working devices to 30% devices. Maybe others reading this can chime in and give their device setup and details if they have the permanently disconnected observation. For now I'll close this but still read reports, comments or suggestions which are welcome to get a better overview how devices behave. |
Syncthing-fork runs a foreground service which is exempt from Doze from android nougat onward according to https://www.bignerdranch.com/blog/diving-into-doze-mode-for-developers/ and https://www.linkedin.com/learning/android-development-building-battery-conscious-apps/overriding-doze-mode-using-a-foreground-service. It seems a foreground service doesn't need to acquire partial wakelock or disable battery optimization. Weirdly, disabling or enabling battery optimization of syncthing-fork doesn't affect how often syncthing-fork is disconnected.
|
|
Is the Go process automatically exempt from doze? The Go process may not qualify as an app which is subject to Doze. I don't understand how disabling battery optimization for syncthing-fork disables battery optimization for syncthing Go process. Why would a foreground service need to disable battery optimization in the first place? |
Well I don't know it that deep but from trying and comparing with other apps like bubbleupnp, linphone ... It's the same observation. A foreground service alone isn't enough as this for example helps rhe app not being killed by Android's algorithms when it's backgrounded (nothing to do with doze here). I'm no Android OS expert in the deep so my observation is , the Android os creates a VM procesa group where the go proc is a child. If the java proc is alive during doze, the whole proc group is alive. |
Conclusion: will readd the partial wake lock option. From what I heard a minority of users will need this as for example my own hardware works fine without the partial lock but needs exemption from doze instead to keep connected while sleeping. |
What is your hardware and operating system? |
I've tested:
Got user report by o-l-a-v that Android TV need exempt from doze or the app is useless. |
Maybe also wifi sleep policy is also relevant as I've checked the setting always scan for wifi in android settings. |
Android 8.1 removed |
Plus, in the location settings there is also an advanced option in Android to scan WiFi and Bluetooth. It's a whole mess, so I change the app if enough people confirm a change makes it better. This has nothing to do with you personally - I need to clarify first that it will help more people than destroying things on other phones where it operated fine already. |
I give up on fiddling with Wi-Fi settings. |
In summary, the forked version doesn't work for you? |
It works. But, disabling battery optimization doesn't have any visible effect on connection reliability on LineageOS 14.1 and LineageOS 15.1 I suspect android TV is different from mobile devices because it dosen't operate on battery. I think it would be better to turn syncthing into a library and call the library from the android app. |
The library idea is already discussed in upstream. But upstream needs a contributor to do so as a clean solution. |
https://dontkillmyapp.com/ (maybe worth adding to the first-run slideshow) Locking in the recent apps view might help aswell. |
Thank you both for the pointers. Will read through this weekend. |
Description of the issue
I just disabled battery optimization for syncthing-fork. While android is sleeping, syncthing-android is disconnected from my desktop computer.
Reproducer
Version Information
Android Log
The text was updated successfully, but these errors were encountered: