fix: reset StartupLogger on JS reload so runJsBundleStart marker is recorded#56616
Conversation
…ecorded (facebook#56339) PR facebook#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.
|
Hi @mohanrajvenkatesan2304-hash! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D102561906. |
Summary:
This is a regression in 0.83 from PR #54255, which made
StartupLoggerreset itself whenAPP_STARTUP_STARTfires. On JS reload,RUN_JS_BUNDLE_STARTandINIT_REACT_RUNTIME_STARTarrive first and are rejected as duplicates by the still-populated logger; only afterward doesAPP_STARTUP_STARTfire and clear the state. The result is NaN start times paired with valid end times, soperformance.measure('runJsBundle', 'runJsBundleStart', 'runJsBundleEnd')throwsThe mark 'runJsBundleStart' does not exist.on every reload after the first load.The fix is to pre-emptively call
StartupLogger::reset()at the top ofReactInstance::loadScriptso every load (including reloads) starts with a clean logger and the startup markers are recorded correctly each time.Fixes #56339.
Changelog:
[GENERAL] [FIXED] - Reset StartupLogger on JS reload so
runJsBundleStartperformance marker is recorded after the first loadTest Plan:
performance.measure('runJsBundle', 'runJsBundleStart', 'runJsBundleEnd')succeeds; press R to reload, measure succeeds again instead of throwingThe mark 'runJsBundleStart' does not exist.clang-format -i packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp— no diffyarn install; see commit for the C++-only nature of the change.