fix(fabric): prevent Yoga layout assertion crash in RNGestureHandlerDetectorShadowNode - #4500
Conversation
…etectorShadowNode
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe layout method now stores computed bounding-box metrics and reuses them only when available. This removes the unconditional optional-value assertion during layout passes without a previous cached value. ChangesLayout metrics handling
Suggested reviewers: Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change prevents Fabric layout crashes when gesture-detector rows are dynamically inserted while preserving subsequent layout reuse. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
🟡 Changes recommended
The new reuse guard relies on previousLayoutMetrics_ semantics, but the clone constructor currently seeds it unconditionally (via getLayoutMetrics()), which can cause incorrect early-return reuse on first layout for cloned nodes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses a Fabric (New Architecture) crash in RNGestureHandlerDetectorShadowNode by removing a Yoga-layout-dependent assertion and introducing a safe fallback path when previous layout metrics are unavailable, preventing a SIGABRT during dynamic insertion of GestureDetector/ReanimatedSwipeable rows.
Changes:
- Avoids asserting on
previousLayoutMetrics_whenanyChildHasNewLayoutis false; reuses cached metrics only when present. - Computes detector bounding-box metrics as a fallback and caches them for subsequent unchanged layout passes.
File summaries
| File | Description |
|---|---|
| packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp | Reworks layout reuse/caching to prevent a null previousLayoutMetrics_ assertion crash and to cache computed bounding-box metrics. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // No child had its layout changed, we can reuse previous values if available | ||
| if (!anyChildHasNewLayout && previousLayoutMetrics_.has_value()) { | ||
| setLayoutMetrics(previousLayoutMetrics_.value()); | ||
| return; |
Description
Fixes #4241
Problem
When dynamically inserting \GestureDetector\ / \ReanimatedSwipeable\ rows into a layout on Fabric (such as inside a list or alongside BottomSheet), \�nyChildHasNewLayout\ can evaluate to false on initial layout passes if child Yoga subtrees have cached layouts. This caused
eact_native_assert(previousLayoutMetrics_.has_value())\ to fail, resulting in a \SIGABRT\ crash.
Solution
Fixes #4241