-
Notifications
You must be signed in to change notification settings - Fork 67
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
Timer
is paused on Android in "doze" state
#63
Comments
|
Commenting to note that this behavior is actually desirable in my use case, as it prevents massive thundering-herds of timers suddenly expiring when Doze ends, something I've seen in Go. My use case does involve massive amounts of small, fine-grained timers (essentially a userspace TCP implementation), so it's somewhat of a worst-case for this though. |
With Rust 1.64 coming out in a month or so, this issue should be fixed on |
As of Rust 1.64, the |
Actually, I just remembered that |
This URL points to line with There is a PR proposing a switch to |
Because
std::time::Instant
is implemented usinglibc::clock_gettime(CLOCK_MONOTONIC)
and this time does not advance on Android while the app is in "doze" state, the timer may be effectively paused on Android: https://users.rust-lang.org/t/std-now-with-android/41774One way to fix this is to use
SystemTime
instead and handle time occasionally going backwards properly. Another is to lift this issue to the standard library so it uses Android-specificioctl
on/dev/alarm
as described here: https://users.rust-lang.org/t/std-now-with-android/41774/2The text was updated successfully, but these errors were encountered: