Skip to content

Commit b646413

Browse files
committed
fix: yoga crash with display:none
1 parent 066c0d8 commit b646413

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,18 @@ static float computeFlexBasisForChildren(
615615
for (auto child : children) {
616616
child->processDimensions();
617617
if (child->style().display() == Display::None) {
618-
zeroOutLayoutRecursively(child);
619-
child->setHasNewLayout(true);
620-
child->setDirty(false);
618+
// Only mutate display: none children during layout passes. Zeroing them
619+
// out during measure-only passes contributes nothing to the measurement,
620+
// but sets `hasNewLayout` on nodes the parent's layout pass may never
621+
// visit (e.g. when its layout is restored from cache, skipping
622+
// `cloneChildrenIfNeeded()`). Such a leaked flag survives the commit and
623+
// is copied into lazily-shared clones, later tripping the ownership
624+
// assertion in `YogaLayoutableShadowNode::layout`.
625+
if (performLayout) {
626+
zeroOutLayoutRecursively(child);
627+
child->setHasNewLayout(true);
628+
child->setDirty(false);
629+
}
621630
continue;
622631
}
623632
if (performLayout) {

0 commit comments

Comments
 (0)