File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/yoga/yoga/algorithm Expand file tree Collapse file tree Original file line number Diff line number Diff 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) {
You can’t perform that action at this time.
0 commit comments