From 370fbaf1cd97540a50496aab477d17d90c257b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 29 Aug 2024 09:42:29 -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 --- .../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 5821863f9192..afb5a48769e0 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; }