Is it guaranteed that every frame takes 16 ms in A...
# compose
m
Is it guaranteed that every frame takes 16 ms in Android?
🚫 2
r
The refresh rate depends on the display. Newer displays have high refresh rates and even variable refresh rates.
❤️ 1
Of course it also depends on what you mean exactly, on a 60Hz display a new vsync fires every 16.6ms, but the all may take more time and miss a frame
❤️ 1
Also things are made a bit more complicated by the fact android gives apps a longer window by firing vsync ahead of time
❤️ 1
Tl;dr don’t assume 16ms and if you need to sync with the display, use the Choreographer API
❤️ 1
m
There is test snippet on Android CS, Compose section:
Copy code
// Forward the clock by 2 frames: 1 for toggle and then 1 for count
composeTestRule.mainClock.advanceTimeBy(32)
It apparently assumes each frame takes 16ms. So, I assume this test could fail on some devices. Sample: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]java/androidx/compose/ui/test/samples/MainTestClockSamples.kt
r
No it's not an issue in this case
❤️ 1
Tests are setup with a special monotic test clock that guarantees a frame delay of 16ms
❤️ 1