From cbfa2ecc9aabaf63d1e21e811e9f6bc5b0379250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiawei=20L=C3=BC?= Date: Wed, 21 May 2025 14:12:16 -0700 Subject: [PATCH] Revert D75006354: Remove JSExecutor::performanceNow() Differential Revision: D75006354 Original commit changeset: d41bf73238e9 Original Phabricator Diff: D75006354 fbshipit-source-id: 99c60268d8d829ff87a8486b0ca67a47bfb198b4 --- 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, 11 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp index ae47983f39b..ef6a44c0f12 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp @@ -27,6 +27,10 @@ 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 7106147cdd9..775e3971f58 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.h +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.h @@ -139,6 +139,8 @@ 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 9a1ce11b70a..39be0f0f055 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 HighResTimeStamp::now().toDOMHighResTimeStamp(); + return JSExecutor::performanceNow().toDOMHighResTimeStamp(); })); } diff --git a/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp b/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp index 7fa624f2924..d6ab76d20d8 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 HighResTimeStamp::now(); + return JSExecutor::performanceNow(); } 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 81324e7d212..17e9667fdc4 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, HighResTimeStamp::now()); + *rootShadowNode, JSExecutor::performanceNow()); if (entry) { { std::unique_lock lock(pendingEntriesMutex_); @@ -266,7 +266,7 @@ void IntersectionObserverManager::updateIntersectionObservations( } auto entry = observer->updateIntersectionObservation( - *rootShadowNode, HighResTimeStamp::now()); + *rootShadowNode, JSExecutor::performanceNow()); 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 0e5280f1b81..03ad43506bf 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 = HighResTimeStamp::now(); + auto time = JSExecutor::performanceNow(); auto rootShadowNode = RootShadowNode::Shared{}; shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree& shadowTree) {