Bug 830990 - Stop dispatching CheckResponsivenessEvents when the profiler is stopped. r?njn
MozReview-Commit-ID: 4MnRGqE2sEK
--- a/tools/profiler/core/ThreadInfo.cpp
+++ b/tools/profiler/core/ThreadInfo.cpp
@@ -33,20 +33,16 @@ ThreadInfo::ThreadInfo(const char* aName
MOZ_COUNT_CTOR(ThreadInfo);
// We don't have to guess on mac
#if defined(GP_OS_darwin)
pthread_t self = pthread_self();
mStackTop = pthread_get_stackaddr_np(self);
#endif
- if (aIsMainThread) {
- mResponsiveness.emplace();
- }
-
// I don't know if we can assert this. But we should warn.
MOZ_ASSERT(aThreadId >= 0, "native thread ID is < 0");
MOZ_ASSERT(aThreadId <= INT32_MAX, "native thread ID is > INT32_MAX");
}
ThreadInfo::~ThreadInfo()
{
MOZ_COUNT_DTOR(ThreadInfo);
@@ -54,21 +50,25 @@ ThreadInfo::~ThreadInfo()
delete mPseudoStack;
}
void
ThreadInfo::StartProfiling()
{
mIsBeingProfiled = true;
mPseudoStack->reinitializeOnResume();
+ if (mIsMainThread) {
+ mResponsiveness.emplace();
+ }
}
void
ThreadInfo::StopProfiling()
{
+ mResponsiveness.reset();
mIsBeingProfiled = false;
}
void
ThreadInfo::StreamJSON(ProfileBuffer* aBuffer, SpliceableJSONWriter& aWriter,
const TimeStamp& aStartTime, double aSinceTime)
{
// mUniqueStacks may already be emplaced from FlushSamplesAndMarkers.
--- a/tools/profiler/core/ThreadInfo.h
+++ b/tools/profiler/core/ThreadInfo.h
@@ -62,21 +62,22 @@ public:
void StreamJSON(ProfileBuffer* aBuffer, SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime, double aSinceTime);
// Call this method when the JS entries inside the buffer are about to
// become invalid, i.e., just before JS shutdown.
void FlushSamplesAndMarkers(ProfileBuffer* aBuffer,
const mozilla::TimeStamp& aStartTime);
- // Returns nullptr if this is not the main thread.
+ // Returns nullptr if this is not the main thread or if this thread is not
+ // being profiled.
ThreadResponsiveness* GetThreadResponsiveness()
{
ThreadResponsiveness* responsiveness = mResponsiveness.ptrOr(nullptr);
- MOZ_ASSERT(!!responsiveness == mIsMainThread);
+ MOZ_ASSERT(!!responsiveness == (mIsMainThread && mIsBeingProfiled));
return responsiveness;
}
private:
bool mIsBeingProfiled;
// JS frames in the buffer may require a live JSRuntime to stream (e.g.,
// stringifying JIT frames). In the case of JSRuntime destruction,