From a0909efbec4481137a6f807f0bbd70e007392e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 29 Aug 2024 12:28:15 -0700 Subject: [PATCH] Move reporting of long tasks to before updating rendering (#46252) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46252 Changelog: [internal] The long task API should only account for work specifically done by the task. Updating the rendering shouldn't be considered for that, so this moves the determination of long tasks before doing that work. Reviewed By: sammy-SC, rshest Differential Revision: D61939261 fbshipit-source-id: 6d2573d561d507dff60b9703e4cc90ce4d131960 --- .../runtimescheduler/RuntimeScheduler_Modern.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp index 5821863f919..afb5a48769e 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp @@ -335,17 +335,17 @@ void RuntimeScheduler_Modern::runEventLoopTick( performMicrotaskCheckpoint(runtime); } - if (ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop()) { - // "Update the rendering" step. - updateRendering(); - } - if (ReactNativeFeatureFlags::enableLongTaskAPI()) { auto taskEndTime = now_(); markYieldingOpportunity(taskEndTime); reportLongTasks(task, taskStartTime, taskEndTime); } + if (ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop()) { + // "Update the rendering" step. + updateRendering(); + } + currentTask_ = nullptr; }