Back to Filament

synchronizePendingFrames

docs/android/dokka/filament-android/com.google.android.filament.android/-filament-helper/synchronize-pending-frames.md

1.75.01.6 KB
Original Source

//filament-android/com.google.android.filament.android/FilamentHelper/synchronizePendingFrames

synchronizePendingFrames

[main]
open fun synchronizePendingFrames(engine: Engine)

Wait for all pending frames to be processed before returning. This is to avoid a race between the surface being resized before pending frames are rendered into it.

For android.view.TextureView this must be called before the texture's size is reconfigured, which unfortunately is done by the Android framework before UiHelper listeners are invoked. Therefore synchronizePendingFrames cannot be called from onSurfaceTextureSizeChanged; instead a subclass of android.view.TextureView must be used in order to call it from onSizeChanged:

kotlin
public class MyTextureView extends TextureView {
    private Engine engine;
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        FilamentHelper.synchronizePendingFrames(engine);
        super.onSizeChanged(w, h, oldw, oldh);
    }
}

Otherwise, this is typically called from onResized, surfaceChanged.

Parameters

main

engineFilament engine to synchronize

See also

UiHelper.RendererCallback
android.view.SurfaceHolder.Callback#surfaceChanged
android.view.TextureView#onSizeChanged