Skip to content

YGNodeFree: mark parent dirty when child is freed#1969

Closed
harsha-cpp wants to merge 1 commit into
react:mainfrom
harsha-cpp:fix/ygnodefree-mark-parent-dirty
Closed

YGNodeFree: mark parent dirty when child is freed#1969
harsha-cpp wants to merge 1 commit into
react:mainfrom
harsha-cpp:fix/ygnodefree-mark-parent-dirty

Conversation

@harsha-cpp

Copy link
Copy Markdown
Contributor

fixes #1659.

problem: YGNodeFree called owner->removeChild(node) to detach the node from its
parent, but never called owner->markDirtyAndPropagate(). the parent's layout stayed
stale after the free, so a subsequent YGNodeCalculateLayout wouldn't recompute it.
YGNodeRemoveChild has always called markDirtyAndPropagateYGNodeFree was just
missing the same call.

YGNodeFreeRecursive was already correct for its recursive child removals (it calls
YGNodeRemoveChild internally), but the terminal YGNodeFree(root) inherited the bug.

fix: added owner->markDirtyAndPropagate() after node->setOwner(nullptr) in
YGNodeFree.

regression tests: dirty_parent_when_child_freed and dirty_parent_when_subtree_freed_recursive
in YGDirtyMarkingTest.cpp.

@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
yoga-website Ready Ready Preview, Comment Jun 7, 2026 2:35pm

Request Review

@meta-cla

meta-cla Bot commented Jun 7, 2026

Copy link
Copy Markdown

Hi @harsha-cpp!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@harsha-cpp

Copy link
Copy Markdown
Contributor Author

i have signed the CLA

@meta-cla meta-cla Bot added the CLA Signed label Jun 7, 2026
@harsha-cpp harsha-cpp force-pushed the fix/ygnodefree-mark-parent-dirty branch from 7b3194c to 473fc15 Compare June 7, 2026 14:34
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 7, 2026

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution

@meta-codesync

meta-codesync Bot commented Jun 8, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D107895988.

meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Jun 9, 2026
Summary:
fixes react/yoga#1659.

**problem:** `YGNodeFree` called `owner->removeChild(node)` to detach the node from its
parent, but never called `owner->markDirtyAndPropagate()`. the parent's layout stayed
stale after the free, so a subsequent `YGNodeCalculateLayout` wouldn't recompute it.
`YGNodeRemoveChild` has always called `markDirtyAndPropagate` — `YGNodeFree` was just
missing the same call.

`YGNodeFreeRecursive` was already correct for its recursive child removals (it calls
`YGNodeRemoveChild` internally), but the terminal `YGNodeFree(root)` inherited the bug.

**fix:** added `owner->markDirtyAndPropagate()` after `node->setOwner(nullptr)` in
`YGNodeFree`.

regression tests: `dirty_parent_when_child_freed` and `dirty_parent_when_subtree_freed_recursive`
in `YGDirtyMarkingTest.cpp`.

bypass-github-export-checks

## Changelog
[General][Changed] - mark parent dirty when child is freed

X-link: react/yoga#1969

Reviewed By: javache

Differential Revision: D107895988

Pulled By: cipolleschi

fbshipit-source-id: 5dce726e13147e8b7735bf72c441e80bb0c9b5a3
@meta-codesync meta-codesync Bot closed this in f6206ec Jun 9, 2026
@meta-codesync

meta-codesync Bot commented Jun 9, 2026

Copy link
Copy Markdown

@cipolleschi merged this pull request in f6206ec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Merged Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YGNodeFree does not mark parent as dirty

2 participants