FramePacer

class FramePacer(nativeHandle: NativePointer)

Coordinates frame scheduling and presentation timestamps: a filter between the platform's VSYNC callbacks (such as Android's Choreographer) and Renderer.setPresentationTime.

Created with Builder and destroyed with Engine.destroy. All times are steady-clock nanoseconds (CLOCK_MONOTONIC on Android, which System.nanoTime() reads there). In each VSYNC callback:

if (pacer.setupFrame(tick) != FramePacer.FrameStatus.ACCEPTED) return // yield to keep the cadence
if (pacer.hasGpuFallenBehind(renderer)) { renderer.skipFrame(tick.baseTime); return }
pacer.applyPresentationTime(renderer)
if (renderer.beginFrame(swapChain)) { renderer.render(view); renderer.endFrame() }

Constructors

Link copied to clipboard
constructor(nativeHandle: NativePointer)

Types

Link copied to clipboard
class Builder
Link copied to clipboard
data class Configuration(val targetFrameRate: Float = 60.0f, val latency: Long)

Pacing targets.

Link copied to clipboard
Link copied to clipboard
data class HardwareTimeline(val expectedPresentationTime: Long, val deadline: Long)

One expected hardware presentation timeline.

Link copied to clipboard
Link copied to clipboard
data class VsyncTick(val baseTime: Long, val vsyncPeriod: Long, val frameScheduleTime: Long? = null, val timelines: List<FramePacer.HardwareTimeline> = emptyList())

VSYNC telemetry from the platform compositor.

Properties

Link copied to clipboard

The active pacing targets; setting it rescales subsequent frames (e.g. for thermal mitigation).

Link copied to clipboard

The target presentation time minus the frame's base time, in nanoseconds.

Link copied to clipboard

The presentation time computed by the last setupFrame, for judder-free animation.

Link copied to clipboard

Whether selectedFrameRate is an exact integer fraction of the display refresh rate (false for 45 FPS on 60Hz).

Link copied to clipboard

The native object, for interop with code calling the Fila* C API directly. Read-only: this wrapper owns it.

Link copied to clipboard

The pipeline's flow control status.

Link copied to clipboard

The time by which the last setupFrame's frame must finish rendering to make its presentation.

Link copied to clipboard

The pacing frame rate in use: the target, matched to the display's cadence and clamped to its refresh rate.

Functions

Link copied to clipboard

Sets the computed presentation time, desired presentation time and rendering deadline on renderer; call before endFrame.

Link copied to clipboard

Whether the GPU has fallen behind; if so, the state setupFrame advanced is rolled back and the frame should be skipped with Renderer.skipFrame, without applyPresentationTime or Renderer.beginFrame.

Link copied to clipboard

Drops the relative pacing state and re-anchors to the target latency on the next frame.

Link copied to clipboard

Targets one more presentation frame without advancing the cadence, to recover queue depth when pacingStatus is PacingStatus.DISPLAY_STARVING; follow it with applyPresentationTime and a frame. Returns false, doing nothing, when the pipeline is already at its target latency.

Link copied to clipboard

Evaluates the pacing state for the upcoming frame; call it first thing in the VSYNC callback.