Skip to content

fix: force-apply props when Fabric recreates a RiveView - #375

Open
mfazekas wants to merge 2 commits into
mainfrom
claude/i365-force-apply-first-update
Open

fix: force-apply props when Fabric recreates a RiveView#375
mfazekas wants to merge 2 commits into
mainfrom
claude/i365-force-apply-first-update

Conversation

@mfazekas

@mfazekas mfazekas commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Fabric can delete a component view and recreate it from the same, unchanged ShadowNode — react-freezed screens (what enableFreeze(true) uses) or a plain display: 'none' toggle both trigger it. nitro 0.35's per-prop isDirty flags live on the shared Props object and were already consumed by the previous view instance, so the recreated RiveView stays blank: no file, no artboard, and the ref JS holds points at a dead view.

This applies #365's fix through nitrogen-postprocess.ts so yarn nitrogen doesn't wipe it: generated updateProps force-applies every prop the first time a view instance updates. The new view-recreate.harness.tsx fails on unpatched main (a gameOver trigger fired after the hide/show cycle never reaches its listener) and passes with the patch; full iOS harness is green with it (29 suites, 209 tests). Android is unaffected — it never recreates the view — and its generated code is untouched.

nitro 0.37 fixes this properly by diffing old vs new props, but the bump (#372) is parked until the nitro-side issues it surfaced (glog modulemap break, margelo/nitro#1184) are fixed upstream. This shim and its injector are deleted with that bump.

Fabric deletes a component view when its subtree stops being mounted
(display: 'none', or a screen frozen by enableFreeze) and recreates it
from the same, unchanged ShadowNode. On iOS the recreated view is never
configured: nitro's isDirty prop flags live on the shared Props object
and the first view instance already consumed them, so the second one
never gets its file, stays blank, and the ref JS holds points at a dead
view.

Fails on iOS until the nitro bump; passes on Android, which recreates
nothing.
Fabric can delete a component view and recreate it from the same,
unchanged ShadowNode (react-freeze / Suspense re-inserting a hidden
screen, or a display:none toggle). Nitro 0.35 keeps per-prop isDirty
flags on the shared Props object and the previous view instance already
consumed them, so the recreated view applies nothing: no file, no
artboard, and a hybridRef that never fires. Force-apply every prop on a
view instance's first updateProps — the fix from #365, applied through
nitrogen-postprocess so yarn nitrogen doesn't wipe it.

Upstream nitro 0.37 fixes this properly by diffing old vs new props
(margelo/nitro#1503, #1506, #1510); this shim and its injector go away
with that bump, which lives in #372. Also gives
acceptNullForOptionalProps an early-exit guard so running the
postprocess twice no longer duplicates its patch.
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