FramePacer
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() }Types
Properties
The active pacing targets; setting it rescales subsequent frames (e.g. for thermal mitigation).
The target presentation time minus the frame's base time, in nanoseconds.
The presentation time computed by the last setupFrame, for judder-free animation.
Whether selectedFrameRate is an exact integer fraction of the display refresh rate (false for 45 FPS on 60Hz).
The native object, for interop with code calling the Fila* C API directly. Read-only: this wrapper owns it.
The pipeline's flow control status.
The time by which the last setupFrame's frame must finish rendering to make its presentation.
The pacing frame rate in use: the target, matched to the display's cadence and clamped to its refresh rate.
Functions
Sets the computed presentation time, desired presentation time and rendering deadline on renderer; call before endFrame.
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.
Drops the relative pacing state and re-anchors to the target latency on the next frame.
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.
Evaluates the pacing state for the upcoming frame; call it first thing in the VSYNC callback.