Skip to content

fix(android): animation freezes when file has ViewModels but no artboard default#195

Closed
mfazekas wants to merge 4 commits intomainfrom
fix/android-auto-databind-no-default-viewmodel
Closed

fix(android): animation freezes when file has ViewModels but no artboard default#195
mfazekas wants to merge 4 commits intomainfrom
fix/android-auto-databind-no-default-viewmodel

Conversation

@mfazekas
Copy link
Collaborator

@mfazekas mfazekas commented Mar 26, 2026

Fixes #189.

In Auto dataBind mode, Android passed autoBind=true to setRiveFile whenever viewModelCount > 0. If the artboard had no default ViewModel assigned, the Rive SDK threw "No default ViewModel found for artboard", freezing the animation.

Fix: always pass autoBind=false for Auto mode and let bindToStateMachine handle binding — it already catches ViewModelException gracefully when no default ViewModel exists.

Reproducer

.riv file: https://rive.app/community/files/27026-50856-no-default-vm-for-artboard/

import { View, StyleSheet, Text } from 'react-native';
import { RiveView, useRiveFile } from '@rive-app/react-native';

export default function Issue189Page() {
  const { riveFile, error } = useRiveFile(
    require('./nodefaultbouncing.riv')
  );

  return (
    <View style={styles.container}>
      {error != null && (
        <Text style={styles.errorText}>Error: {String(error)}</Text>
      )}
      {riveFile && (
        <RiveView
          file={riveFile}
          autoPlay={true}
          // No dataBind prop — defaults to Auto. On Android (unfixed) this
          // triggers "No default ViewModel found for artboard" and freezes.
          style={styles.rive}
        />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1 },
  errorText: { color: 'red', textAlign: 'center', padding: 8 },
  rive: { flex: 1, width: '100%' },
});

Expected: bouncing animation plays normally on both platforms.
Actual (Android, unfixed): animation freezes, ViewModelInstanceNotFound error fired via onError.

Legacy addListener does NOT emit on subscribe — only on changes.
Without this, hooks stayed undefined forever if the value never changed.
Now the effect reads property.value synchronously when subscribing,
then the listener handles subsequent updates.
@mfazekas mfazekas requested a review from HayesGordon March 26, 2026 13:07
@mfazekas
Copy link
Collaborator Author

Superseded by a clean PR rebased on main.

@mfazekas mfazekas closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android [RIVE] HybridRiveView afterUpdate No default ViewModel found for artboard error

1 participant