Skip to content

Fix LayoutAnimation crash from mutation sort ordering#56629

Closed
fkgozali wants to merge 1 commit into
react:mainfrom
fkgozali:export-D102696875
Closed

Fix LayoutAnimation crash from mutation sort ordering#56629
fkgozali wants to merge 1 commit into
react:mainfrom
fkgozali:export-D102696875

Conversation

@fkgozali

@fkgozali fkgozali commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary:
LayoutAnimationDriver::animationMutationsForFrame was sorting animation-frame Update mutations together with structural mutations (Remove/Insert/Delete) from completed animations. Animation-frame Updates reference views by their pre-structural-change parentTag. When std::stable_sort reordered these Updates after Remove/Insert pairs that reparented a view, StubViewTree::mutate hit a parentTag mismatch assertion (react_native_assert(oldStubView->parentTag == mutation.parentTag)) and crashed with SIGABRT.

The fix records the boundary between animation-frame Updates and final structural mutations, then only sorts the structural portion. This preserves the invariant that animation-frame Updates execute before any structural changes.

Per zeyap's review: simplified to just the LayoutAnimationDriver.cpp change. The earlier MutationComparator (Update < Insert) tweak and the TEST_F + feature-flag test refactor were dropped — the driver-side fix alone unbreaks the failing test.

Changelog: [Internal]

Differential Revision: D102696875

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 28, 2026
@meta-codesync

meta-codesync Bot commented Apr 28, 2026

Copy link
Copy Markdown

@fkgozali has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102696875.

Summary:
`LayoutAnimationDriver::animationMutationsForFrame` was sorting animation-frame Update mutations together with structural mutations (Remove/Insert/Delete) from completed animations. Animation-frame Updates reference views by their pre-structural-change parentTag. When `std::stable_sort` reordered these Updates after Remove/Insert pairs that reparented a view, `StubViewTree::mutate` hit a parentTag mismatch assertion (`react_native_assert(oldStubView->parentTag == mutation.parentTag)`) and crashed with SIGABRT.

The fix records the boundary between animation-frame Updates and final structural mutations, then only sorts the structural portion. This preserves the invariant that animation-frame Updates execute before any structural changes.

Per zeyap's review: simplified to just the LayoutAnimationDriver.cpp change. The earlier MutationComparator (`Update < Insert`) tweak and the `TEST_F` + feature-flag test refactor were dropped — the driver-side fix alone unbreaks the failing test.

Changelog: [Internal]

Differential Revision: D102696875
@fkgozali fkgozali force-pushed the export-D102696875 branch from e869f82 to b660c0f Compare April 28, 2026 17:20
@meta-codesync meta-codesync Bot closed this in 6ec4597 Apr 30, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 30, 2026
@meta-codesync

meta-codesync Bot commented Apr 30, 2026

Copy link
Copy Markdown

This pull request has been merged in 6ec4597.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @fkgozali in 6ec4597

When will my fix make it into a release? | How to file a pick request?

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants