Bug 1341924 - Don't attempt to dispatch CheckResponsivenessTasks to non-main threads. r?njn
This is more of a workaround than a real fix, but the old code wasn't working
for non-main threads either, and we'd like to change the way this information
is computed anyway (
bug 1340714) and then we won't need CheckResponsivenessTask
any more.
MozReview-Commit-ID: FGiomjwpk3z
--- a/tools/profiler/gecko/ThreadResponsiveness.cpp
+++ b/tools/profiler/gecko/ThreadResponsiveness.cpp
@@ -26,16 +26,18 @@ public:
}
protected:
~CheckResponsivenessTask()
{
}
public:
+
+ // Can only run on the main thread.
NS_IMETHOD Run() override
{
MonitorAutoLock mon(mMonitor);
if (mStop)
return NS_OK;
// This is raced on because we might pause the thread here
// for profiling so if we tried to use a monitor to protect
@@ -90,23 +92,20 @@ ThreadResponsiveness::~ThreadResponsiven
if (mActiveTracerEvent) {
mActiveTracerEvent->Terminate();
}
}
void
ThreadResponsiveness::Update(bool aIsMainThread, nsIThread* aThread)
{
- if (!mActiveTracerEvent) {
- if (aIsMainThread) {
- mActiveTracerEvent = new CheckResponsivenessTask();
- NS_DispatchToMainThread(mActiveTracerEvent);
- } else if (aThread) {
- mActiveTracerEvent = new CheckResponsivenessTask();
- aThread->Dispatch(mActiveTracerEvent, NS_DISPATCH_NORMAL);
- }
+ if (!aIsMainThread) {
+ return;
}
- if (mActiveTracerEvent) {
- mLastTracerTime = mActiveTracerEvent->GetLastTracerTime();
+ if (!mActiveTracerEvent) {
+ mActiveTracerEvent = new CheckResponsivenessTask();
+ NS_DispatchToMainThread(mActiveTracerEvent);
}
+
+ mLastTracerTime = mActiveTracerEvent->GetLastTracerTime();
}
--- a/tools/profiler/gecko/ThreadResponsiveness.h
+++ b/tools/profiler/gecko/ThreadResponsiveness.h
@@ -13,16 +13,17 @@
class CheckResponsivenessTask;
class ThreadResponsiveness {
public:
explicit ThreadResponsiveness();
~ThreadResponsiveness();
+ // Won't do anything on non-main threads for now.
void Update(bool aIsMainThread, nsIThread* aThread);
mozilla::TimeDuration GetUnresponsiveDuration(const mozilla::TimeStamp& now) const {
return now - mLastTracerTime;
}
bool HasData() const {
return !mLastTracerTime.IsNull();