Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions android/src/new/java/com/rive/RiveReactNativeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
private var surfaceHeight = 0

private var renderLoopRunning = false
private var disposed = false
private var lastFrameTimeNs = 0L
private var frameCount = 0L

Expand Down Expand Up @@ -112,7 +113,7 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {

private val renderCallback = object : Choreographer.FrameCallback {
override fun doFrame(frameTimeNanos: Long) {
if (!renderLoopRunning) return
if (!renderLoopRunning || disposed) return

val deltaTime = if (lastFrameTimeNs == 0L) {
Duration.ZERO
Expand All @@ -136,7 +137,9 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
}
}

Choreographer.getInstance().postFrameCallback(this)
if (!disposed) {
Choreographer.getInstance().postFrameCallback(this)
}
}
}

Expand Down Expand Up @@ -366,13 +369,17 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
}

fun dispose() {
disposed = true
RiveErrorLogger.removeListener(errorListener)
stopRenderLoop()
boundInstance?.close()
// Null handles to prevent any further draw calls.
// Don't close artboard/stateMachine/surface here — the command queue
// may still have a pending draw command that references them.
// Let them be cleaned up by GC instead.
boundInstance = null
artboard?.close()
artboard = null
riveSurface?.close()
artboardHandle = null
stateMachineHandle = null
riveSurface = null
}
}
Binary file added expo-example/assets/kanit_regular.ttf
Binary file not shown.
Binary file added expo55-example/assets/kanit_regular.ttf
Binary file not shown.
Loading