@Deprecated(
"MonotonicFrameClocks are not globally applicable across platforms. " +
"Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock by lazy {
if (DisallowDefaultMonotonicFrameClock) error("Disallowed use of DefaultMonotonicFrameClock")
// When linked against Android SDK stubs and running host-side tests, APIs such as
// Looper.getMainLooper() that will never return null on a real device will return null.
// This branch offers an alternative solution.
if (Looper.getMainLooper() != null) DefaultChoreographerFrameClock else FallbackFrameClock
}
public val DefaultMonotonicFrameClock: MonotonicFrameClock
The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.
This value is no longer used by compose runtime.
@Deprecated(
"MonotonicFrameClocks are not globally applicable across platforms. " +
"Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock
@Deprecated(
"MonotonicFrameClocks are not globally applicable across platforms. " +
"Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
object : MonotonicFrameClock {
override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R =
suspendCoroutine { continuation ->
window.requestAnimationFrame {
val duration = it.toDuration(DurationUnit.MILLISECONDS)
val result = onFrame(duration.inWholeNanoseconds)
continuation.resume(result)
}
}
}
The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.
This value is no longer used by compose runtime.
@Deprecated(
"MonotonicFrameClocks are not globally applicable across platforms. " +
"Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
object : MonotonicFrameClock {
private val markNow = TimeSource.Monotonic.markNow()
override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R {
yield()
return onFrame(markNow.elapsedNow().inWholeNanoseconds)
}
}
The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.
This value is no longer used by compose runtime.
@Deprecated(
"MonotonicFrameClocks are not globally applicable across platforms. " +
"Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
object : MonotonicFrameClock {
override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R =
suspendCoroutine { continuation ->
window.requestAnimationFrame {
val duration = it.toDuration(DurationUnit.MILLISECONDS)
val result = onFrame(duration.inWholeNanoseconds)
continuation.resume(result)
}
}
}
The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.
This value is no longer used by compose runtime.