Bug 1389184 - Avoid crashing in worker MemoryReporter if the GlobalScope is nullptr. r=asuth, a=gchang
authorBen Kelly <ben@wanderview.com>
Thu, 10 Aug 2017 18:00:05 -0700
changeset 423553 ee0bdebf299a39ca18cd8f587363aa9cb5258b14
parent 423552 4f7144901630bea10412fb779dbc7d48340daf0c
child 423554 4ae9b45662dd43910885008a1731daa4ff902c95
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1389184
milestone56.0
Bug 1389184 - Avoid crashing in worker MemoryReporter if the GlobalScope is nullptr. r=asuth, a=gchang
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2593,18 +2593,19 @@ WorkerPrivate::MemoryReporter::CollectRe
 { }
 
 bool
 WorkerPrivate::MemoryReporter::CollectReportsRunnable::WorkerRun(JSContext* aCx,
                                                                  WorkerPrivate* aWorkerPrivate)
 {
   aWorkerPrivate->AssertIsOnWorkerThread();
 
-  RefPtr<Performance> performance =
-    aWorkerPrivate->GlobalScope()->GetPerformanceIfExists();
+  RefPtr<WorkerGlobalScope> scope = aWorkerPrivate->GlobalScope();
+  RefPtr<Performance> performance = scope ? scope->GetPerformanceIfExists()
+                                          : nullptr;
   if (performance) {
     size_t userEntries = performance->SizeOfUserEntries(JsWorkerMallocSizeOf);
     size_t resourceEntries =
       performance->SizeOfResourceEntries(JsWorkerMallocSizeOf);
     mFinishCollectRunnable->SetPerformanceSizes(userEntries, resourceEntries);
   }
 
   mFinishCollectRunnable->SetSuccess(