-
-
Notifications
You must be signed in to change notification settings - Fork 848
SensorWorkerBase set foreground type based on WebSocketManager status #5999
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
base: main
Are you sure you want to change the base?
Conversation
|
In addition to testing your assumption, this may or may not be a Play Store policy violation if Google wants to be even more annoying than they currently are: https://support.google.com/googleplay/android-developer/answer/16559646?sjid=6427937707813206044-EU&visit_id=638978871294180277-1134189417&rd=2#fgs (we need to upload video/description of our usages) Sensor updates can run as a background service / pure WorkManager job in theory, but are throttled on some devices when doing this making sensor updates less reliable. |
Should it be a violation for the google play version, but work otherwise, please consider ifdefing it for the FOSS/minimal version only. |
That's a possibility but before we want to validate the assumption, so if you are able to reproduce the issue please try to disable all the sensors and see if the issue persist, then test the APK from this branch. |
|
Yes, forgot to mention that in the ticket, I've disabled the sensors in the app (was only battery anyway) and will now see if the persistent connection breaks down again. |
b99c0c4 to
5427c17
Compare
I've made a new version more aggressive if you can test again 🙏🏻 |
|
Well the connection was working for around 20 hours, but still failed at some point. I force-closed the app without looking at the logs assuming the don't reset after restart, so that was my mistake. I'll look at them once it fails again. |
|
New day, same behavior. I'm not seeing anything failing and the notification is still there. Calling notify fails with the usual not connected to local push. I'm switching to airplane mode overnight, so maybe staying offline "too long" breaks stuff? |
So it's better than before no? It seems that the services are not killed anymore. The notify issue might be something else. I see from the logs that everything seems to be connected fine. It takes some time for HA to recover from airplane mode. |
|
I'm not entirely sure. For me the connection usually held longer than for the ticket author. I have now created an automation to test the notification at hourly intervals, will get back to you with the results. Not sure I understand the airplane recovery part, I'd expect it to recover instantly as when I force close the app. I have also tried switching airplane mode on and off briefly and the notification worker reconnected after about 10 seconds (which is fine), but the issue with airplane mode overnight is permament. I also saw that everything seems to be connected at least from the view of the companion app, maybe the issue is also partially on the server side? |
I forgot to ask on which version of Android are you? |
|
16, running latest grapheneOS without google services. |
|
My hourly notifications had some troubles at 2pm, server claims it was sent successfully, but it did not show in the app notification history. I've then sent a notification manually at around 2:08 and it was delivered correctly, so some sort of recovery did take place - but nothing visible in the logs. Around 4:30pm I left the house and the 5pm notification did not arrive - the connection was broken and has not recovered so far, even though I returned home. This time, there is something in the logs though, let's hope that might give you an idea: |



Summary
This PR is a PoC to try to address an issue for users using Persistent Connection #5939
My though on this issue is that the
SensorWorkermight get theWebSocketManagerto be killed by the system when the overall limit of 6h is reach from the sum of running time of these two worker, even if the WebSocketManager is usingremoteMessaging. This PR is an attempt to change the type ofSensorWorkerso that when it starts when the Connection is persistent it won't start as adataSyncbut as the same type as theWebSocketManager.This is definitely a hack, so we need to first test if this assumption is valid.