Bug 1943586: Don't collect information in profiler_shutdown when we won't use it. a=dmeehan

Original Revision: https://phabricator.services.mozilla.com/D236346

Differential Revision: https://phabricator.services.mozilla.com/D237235
This commit is contained in:
Bob Owen 2025-02-07 20:23:56 +00:00
parent b6a806fdf1
commit 97dfb547ef

View file

@ -5889,8 +5889,13 @@ void profiler_shutdown(IsFastShutdown aIsFastShutdown) {
}
invoke_profiler_state_change_callbacks(ProfilingState::ShuttingDown);
const auto preRecordedMetaInformation =
PreRecordMetaInformation(/* aShutdown = */ true);
// We collect information here to be used below so it can be done outside of
// the lock. We only need it if MOZ_PROFILER_SHUTDOWN is set and not empty.
const char* filename = getenv("MOZ_PROFILER_SHUTDOWN");
PreRecordedMetaInformation preRecordedMetaInformation = {};
if (filename && filename[0] != '\0') {
preRecordedMetaInformation = PreRecordMetaInformation(/* aShutdown */ true);
}
ProfilerParent::ProfilerWillStopIfStarted();
@ -5902,7 +5907,6 @@ void profiler_shutdown(IsFastShutdown aIsFastShutdown) {
// Save the profile on shutdown if requested.
if (ActivePS::Exists(lock)) {
const char* filename = getenv("MOZ_PROFILER_SHUTDOWN");
if (filename && filename[0] != '\0') {
locked_profiler_save_profile_to_file(lock, filename,
preRecordedMetaInformation,