Skip to content

fix: support clearing image and artboard properties on the new runtime - #360

Open
mfazekas wants to merge 2 commits into
mainfrom
claude/android-compose-image-null-7cee4c
Open

fix: support clearing image and artboard properties on the new runtime#360
mfazekas wants to merge 2 commits into
mainfrom
claude/android-compose-image-null-7cee4c

Conversation

@mfazekas

Copy link
Copy Markdown
Collaborator

ViewModelImageProperty.set and ViewModelArtboardProperty.set are typed to accept undefined — the artboard one is even documented as "pass undefined to clear" — but both new-runtime backends dropped it. The iOS image property threw Invalid image type - expected HybridRiveImage, and the iOS artboard and Android artboard properties returned silently. Passing undefined now clears the property. Both legacy backends already handled this correctly.

Android image clearing stays a no-op for now: ViewModelInstance.setImage only accepts a non-null ImageAsset up to rive-android 11.7.2. The nullable overload landed upstream in rive-app/rive-android#13261 and ships in the next release — until we bump the pin the call is logged rather than silently dropped. Swapping the log for setImage(path, null) is the whole follow-up.

Setting an image (and instantiating an artboard) is asynchronous on both new backends, so a slow decode could land after a later set() and resurrect a stale value — including overwriting a clear. Both properties now carry a generation counter and drop outdated completions.

Verification: built and ran the example on the iOS simulator against the new runtime (RiveRuntime 6.21.1). imageProperty.set(undefined) no longer throws — that call is a hard error on main — and artboardProperty.set(undefined) runs clean with no crash. I could not visually confirm the slot actually empties: neither databinding_images.riv nor many_viewmodels.riv gives a usable visual channel, since the bound image slot renders its authored image regardless. Worth confirming against a .riv authored for this, and re-checking once the runtimes that support clearing ship.

Adds example/src/reproducers/ClearImageAndArtboard.tsx for manual checks, plus a harness case for imageProperty.set(undefined) which fails on the unfixed iOS build.

mfazekas added 2 commits July 29, 2026 20:18
`ViewModelImageProperty.set` and `ViewModelArtboardProperty.set` are typed to
accept `undefined`, but both new-runtime backends dropped it: the iOS image
property threw "Invalid image type", and the iOS artboard and Android artboard
properties returned silently. Passing `undefined` now clears the property.

Android image clearing stays a no-op for now — `ViewModelInstance.setImage`
only accepts a non-null `ImageAsset` up to rive-android 11.7.2. The nullable
overload landed upstream in rive-app/rive-android#13261 and ships in the next
release; the call is logged instead of silently dropped until we bump the pin.

Setting an image (and instantiating an artboard) is asynchronous, so a slow
decode could previously land after a later `set()` and resurrect a stale value.
Both properties now carry a generation counter and drop outdated completions.
The name said it verified clearing; it only asserts that set(undefined) does
not throw, which is all the API allows — image properties are write-only and
addListener is a no-op on both new backends. On Android's new backend it passes
because the call is deliberately dropped, so green must not be read as
'clearing works'.
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.

1 participant