Skip to content

Native crash on mount when using dataBind with ViewModel state machine value-change actions in .riv files #428

@klock-enginio

Description

@klock-enginio

Bug: Native crash on mount when using dataBind with ViewModel state machine value-change actions

Description

Binding a ViewModel instance to RiveView via dataBind causes a native crash on mount whenever the loaded .riv file contains state machine ViewModel value-change actions.

The crash happens during file initialization regardless of whether those actions are reachable from the initial state, and cannot be caught by a React error boundary.


Provide a repro

Minimal code reproduction

function RivePreview() {
  const { riveFile } =
    useRiveFile(require('./vm_value_change_test.riv'));
  const [instance, setInstance] = useState(null);

  useEffect(() => {
    if (!riveFile) return;
    let cancelled = false;

    (async () => {
      const vm = await riveFile.viewModelByNameAsync("TextModel");
      const inst = await vm?.createDefaultInstanceAsync();
      if (!cancelled) setInstance(inst ?? null);
    })();

    return () => {
      cancelled = true;
    };
  }, [riveFile]);

  if (!riveFile || !instance) return null;

  // Crashes on mount if .riv contains state machine ViewModel value-change actions
  return <RiveView file={riveFile} dataBind={instance} />;
}

Steps to reproduce

  1. Load a .riv file whose state machine contains ViewModel value-change actions.
  2. Create a ViewModel instance via the async API and pass it via dataBind.
  3. Native crash occurs during mount. No JS exception is thrown.

Expected behavior

When a ViewModel instance is bound via dataBind, state machine ViewModel value-change actions should apply to the bound instance without causing a native crash.


Actual behavior

  • App crashes natively during mount
  • No JavaScript error is thrown
  • React ErrorBoundary does not catch the crash

Things confirmed NOT to prevent the crash

  • autoPlay={false}
  • Moving the action to a state disconnected from the initial state
  • Using async API (viewModelByNameAsync / createDefaultInstanceAsync) instead of useViewModelInstance
  • Wrapping in a React ErrorBoundary
  • Not calling any JS-side setters

Removing the ViewModel value-change actions from the state machine in the Rive editor eliminates the crash entirely.


Source .riv / .rev files

A ZIP containing both the runtime .riv and the editor .rev file will be attached.
vm_value_change_test.zip


Device & versions

  • Device: iPhone 13 Pro Max (physical device)
  • OS: iOS 26.3.1
  • React Native: 0.83.6
  • Expo: 55.0.17
  • @rive-app/react-native: 0.4.6

Additional context

The JavaScript side completes successfully: the .riv file loads, the ViewModel instance is created, and RiveView mounts before the native crash occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions