Skip to content

Avoid copying surface props when starting or updating a surface - #57813

Open
javache wants to merge 2 commits into
react:mainfrom
javache:export-D114730310
Open

Avoid copying surface props when starting or updating a surface#57813
javache wants to merge 2 commits into
react:mainfrom
javache:export-D114730310

Conversation

@javache

@javache javache commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary:
SurfaceHandler already takes a throwaway snapshot of its Parameters under parametersMutex_ before handing them to the UIManager, but UIManager::startSurface and UIManager::setSurfaceProps took moduleName and props by const reference and then copy-captured them into the lambda posted to the RuntimeExecutor. That forced a second deep copy of the props tree — which for a real surface holds the initial route params and deep link data — on every surface start, prop update, and display mode change.

Take both by value and move them into the lambda, and move at the SurfaceHandler call sites, so the snapshot is handed off instead of duplicated. The snapshot is a local that is dead after the call, so there is nothing left to observe the moved-from state.

Changelog:
[General][Changed] - UIManager::startSurface and UIManager::setSurfaceProps now take moduleName and props by value

Differential Revision: D114730310

javache added 2 commits August 4, 2026 06:47
…eact#57812)

Summary:

The whole `PointerEventsProcessorTest` suite has been aborting in its fixture constructor since the `modernize-use-designated-initializers` codemod moved the `ContextContainer` into `ComponentDescriptorParameters`. The `shared_ptr` is read twice more afterwards — once to construct the `UIManager` and once to construct the `ShadowTree` — so the move left both with a null container and the second read tripped the libstdc++ null-deref assert.

Stop moving out of a `shared_ptr` that is still needed by later statements.

Changelog: [Internal]

___

Differential Revision: D114730311
Summary:
`SurfaceHandler` already takes a throwaway snapshot of its `Parameters` under `parametersMutex_` before handing them to the `UIManager`, but `UIManager::startSurface` and `UIManager::setSurfaceProps` took `moduleName` and `props` by const reference and then copy-captured them into the lambda posted to the `RuntimeExecutor`. That forced a second deep copy of the props tree — which for a real surface holds the initial route params and deep link data — on every surface start, prop update, and display mode change.

Take both by value and move them into the lambda, and move at the `SurfaceHandler` call sites, so the snapshot is handed off instead of duplicated. The snapshot is a local that is dead after the call, so there is nothing left to observe the moved-from state.

Changelog:
[General][Changed] - `UIManager::startSurface` and `UIManager::setSurfaceProps` now take `moduleName` and `props` by value

Differential Revision: D114730310
@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 Aug 4, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Aug 4, 2026
@meta-codesync

meta-codesync Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant