Skip to content

Compose API: no public way to know when a state machine finishes #467

Description

@oblakr24

Submission checklist

  • I have confirmed the issue is present in the latest version of rive-android
  • I have searched the documentation and forums and could not find an answer
  • I have searched existing issues and this is not a duplicate

Description

We show short Rive animations as TV overlays. When the animation finishes,
we remove the overlay from the screen. To know when it finishes, we need a
signal from the runtime.

What we did on 11.7.1

We collected RiveWorker.settledFlow and waited for our state machine's
handle. When it settled after our trigger fired, we removed the overlay.

What changed in 11.8.0

settledFlow is gone. The replacement, StateMachine.settled: StateFlow<Boolean>, is internal. So there is now no public way to know
that a state machine has finished.

We also can't use Rive events for this: our files fire an "eventDone" event,
but the Compose API has no way to listen to events (the legacy
RiveFileController.addEventListener does, but we migrated off the legacy
view).

Ask

One of these would unblock us:

  1. Make StateMachine.settled public. The docs on it are already written,
    and Rive() and RiveCanvasSession both use it internally.
  2. Or expose state machine events (like eventDone) in the Compose API,
    like the legacy listener API does.

We would rather not call the internal member through
@Suppress("INVISIBLE_MEMBER") or a Java bridge, so an official API would
be great.

Previous working version

11.7.1,

Reproduction steps / code

No response

Upload your reproduction files / stack trace

No response

Source .riv / .rev file

No response

Screenshots / video

No response

Rive Android runtime version

11.8.0

Rive API

Compose

Device

Any

Device OS

Any

App minimum SDK level

21

App target SDK level

36

App NDK level

No response

Other Rive runtimes affected

No response

Dependencies with native libraries

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions