maxGpuFramesInFlight property

int maxGpuFramesInFlight
getter/setter pair

How many frames of GPU work may be outstanding before a screen view presents its previous image again instead of encoding a new frame.

The Vulkan and Metal backends encode and queue GPU work on the thread that calls render. Once the GPU falls behind, Android's Vulkan drivers block that thread for the backlog (the queue is serialized with the raster thread's own submissions), so a GPU-bound scene stalls the UI thread and everything else on it. Pacing instead re-presents the last frame once maxGpuFramesInFlight frames are still running; the scene updates at the rate the GPU finishes frames, which it did anyway. Scene time still advances on a paced frame.

Defaults to 2 on iOS and macOS, where Metal queues a second frame without stalling either thread. There a limit of 1 can halve the frame rate of a scene the GPU has room for, since the GPU clocks down until each frame barely fits a vsync and a held frame then misses the next. It is also 2 on web, where completion is only seen after a trip through the event loop, so a limit of 1 holds frames the GPU has already finished. Elsewhere it defaults to 1. On Android's Vulkan backend a second frame blocks this thread or the raster thread once the GPU falls behind, which slows the whole app, and on GLES it gains little. An Android game whose 3D view matters more than the rest of its UI can still set 2. Set to 0 to always encode. Only screen views pace; render-to-texture views always render.

Implementation

int maxGpuFramesInFlight = defaultMaxGpuFramesInFlight;