Avoid copying surface props when starting or updating a surface - #57813
Open
javache wants to merge 2 commits into
Open
Avoid copying surface props when starting or updating a surface#57813javache wants to merge 2 commits into
javache wants to merge 2 commits into
Conversation
…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
|
@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114730310. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
SurfaceHandleralready takes a throwaway snapshot of itsParametersunderparametersMutex_before handing them to theUIManager, butUIManager::startSurfaceandUIManager::setSurfacePropstookmoduleNameandpropsby const reference and then copy-captured them into the lambda posted to theRuntimeExecutor. 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
SurfaceHandlercall 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::startSurfaceandUIManager::setSurfacePropsnow takemoduleNameandpropsby valueDifferential Revision: D114730310