fix: force-apply props when Fabric recreates a RiveView - #375
Open
mfazekas wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fabric can delete a component view and recreate it from the same, unchanged ShadowNode —
react-freezed screens (whatenableFreeze(true)uses) or a plaindisplay: 'none'toggle both trigger it. nitro 0.35's per-propisDirtyflags live on the shared Props object and were already consumed by the previous view instance, so the recreatedRiveViewstays blank: no file, no artboard, and the ref JS holds points at a dead view.This applies #365's fix through
nitrogen-postprocess.tssoyarn nitrogendoesn't wipe it: generatedupdatePropsforce-applies every prop the first time a view instance updates. The newview-recreate.harness.tsxfails on unpatched main (agameOvertrigger 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.