Skip to content

Commit 9ade236

Browse files
committed
Fix "0x1 not found" error when artboard has no default ViewModel on Android
When auto-binding, cppDefaultVMCreateDefaultVMI returns handle 1L (null sentinel) if the artboard has no default ViewModel. Guard against passing this sentinel to bindViewModelInstance.
1 parent 3773f79 commit 9ade236

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

android/src/experimental/java/com/rive/RiveReactNativeView.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
284284
val art = artboard ?: return@withContext
285285
val source = ViewModelSource.DefaultForArtboard(art).defaultInstance()
286286
val instance = ViewModelInstance.fromFile(riveFile, source)
287+
// A handle of 1L is the C++ null sentinel — the artboard has ViewModels but
288+
// none is set as the default, so binding would fire "instance 0x1 not found".
289+
if (instance.instanceHandle.handle == 1L) {
290+
Log.d(TAG, "Auto-binding skipped: no default ViewModel for artboard")
291+
return@withContext
292+
}
287293
boundInstance = instance
288294
bindInstanceToStateMachine(instance)
289295
}

0 commit comments

Comments
 (0)