Skip to content

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

Closed
javache wants to merge 1 commit into
react:mainfrom
javache:export-D114730310
Closed

Avoid copying surface props when starting or updating a surface (#57813)#57813
javache wants to merge 1 commit 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

Reviewed By: zeyap, christophpurrer

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.

…t#57813)

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

Reviewed By: zeyap, christophpurrer

Differential Revision: D114730310
@meta-codesync meta-codesync Bot changed the title Avoid copying surface props when starting or updating a surface Avoid copying surface props when starting or updating a surface (#57813) Aug 7, 2026
@javache
javache force-pushed the export-D114730310 branch from 2d92d63 to 89fa597 Compare August 7, 2026 09:49
@meta-codesync meta-codesync Bot closed this in 85a8181 Aug 7, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Aug 7, 2026
@meta-codesync

meta-codesync Bot commented Aug 7, 2026

Copy link
Copy Markdown

This pull request has been merged in 85a8181.

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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant