Files
react-native/packages
Jakub Piasecki d80377cd60 Replace merge commit scheduling with a run loop observer (#56726)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56726

Changelog: [IOS][CHANGED] - Drain React-revision merges from a `BeforeWaiting` main run loop observer instead of dispatching each merge as a separate main-queue block

With Fabric commit branching (`enableFabricCommitBranching`), React commits land on a forked `currentReactRevision_` and are merged into the main branch later via `ShadowTree::mergeReactRevision()`. On iOS, the `schedulerShouldMergeReactRevision:` callback used to do a plain `RCTExecuteOnMainQueue` per promotion, so every promotion enqueued a fresh main queue block that competed for ordering with mount blocks dispatched from concurrent commits with `mountSynchronously=true`.

Instead of dispatching each merge as its own main-queue block, enqueue the surface id into an `unordered_set<SurfaceId>` and drain it from a `MainRunLoopObserver` registered at `kCFRunLoopBeforeWaiting`. The merge calls `ShadowTree::commit(..., mountSynchronously = true)`, so the mount completes inline before the observer returns.

A similar mechanism has already been implemented on Android in D100966623

Reviewed By: javache

Differential Revision: D104227839

fbshipit-source-id: 94953290fad3e65f038846ba81e05591756864a8
2026-05-11 04:04:40 -07:00
..