From 9813abc3e1c9474da7a431076807cb12a57003f1 Mon Sep 17 00:00:00 2001 From: Mohanraj Venkatesan Date: Mon, 27 Apr 2026 11:31:52 +0530 Subject: [PATCH] fix: reset StartupLogger on JS reload so runJsBundleStart marker is recorded (#56339) PR #54255 (which made StartupLogger reset on APP_STARTUP_START) introduced a regression in 0.83 where the `runJsBundleStart` performance marker is dropped on JS reload. On reload, RUN_JS_BUNDLE_START and INIT_REACT_RUNTIME_START fire and are rejected by the still-populated StartupLogger as duplicates; only afterward does APP_STARTUP_START fire and reset the logger, leaving NaN start times paired with valid end times. As a result `performance.measure('runJsBundle', 'runJsBundleStart', 'runJsBundleEnd')` throws "The mark 'runJsBundleStart' does not exist." after the first load. Pre-emptively call StartupLogger::reset() at the top of ReactInstance::loadScript so every load (including reloads) starts with a clean logger and the startup markers are recorded correctly each time. --- .../ReactCommon/react/runtime/ReactInstance.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 0e792803be4..f75350089ec 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -248,6 +248,12 @@ void ReactInstance::loadScript( beforeLoad(runtime); } TraceSection s("ReactInstance::loadScript"); + // Reset the StartupLogger so that JS reloads re-record all START/STOP + // timings. Without this, the APP_STARTUP_START handler resets the logger + // mid-sequence (after RUN_JS_BUNDLE_START / INIT_REACT_RUNTIME_START have + // already been rejected as duplicates), leaving NaN start times paired + // with valid end times. See issue #56339. + ReactMarker::StartupLogger::getInstance().reset(); bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl != nullptr); if (hasLogger) { ReactMarker::logTaggedMarkerBridgeless(