docs/android/dokka/filament-android/com.google.android.filament/-renderer/begin-frame.md
//filament-android/com.google.android.filament/Renderer/beginFrame
[main]
open fun beginFrame(swapChain: SwapChain, frameTimeNanos: Long): Boolean
Sets up a frame for this Renderer.
beginFrame manages frame pacing, and returns whether or not a frame should be drawn. The goal of this is to skip frames when the GPU falls behind in order to keep the frame latency low.
If a given frame takes too much time in the GPU, the CPU will get ahead of the GPU. The display will draw the same frame twice producing a stutter. At this point, the CPU is ahead of the GPU and depending on how many frames are buffered, latency increases. beginFrame() attempts to detect this situation and returns false in that case, indicating to the caller to skip the current frame.
All calls to render() must happen after beginFrame().
true: the current frame must be drawn, and endFrame must be calledfalse: the current frame should be skipped, when skipping a frame, the whole frame is canceled, and endFrame must not be called. However, the user can choose to proceed as though true was returned and produce a frame anyways, by making calls to render, in which case endFrame must be called.
main
| swapChain | the SwapChain instance to use |
| frameTimeNanos | The time in nanoseconds when the frame started being rendered, in the nanoTime timebase. Divide this value by 1000000 to convert it to the uptimeMillis time base. This typically comes from android.view.Choreographer.FrameCallback. |
| endFrame |
| render |
| Error | if the backend thread encountered an unrecoverable error. |