Repository navigation
Allocate Fabric native props storage on first use #60542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
| #include <react/cxxstableapi/UmbrellaGuard.h> | ||
|
|
||
| #include <atomic> | ||
| #include <memory> | ||
| #include <mutex> | ||
|
|
||
|
|
@@ -135,15 +136,6 @@ class ShadowNodeFamily final : public jsi::NativeState { | |
| std::shared_ptr<const Props> appliedProps = nullptr; | ||
| }; | ||
|
|
||
| /* | ||
| * Holds currently applied native props. `nullptr` if setNativeProps API is | ||
| * not used. It is used to backport setNativeProps API from the old | ||
| * architecture and will be removed in the future. Guarded by | ||
| * `nativePropsMutex`. | ||
| */ | ||
| mutable std::unique_ptr<NativeProps_DEPRECATED> nativeProps_DEPRECATED; | ||
| mutable std::mutex nativePropsMutex; | ||
|
|
||
| /** | ||
| * @return tag for the ShadowNodeFamily. | ||
| */ | ||
|
|
@@ -161,6 +153,24 @@ class ShadowNodeFamily final : public jsi::NativeState { | |
| private: | ||
| friend ShadowNode; | ||
| friend State; | ||
| friend class UIManager; | ||
|
|
||
| /* | ||
| * Holds the props set with `setNativeProps`, which is backported from the | ||
| * old architecture and will be removed in the future. The first | ||
| * `setNativeProps` call on the family creates the holder, and the holder | ||
| * lives until the family is destroyed: clones use it through a raw pointer, | ||
| * so nothing may free or replace it earlier. `nativeProps` is guarded by | ||
| * `mutex`. | ||
| */ | ||
| struct NativePropsHolder { | ||
| std::mutex mutex; | ||
| std::unique_ptr<NativeProps_DEPRECATED> nativeProps; | ||
| }; | ||
|
|
||
| NativePropsHolder *getNativePropsHolder() const noexcept; | ||
| NativePropsHolder &getOrCreateNativePropsHolder() const; | ||
| mutable std::atomic<NativePropsHolder *> nativePropsHolder_{nullptr}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not store this as unique_ptr? so we can avoid the manual delete
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pointer is atomic so that a clone can check it without the lock while |
||
|
|
||
| /* | ||
| * Returns the most recent state if the given `state` is obsolete, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.