Rive Android Bug Report: Property Observer Not Triggering on Rive Component Listener

Environment Details

  • Rive version: `10.5.0` (app.rive:rive-android:10.5.0)

  • Android Jetpack Compose version: `1.5.8` (androidx.compose version)

  • Kotlin version: `2.0.21`

  • Android Gradle Plugin: `8.13.0`

Bug Description

Issue 1: Property Observer Not Triggering on Rive Component Listener

The Rive file has three Rive button components, each with a Listener (configured in the Rive editor) that sets the value of the "selection" property. However, interacting with these Rive components does not trigger the observer to indicate that the `selection` value has changed.

Exception:

  • If we make the `selection` visible as part of the animation itself (i.e., the selection property is displayed in the Rive animation), then the observer does trigger and detects the property change.

  • If we trigger a state change by setting another property first (e.g., setting `choice1_text` programmatically), and then interact with a Rive component Listener that sets `selection`, the selection observer will trigger ONCE but then stop working. Subsequent interactions with Rive component Listeners will not trigger the observer anymore.

Issue 2: Property Changes Don't Auto-Play Despite Listener Detection

Although `autoplay` is set to `true`, when setting a property string value programmatically, it does not auto-play the change even though the listener indicates that it has detected the property change.


Code Implementation

Important: Our implementation follows the exact same patterns used in the official Rive examples:

  • MultiTouchActivity (rive-android-master/app/src/main/java/app/rive/runtime/example/MultiTouchActivity.kt) - Uses `lifecycleScope.launch` with `repeatOnLifecycle`

  • ComposeActivity (rive-android-master/app/src/main/java/app/rive/runtime/example/ComposeActivity.kt) - Uses `collectAsState()` for property observation

  • Reference: https://rive.app/docs/runtimes/data-binding#observability


The following code shows snippet of how we're observing the `selection` property using these same approaches:

Approach 1: Using `collectAsState()` - Following ComposeActivity Pattern

@Composable
fun RiveZStackExperimentScreen() {
    var vmi by remember { mutableStateOf<ViewModelInstance?>(null) }
    
    // ... file loading code ...
    
    AndroidView(
        factory = { ctx ->
            val builder = RiveAnimationView.Builder(ctx)
                .setResource(data)
                .setArtboardName(ARTBOARD_NAME)
                .setAutoplay(true)
                .setAutoBind(true)
            
            builder.build().apply {
                doOnAttach {
                    val instance = stateMachines.first().viewModelInstance!!
                    vmi = instance
                    
                    // Apply bindings
                    THREE_CHOICE_PROPERTIES.forEach { (key, value) ->
                        instance.getStringProperty(key).value = value
                    }
                }
            }
        },
        modifier = Modifier.fillMaxSize()
    )
    
    // Observe selection property - matches ComposeActivity pattern
    vmi?.let { instance ->
        val selectionProperty = remember(instance) { instance.getStringProperty("selection") }
        val selectionValue by selectionProperty.valueFlow.collectAsState()
        
        LaunchedEffect(selectionValue) {
            // This should trigger when Rive component Listener sets selection, but doesn't
        }
        
        PropertyRow("Selection", selectionValue)
    }

Approach 2: Using `lifecycleScope.launch` with `repeatOnLifecycle` - Following MultiTouchActivity Pattern

builder.build().apply {
    doOnAttach {
        val lifecycleOwner = findViewTreeLifecycleOwner() ?: return@doOnAttach
        val instance = stateMachines.first().viewModelInstance!!
        vmi = instance
        
        val collectJob = lifecycleOwner.lifecycleScope.launch {
            lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
                // Observe selection property - matches MultiTouchActivity pattern
                launch {
                    val property = instance.getStringProperty("selection")
                    property.valueFlow.collect { value ->
                        selectionState.value = selectionState.value + ("selection" to value)
                        // This should trigger when Rive component Listener sets selection, but doesn't
                    }
                }
            }
        }
        doOnDetach { collectJob.cancel() }
    }
}


Setting Property Values Programmatically

// Setting property - listener detects change, but animation doesn't auto-play
vmi?.let { instance ->
    instance.setString("choice1_text", newText)
    // Property change is detected, but autoplay doesn't trigger animation
}

Expected Behavior

  • When a Rive component (with a Listener configured in the Rive editor) is interacted with and triggers its listener to set `selection`:

    • The `valueFlow.collectAsState()` or `property.valueFlow.collect { }` should immediately detect the change

    • The UI should update to reflect the new `selection` value

  • When a property is set programmatically:

    • The animation should auto-play if `autoplay` is enabled

    • Property observers should detect the change


Actual Behavior

1. Rive component Listener → No observer trigger: Interacting with Rive components that have Listeners (configured in Rive editor) that set `selection` does NOT trigger the observer, unless the `selection` property is made visible in the animation itself.

2. Programmatic property change → No auto-play: Setting a property value programmatically is detected by the listener, but the animation does not auto-play the change despite `autoplay = true`.


Screen Recording 2025-10-29 at 17.07.02.mov


Screen Recording 2025-10-29 at 17.08.45.mov