https://kotlinlang.org logo
Title
m

Martin Rajniak

04/13/2022, 8:52 AM
Can anyone pls explain how come
delay
sometimes takes 30m instead of expected 4m (that were supplied as argument)? It is observed on Android.
j

Joffrey

04/13/2022, 8:54 AM
Maybe you're running this
delay()
in a dispatcher with a limited number threads, and running blocking code in that same dispatcher at the same time, which would prevent it from resuming other coroutines. Could you please share a bit more details about those coroutines?
l

louiscad

04/13/2022, 8:54 AM
App/device put in deep sleep
👆 2
delay is based on SystemClock.uptimeMillis
Because delay is based on Handler.postDelayed which uses this clock, and doesn't itself put any wakelock
:today-i-learned: 2
m

Martin Rajniak

04/13/2022, 5:11 PM
@Joffrey thx, but probably not it, since I have reproduced with MainDispatcher and I would expect ANRs in that case @louiscad Thank you, that explains it. Today I learned that delay has Android specific implementation.