diff --git a/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp b/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp index e9059dac7137c8..86c3a03c9df5bf 100644 --- a/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp +++ b/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp @@ -53,9 +53,13 @@ void StartupLogger::logStartupEvent( double markerTime) { switch (markerId) { case ReactMarkerId::APP_STARTUP_START: - if (std::isnan(appStartupStartTime)) { - appStartupStartTime = markerTime; + if (!std::isnan(appStartupStartTime)) { + // We had a startup start time, which indicates a warm start (user + // closed the app and start again). In this case we need to invalidate + // all other startup timings. + reset(); } + appStartupStartTime = markerTime; return; case ReactMarkerId::APP_STARTUP_STOP: @@ -93,6 +97,15 @@ void StartupLogger::logStartupEvent( } } +void StartupLogger::reset() { + appStartupStartTime = std::nan(""); + appStartupEndTime = std::nan(""); + initReactRuntimeStartTime = std::nan(""); + initReactRuntimeEndTime = std::nan(""); + runJSBundleStartTime = std::nan(""); + runJSBundleEndTime = std::nan(""); +} + double StartupLogger::getAppStartupStartTime() { return appStartupStartTime; } diff --git a/packages/react-native/ReactCommon/cxxreact/ReactMarker.h b/packages/react-native/ReactCommon/cxxreact/ReactMarker.h index 8d3a532e2c4e0d..e50746780d4867 100644 --- a/packages/react-native/ReactCommon/cxxreact/ReactMarker.h +++ b/packages/react-native/ReactCommon/cxxreact/ReactMarker.h @@ -74,6 +74,7 @@ class RN_EXPORT StartupLogger { static StartupLogger& getInstance(); void logStartupEvent(const ReactMarkerId markerName, double markerTime); + void reset(); double getAppStartupStartTime(); double getInitReactRuntimeStartTime(); double getInitReactRuntimeEndTime();