Repository navigation
fix: initialize the light tree from the base revision on attach - #10313
bartlomiejbloniarz merged 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change passes ChangesSurface initialization
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change initializes the light tree from the existing base revision before processing new transactions, addressing attach-time crashes without any actionable merge-blocking risk remaining after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant ReanimatedCommitHook
participant LayoutAnimationsProxy_Experimental
participant MountingCoordinator
participant LightTree
ReanimatedCommitHook->>LayoutAnimationsProxy_Experimental: startSurface(shadowTree)
LayoutAnimationsProxy_Experimental->>MountingCoordinator: getBaseRevision()
MountingCoordinator-->>LayoutAnimationsProxy_Experimental: base revision
LayoutAnimationsProxy_Experimental->>LightTree: apply base mutations
LayoutAnimationsProxy_Experimental->>LightTree: apply newer pending transactions
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pawicao
left a comment
There was a problem hiding this comment.
this looks good to me, i left a nit related to similarity of applyInitialMutationsToLightTree with updateLightTree and whether we should do something about it but I'm giving an approval anyway and will let you decide whether to handle that now, or defer it
tjzel
left a comment
There was a problem hiding this comment.
LGTM but I don't really know the deets about how light trees work
1f5b378 to
fa07fee
Compare
Summary
Fixes #9021.
The experimental layout-animations proxy builds its light tree only from the mutations it intercepts in
pullTransaction. When Reanimated initializes after a surface already has content (a lazyrequiredeep in the app), the tree starts empty. The next batch touches tags the tree never saw andupdateLightTreeaborts onLightNode not found.The fix is to take the base revision (the last commit before the attach) and build the light tree from it. Then carry on from pullTransaction. Some transactions may arrive while we are reading the base revision, but they are recorded and applied before we start the normal pullTransaction path.
Important design is that we set the delegate before the base revision is read. Every transaction is then on one of two paths: its pull finished before the read (its content is inside the base revision), or the delegate received it and recorded it in
pendingTransactions_with itsTransactionTelemetry::revisionNumber. Entries newer thanbase.numberare applied on top; older ones are already in the tree and are dropped. Nothing is lost, nothing applies twice.This is the new flow:
And here is a full (AI-assisted) analysis of possible thread interleavings
Here is the full AI document on the design and reasoning behind it. Attaching it mostly for future analysis if this turns out to be wrong:
light-tree-initialization.html
Test plan
Repro from #9021: an app that doesn't import reanimated lazily
requires it, then resizes a pre-existing view. Crashes on main (LightNode not found), works with this PR. Verified on iOS and Android.Also on both platforms: a stress run (commits every 16 ms while reanimated loads at a random moment, 12 relaunches each, no crashes) and the usual LA/SET examples — entering/exiting, layout transitions, shared elements - all unchanged.
Repro entry file
Replace
apps/fabric-example/index.jswith this, launch, tap "1. LoadReanimated", then "2. Grow pre-existing view" twice.