Skip to content

fix(android): pace frame-rate caps like rive-android - #417

Open
mfazekas wants to merge 1 commit into
fix/android-idle-frame-loopsfrom
fix/android-frame-pacer
Open

mfazekas wants to merge 1 commit into
fix/android-idle-frame-loopsfrom
fix/android-frame-pacer

Conversation

@mfazekas

Copy link
Copy Markdown
Collaborator

Stacked on #416.

The frameRate cap compared each vsync against the last drawn frame with a 4 ms tolerance, so a cap that doesn't divide the refresh rate came out low (60 fps on a 90 Hz display rendered at 45), and every skipped vsync still cost a frame callback. This replaces it with a copy of rive-android's internal RiveFramePacer, which tracks the next due frame time, and posts the next frame callback delayed until shortly before it, as the Rive composable does.

On a 60 Hz emulator (release build, per 10 s): a 45 fps cap went from 293 to 449 draws, and a 15 fps cap from 600 to 294 frame callbacks. 30 fps on 60 Hz still wakes on every vsync, the same as upstream, because the pacer's early-wake margin lands on the vsync before the target. The Frame Rate Cap example page gets a 45 fps option to show the non-divisor case.

The frameRate cap compared each vsync against the last drawn frame with a
4 ms tolerance, so a cap that does not divide the refresh rate came out
low (60 fps on a 90 Hz display rendered at 45), and every skipped vsync
still cost a frame callback.

Use a copy of rive-android's internal RiveFramePacer, which tracks the
next due frame time, and post the next frame callback delayed until close
to that time, as the Rive composable does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant