Bug 1449084 - Early-exit in profiler_add_marker_for_thread if the profiler is not running. r?mystor
MozReview-Commit-ID: Kiqur4ZJobi
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3340,27 +3340,30 @@ profiler_add_marker(const char* aMarkerN
// to lock here.
void
profiler_add_marker_for_thread(int aThreadId,
const char* aMarkerName,
UniquePtr<ProfilerMarkerPayload> aPayload)
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
+ PSAutoLock lock(gPSMutex);
+ if (!ActivePS::Exists(lock)) {
+ return;
+ }
+
// Create the ProfilerMarker which we're going to store.
TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
? aPayload->GetStartTime()
: TimeStamp::Now();
TimeDuration delta = origin - CorePS::ProcessStartTime();
ProfilerMarker* marker =
new ProfilerMarker(aMarkerName, aThreadId, Move(aPayload),
delta.ToMilliseconds());
- PSAutoLock lock(gPSMutex);
-
#ifdef DEBUG
// Assert that our thread ID makes sense
bool realThread = false;
const nsTArray<UniquePtr<RegisteredThread>>& registeredThreads =
CorePS::RegisteredThreads(lock);
for (auto& thread : registeredThreads) {
RefPtr<ThreadInfo> info = thread->Info();
if (info->ThreadId() == aThreadId) {