-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Android: Instant not advancing while the screen is off #71860
Comments
Does |
Yes. https://developer.android.com/reference/android/os/SystemClock:
|
Another option here is to wait until the minimum supported version of linux is >= 2.6.39 to use |
With Rust now requiring Linux 3.2, would it be possible to migrate these timers to |
golang however decided against using There is also a reason fix for So there is a conflict between the needs of network protocol implementations which want to use timeouts to wait for external events and keepalives and all kinds of existing usecases like watchdog timers which should be triggered if CPU was used but the process did not make any progress and got into some busyloop. Maybe we need new kind of timestamps and new kind of timeouts. There is a discussion in the go repo started by zx2c4 (known for creating wireguard): golang/go#36141 |
I think this is also for T-libs because it is also about the implementation, not just the API? @rustbot label +T-libs |
I tried this code on Android:
I expected to see this happen: Get some hours as a result
Instead, this happened: Got only minutes because the time while the process is sleeping / the app is "dozing" is not counted.
Nice explanation from mbrubeck (https://users.rust-lang.org/t/std-now-with-android/41774):
Instant::now()
on Android (and other Linux platforms) is currently implemented usinglibc::clock_gettime(CLOCK_MONOTONIC)
. Apparently this clock does not advance while the CPU is in deep sleep modes ("Doze"). This is also how Android'sSystemClock.uptimeMillis
method works.Android also offers a
SystemClock.elapsedRealTime
method, which seems to be implemented using an Android-specific ioctl . Perhaps it would be possible to migrate the Rust standard library to use this call on Android, if there are no trade-offs in precision.The text was updated successfully, but these errors were encountered: