From beb866626b6305f84da54a47f293411837bf991a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Such=C3=BD?= Date: Thu, 27 Aug 2026 21:06:11 +0200 Subject: [PATCH] fix(android): start the configured state machine when deferring autoplay The deferAutoPlay branch in configure() used the no-arg play(), which on a cold start also starts the artboard's first raw timeline animation. That timeline then draws over the data-bound state machine, showing the wrong state. Same bug class as #332, already fixed for the public play() in #343 - this applies the same explicit start to the internal call site. Co-Authored-By: Claude --- .../src/legacy/java/com/rive/RiveReactNativeView.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/android/src/legacy/java/com/rive/RiveReactNativeView.kt b/android/src/legacy/java/com/rive/RiveReactNativeView.kt index c07af64e..e448094b 100644 --- a/android/src/legacy/java/com/rive/RiveReactNativeView.kt +++ b/android/src/legacy/java/com/rive/RiveReactNativeView.kt @@ -149,7 +149,18 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) { // Create the state machine without advancing Entry transitions. // The first Choreographer frame will advance it with the user's // VM instance already bound via applyDataBinding() below. - riveAnimationView?.play(settleInitialState = false) + // + // Start the configured state machine explicitly: on a cold start the + // no-arg play() also starts the artboard's first raw timeline + // animation (same class of bug as #332), which plays on top of the + // data-bound state machine and shows the wrong state. + val smName = config.stateMachineName + ?: riveAnimationView?.controller?.activeArtboard?.stateMachineNames?.firstOrNull() + if (smName != null) { + riveAnimationView?.play(smName, isStateMachine = true, settleInitialState = false) + } else { + riveAnimationView?.play(settleInitialState = false) + } } _activeStateMachineName = getSafeStateMachineName() configuredStateMachineName = config.stateMachineName