react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Add featureflag to not re-order mount items in FabricMountingManager

Open javache opened this issue 1 year ago • 2 comments

Summary: In https://github.com/facebook/react-native/pull/44188, we've started combining multiple transactions in a single transaction, to meet React's atomicity requirements, while also dealing with the constraints of Android's Fabric implementation.

This revealed a bug where in some scenarios (especially when using transitions), a node may be deleted and created during the same transaction. The current implementation of FabricMountingManager assumes it can safely reorder some operations, which it does to optimize the size of IntBufferBatch mount items. This is however incorrect and unsafe when multiple transactions are merged.

Example:

Differentiator output:

# Transaction 1
Remove #100 from #11
Delete #100

# Transaction 2
Create #100
Insert #100 into #11

FabricMountingManager output

Remove #100 from #11
Insert #100 into #11
Delete #100

Note that the create action is also skipped, because we only update allocatedViewTags after processing all mutations, leading FabricMountingManager to assume creation is not required.

This leads to an invalid state in SurfaceMountingManager, which will be surfaced as a crash in getViewState on the next mutation that interacts with these views.

Changelog: [Android][Fixed] Fix crash in getViewState when using suspense fallbacks.

Differential Revision: D63148523

javache avatar Sep 27 '24 15:09 javache

This pull request was exported from Phabricator. Differential Revision: D63148523

facebook-github-bot avatar Sep 27 '24 15:09 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D63148523

facebook-github-bot avatar Oct 26 '24 23:10 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D63148523

facebook-github-bot avatar Oct 28 '24 11:10 facebook-github-bot

This pull request has been merged in facebook/react-native@bd133b5dd57b18140eae51c6d7aaab02874455c1.

facebook-github-bot avatar Oct 28 '24 13:10 facebook-github-bot

This pull request was successfully merged by @javache in bd133b5dd57b18140eae51c6d7aaab02874455c1

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

react-native-bot avatar Oct 28 '24 13:10 react-native-bot