rememberRiveWorker

fun rememberRiveWorker(autoPoll: Boolean = true, tracingEnabled: Boolean = false, renderBackend: RenderBackend = RenderBackend.OpenGL): RiveWorker

A RiveWorker is the worker that runs Rive in a thread. It holds all of the state, including assets (images, audio, and fonts), RiveFiles, artboards, state machines, and view model instances.

The lifetime of the Rive worker reference created by this composable is managed by this composable. It releases that reference when it falls out of scope. The worker fully disposes once any other Rive resources that acquired it, such as files, assets, or surfaces, are also closed.

A Rive worker needs to be polled to receive messages from the command server. This composable creates a poll loop that runs while the Lifecycle is in the Lifecycle.State.RESUMED state. The poll rate is once per frame, which is typically 60 FPS.

This function throws a RuntimeException if the Rive worker cannot be created. If you want to handle failure gracefully, use rememberRiveWorkerOrNull instead.

Return

The created RiveWorker.

Parameters

autoPoll

Whether to automatically poll the worker while lifecycle is RESUMED.

tracingEnabled

Whether native draw/advance tracing is enabled for the worker.

renderBackend

Preferred render backend. OpenGL is used by default to preserve backward compatibility. Vulkan is available for higher performance and may become the default in a future release. If Vulkan is requested below Android API 29 / Android 10, or Vulkan native initialization fails, the worker falls back to OpenGL.

See also

Throws

If the Rive worker cannot be created for any reason.