From f14a4d1eeab5e087e593be55cd96d1008a06f8eb Mon Sep 17 00:00:00 2001 From: AgustinMJ Date: Tue, 14 Jul 2026 17:56:24 +0200 Subject: [PATCH] Use std::mutex instead of never-shared std::shared_mutex in ShadowNodeFamily ShadowNodeFamily::mutex_ is declared std::shared_mutex but has not been acquired in shared mode since February 2020. All three call sites take it exclusively via unique_lock, and there is no shared_lock in the class. Of the 17 classes in ReactCommon that declare a std::shared_mutex, this is the only one that never takes a shared_lock. Reduces sizeof(ShadowNodeFamily) from 384 to 272 bytes on arm64 (-112, -29%). There is one family per host element, so this scales with tree size. Changelog: [GENERAL] [CHANGED] - Replace never-shared std::shared_mutex with std::mutex in ShadowNodeFamily --- .../ReactCommon/react/renderer/core/ShadowNodeFamily.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h index d32b4458c0b..898ae5bcdcf 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -145,7 +144,7 @@ class ShadowNodeFamily final : public jsi::NativeState { EventDispatcher::Weak eventDispatcher_; std::shared_ptr mostRecentState_; - mutable std::shared_mutex mutex_; + mutable std::mutex mutex_; std::function onUnmountedFamilyDestroyedCallback_ = nullptr;