-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Tracking only sends new information very slowly when screen is off on Android #60
Comments
I'm aware of this issue. You're right, its not great. I did some tests on this back in November (see below). Basically the phone seems to wake up for a few seconds and it spits off some fingerprints, but then sleeps for a sporadic amount of time (ranging from 25 to 120 seconds, see below). A solution might be to use a background plugin that basically would work kind of like this alarm clock except instead of alerting anyone, it would just wake and send off a fingerprint. Another solution would be to implement wakelocks, but I've read this can take a lot of battery which is what this whole system is designed to avoid! I don't know though because I haven't tried it. |
I don't think there is a way to avoid battery drain when tracking with somewhat high accuracy, be it via wakelocks or via the background-plugin (however that works). That's why I mentioned a timeout. I don't know much about android internals, but my thinking would be kinda like this: |
I think that's definitely worth a try. Its certainly the easiest - as its only one plugin + two lines of code. I'll play with this. |
I've added this now here: 6547012. The resultslook good. When I use the wakelock, it works as intended (the points are the timestamps received of /learn requests from the phone): versus no wakelock (previous version): Before it becomes a release, I'd like to add an option to turn this functionality on (by default it should be off, I don't want to waste people's batteries). The without wakelock is not that bad for many applications, because of the background plugin that holds over data until the phone wakes a bit from sleep. |
Nice :) |
Unfortunately I don't think the wakelock is a solution. It uses a LOT of battery. I extrapolated from battery logging that it would use about ~60% per hour on my phone, even when I dimmed the screen as much as I could. For comparison, the current program, which can run in the background albeit sporadically, uses about 6% per hour (which may be the baseline of my phone). Another possibly, yet hacky, solution is to set a silent alarm that wakes the phone up every minute or so. Then, I assume, the android might take a little bit to go back to sleep which could help with the consistency. It actually seems to work okay: The actual implementation here could be smarter - i.e. I could create an alarm whenever a user is tracking/learning and a response from the server hasn't been seen in 30+ seconds, instead of creating alarms every 61 seconds. Here's a direct comparison. The alarm is not as perfect as the wakelock, but it helps keep things more consistent. The only problem is that it vibrates the first time the alarm activate :|. |
Ouch, that's a lot ;) Well, I guess for my use case I could change it so Tasker not only starts the tracking but also wakes up the phone. |
I got a new version (4b89410) that doesn't vibrate! And it also seems better than the baseline: |
Hi all, |
I'm guessing that's some wakelock problem (or rather lack of one). It would definitely be useful to have it send requests and the same speed as with screen on. Maybe with an optional timeout (default 5 minutes) to avoid draining the battery.
The text was updated successfully, but these errors were encountered: