Open j-piasecki opened 2 hours ago
[!TIP] Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.3. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
[!TIP] Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
Description
Related to https://github.com/facebook/react-native/issues/38743
Transaction merging introduced in https://github.com/facebook/react-native/pull/44188 may cause
CREATE
mutations to be effectively dropped.When two transactions, where the first one contains a
DELETE
mutation for a view with a view tagX
and the other contains aCREATE
mutation for a view with a view tagX
, get merged the result is a transaction containing both mutations. When that transaction is executed, theDELETE
operations are run afterCREATE
operations, so the view will not exist after the transaction finishes which results in the host tree diverging from the shadow tree.Inside
FabricUIManagerBinding
pendingTransactions_
field tracks transactions to be executed but only one per surface: https://github.com/facebook/react-native/blob/a6b2355b8d559aba2f1f13394c91f563f9b9e1a4/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h#L164-L166Inside
schedulerDidFinishTransaction
transactions are merged when a transaction for a given surface is already pending: https://github.com/facebook/react-native/blob/a6b2355b8d559aba2f1f13394c91f563f9b9e1a4/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp#L546-L550If instead of merging transactions into one, multiple ones could be queued for a single surface and executed in order, the issue would be fixed. I can open a PR with that change but before that, I'd like to know whether that could have any unwanted side effects, as I'm lacking context on why merging was chosen there.
It also seems like this may be a known problem: https://github.com/facebook/react-native/blob/69356b7f2144283fa6be7e9998e25a0681e159f0/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp#L828-L829
Steps to reproduce
Click this first
buttonClick this second
buttonReact Native Version
0.76.2
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://snack.expo.dev/@jpiasecki/unable_to_find_viewstate_repro
Screenshots and Videos
https://github.com/user-attachments/assets/7df6bc47-a741-48cc-85e3-398239415b11