ViewModelInstanceTrigger.trigger() is silently swallowed by the State Machine when fired shortly ...
Environment
rive: 0.14.5
rive_native: 0.1.5
Renderer: Factory.rive (C++ backend)
Reproduced on iOS / iOS simulator (Flutter 3.x)
Summary A ViewModelInstanceTrigger.trigger() call issued shortly after the first RiveWidgetController.dataBind(DataBind.auto()) is silently dropped by the state machine. The trigger reaches the ViewModel layer — a listener attached via ViewModelInstanceTrigger.addListener fires every time — but the corresponding Idle → X state-machine transition does not run, even though the SM is verifiably in the source state of that transition.
The bug is asymmetric: triggers fired by the SM itself and observed in Dart (e.g. via addListener) work correctly. Only Dart-→-SM trigger fires are affected.
The bug is time-bound: after the SM has been ticking for ~1–2 s (we tick it from Dart by writing unrelated ViewModel properties every frame), the same trigger() call works reliably. Re-firing the trigger up to 10 times at 100 ms intervals immediately after dataBind does not unblock the SM.
Reproduction
Create an artboard Test with a state machine SM containing two states: Idle (default) and Active.
Add a ViewModel VM to the artboard, with one Trigger property named go.
In the SM: add a single transition Idle → Active whose only condition is the go trigger.
In Flutter:
final ctrl = RiveWidgetController( file, artboardSelector: ArtboardSelector.byName('Test'), stateMachineSelector: StateMachineSelector.byName('SM'), ); final vmi = ctrl.dataBind(DataBind.auto()); final go = vmi.trigger('go')!; go.addListener((_) => debugPrint('VM listener fired')); // ignore: deprecated_member_use, invalid_use_of_internal_member ctrl.stateMachine.onStateChanged((s) => debugPrint('state → $s')); // Render the widget, then fire after two post-frame callbacks: WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) { go.trigger(); }); });Observe the console.
Expected
state → Idle
VM listener fired
state → Active
Actual
state → Idle
VM listener fired
[no further state change]
Re-firing go.trigger() repeatedly produces additional VM listener fired lines but no state change. After ~2 s of unrelated ViewModel writes (e.g. setting another Number property periodically), the next go.trigger() fires the transition correctly.
Workaround Replacing the Trigger with a Number property (e.g. mode) and changing the transition condition to mode > 0 works reliably on the very first call.
Why this looks like a Rive bug, not a usage error
ViewModelInstanceTrigger.addListener confirms the trigger is observed on the VM side every single time.
onStateChanged confirms the SM is in Idle (the source state) when the trigger fires.
Idle → Active is the only outgoing transition and has no condition other than go.
A pure Number-property variant of the same setup works on the first call.