diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index 018cf745ee5..b4b5e908fdb 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -167,12 +167,6 @@ class UIManager final : public ShadowTreeDelegate { ShadowTreeRegistry shadowTreeRegistry_{}; BackgroundExecutor backgroundExecutor_{}; - // Used only when BackgroundExecutor is enabled. - // Property is used to keep count of `completeRoot` events to - // determine whether a commit should be cancelled. Only to be used - // inside UIManagerBinding. - std::atomic_uint_fast8_t completeRootEventCounter_{0}; - mutable better::shared_mutex commitHookMutex_; mutable std::vector commitHooks_; diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index e21cb7a2512..4c808002b7d 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -452,20 +452,18 @@ jsi::Value UIManagerBinding::get( auto surfaceId = surfaceIdFromValue(runtime, arguments[0]); auto shadowNodeList = shadowNodeListFromValue(runtime, arguments[1]); - - sharedUIManager->completeRootEventCounter_ += 1; + static std::atomic_uint_fast8_t completeRootEventCounter{0}; + completeRootEventCounter += 1; sharedUIManager->backgroundExecutor_( [sharedUIManager, surfaceId, shadowNodeList, - eventCount = - sharedUIManager->completeRootEventCounter_.load()] { - auto shouldCancel = [eventCount, sharedUIManager]() -> bool { - // If `eventCounter_` was incremented, another + eventCount = completeRootEventCounter.load()] { + auto shouldCancel = [eventCount]() -> bool { + // If `completeRootEventCounter` was incremented, another // `completeSurface` call has been scheduled and current // `completeSurface` should be cancelled. - return sharedUIManager->completeRootEventCounter_ > - eventCount; + return completeRootEventCounter > eventCount; }; sharedUIManager->completeSurface( surfaceId, shadowNodeList, {true, shouldCancel});