Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add featureflag to not re-order mount items in FabricMountingManager #46702

Closed
wants to merge 1 commit into from

Conversation

javache
Copy link
Member

@javache javache commented Sep 27, 2024

Summary:
In #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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Sep 27, 2024
@facebook-github-bot
Copy link
Contributor

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

javache added a commit to javache/react-native that referenced this pull request Oct 26, 2024
…acebook#46702)

Summary:

In facebook#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 facebook#100 from facebook#11
Delete facebook#100

# Transaction 2
Create facebook#100
Insert facebook#100 into facebook#11
```
FabricMountingManager output
```
Remove facebook#100 from facebook#11
Insert facebook#100 into facebook#11
Delete facebook#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
@facebook-github-bot
Copy link
Contributor

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

…acebook#46702)

Summary:
Pull Request resolved: facebook#46702

In facebook#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 facebook#100 from facebook#11
Delete facebook#100

# Transaction 2
Create facebook#100
Insert facebook#100 into facebook#11
```
FabricMountingManager output
```
Remove facebook#100 from facebook#11
Insert facebook#100 into facebook#11
Delete facebook#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.

Reviewed By: sammy-SC

Differential Revision: D63148523
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in bd133b5.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @javache in bd133b5

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

@javache javache deleted the export-D63148523 branch October 29, 2024 09:36
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. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants