From 6e50603faa60da106e1210b08eb84eaf322274e1 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Wed, 21 May 2025 11:56:22 -0700 Subject: [PATCH] Remove JSExecutor::performanceNow() (#51481) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51481 # Changelog: [Internal] This is replaced by `HighResTimeStamp::now()`, which is available in a dedicated smal `react/timing` module. Reviewed By: lenaic Differential Revision: D75006354 fbshipit-source-id: d41bf73238e9c6bf5c5a9509d60713ce11e6ea4a --- packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp | 4 ---- packages/react-native/ReactCommon/cxxreact/JSExecutor.h | 2 -- .../ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp | 2 +- .../react/nativemodule/webperformance/NativePerformance.cpp | 2 +- .../observers/intersection/IntersectionObserverManager.cpp | 4 ++-- .../ReactCommon/react/renderer/uimanager/UIManager.cpp | 2 +- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp index ef6a44c0f12..ae47983f39b 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp @@ -27,10 +27,6 @@ std::string JSExecutor::getSyntheticBundlePath( return buffer.data(); } -HighResTimeStamp JSExecutor::performanceNow() { - return HighResTimeStamp::now(); -} - jsinspector_modern::RuntimeTargetDelegate& JSExecutor::getRuntimeTargetDelegate() { if (!runtimeTargetDelegate_) { diff --git a/packages/react-native/ReactCommon/cxxreact/JSExecutor.h b/packages/react-native/ReactCommon/cxxreact/JSExecutor.h index 775e3971f58..7106147cdd9 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.h +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.h @@ -139,8 +139,6 @@ class RN_EXPORT JSExecutor { uint32_t bundleId, const std::string& bundlePath); - static HighResTimeStamp performanceNow(); - /** * Get a reference to the \c RuntimeTargetDelegate owned (or implemented) by * this executor. This reference must remain valid for the duration of the diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index 39be0f0f055..9a1ce11b70a 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -557,7 +557,7 @@ void bindNativePerformanceNow(Runtime& runtime) { const jsi::Value&, const jsi::Value* args, size_t /*count*/) { - return JSExecutor::performanceNow().toDOMHighResTimeStamp(); + return HighResTimeStamp::now().toDOMHighResTimeStamp(); })); } diff --git a/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp b/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp index d6ab76d20d8..7fa624f2924 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp @@ -117,7 +117,7 @@ NativePerformance::NativePerformance(std::shared_ptr jsInvoker) : NativePerformanceCxxSpec(std::move(jsInvoker)) {} HighResTimeStamp NativePerformance::now(jsi::Runtime& /*rt*/) { - return JSExecutor::performanceNow(); + return HighResTimeStamp::now(); } HighResTimeStamp NativePerformance::markWithResult( diff --git a/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserverManager.cpp b/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserverManager.cpp index 17e9667fdc4..81324e7d212 100644 --- a/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserverManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserverManager.cpp @@ -98,7 +98,7 @@ void IntersectionObserverManager::observe( if (!hasPendingTransactions) { auto entry = observer->updateIntersectionObservation( - *rootShadowNode, JSExecutor::performanceNow()); + *rootShadowNode, HighResTimeStamp::now()); if (entry) { { std::unique_lock lock(pendingEntriesMutex_); @@ -266,7 +266,7 @@ void IntersectionObserverManager::updateIntersectionObservations( } auto entry = observer->updateIntersectionObservation( - *rootShadowNode, JSExecutor::performanceNow()); + *rootShadowNode, HighResTimeStamp::now()); if (entry) { { std::unique_lock lock(pendingEntriesMutex_); diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index 03ad43506bf..0e5280f1b81 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -638,7 +638,7 @@ void UIManager::shadowTreeDidFinishTransaction( void UIManager::reportMount(SurfaceId surfaceId) const { TraceSection s("UIManager::reportMount"); - auto time = JSExecutor::performanceNow(); + auto time = HighResTimeStamp::now(); auto rootShadowNode = RootShadowNode::Shared{}; shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree& shadowTree) {