Bug 1548795 - P2. Remove dom.performance.enable_scheduler_timing preference. r=tarek
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 09 May 2019 23:12:12 +0000
changeset 532149 43a787dd45535c9ac25e7a8f8f11cd18d577f522
parent 532148 58de421f3fd072e481877f80e1c7c2e398027b17
child 532150 3ddac071d565fb30846e19708adb4d302a487466
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstarek
bugs1548795
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548795 - P2. Remove dom.performance.enable_scheduler_timing preference. r=tarek Differential Revision: https://phabricator.services.mozilla.com/D30467
dom/base/DOMPrefsInternal.h
dom/base/DocGroup.cpp
dom/base/DocGroup.h
dom/base/TimeoutManager.cpp
dom/chrome-webidl/ChromeUtils.webidl
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/tests/browser/browser.ini
dom/tests/browser/browser_test_performance_metrics_off.js
dom/tests/browser/perfmetrics/browser.ini
dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
dom/tests/browser/perfmetrics/browser_test_unresponsive.js
dom/workers/WorkerDebugger.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/WorkerThread.cpp
modules/libpref/init/StaticPrefList.h
modules/libpref/init/all.js
xpcom/tests/gtest/TestThreadMetrics.cpp
xpcom/threads/nsThread.cpp
--- a/dom/base/DOMPrefsInternal.h
+++ b/dom/base/DOMPrefsInternal.h
@@ -22,13 +22,12 @@ DOM_WEBIDL_PREF(dom_storageManager_enabl
 DOM_WEBIDL_PREF(dom_testing_structuredclonetester_enabled)
 DOM_WEBIDL_PREF(dom_promise_rejection_events_enabled)
 DOM_WEBIDL_PREF(dom_push_enabled)
 DOM_WEBIDL_PREF(gfx_offscreencanvas_enabled)
 DOM_WEBIDL_PREF(dom_webkitBlink_dirPicker_enabled)
 DOM_WEBIDL_PREF(dom_netinfo_enabled)
 DOM_WEBIDL_PREF(dom_fetchObserver_enabled)
 DOM_WEBIDL_PREF(dom_enable_performance_observer)
-DOM_WEBIDL_PREF(dom_performance_enable_scheduler_timing)
 DOM_WEBIDL_PREF(dom_reporting_enabled)
 DOM_WEBIDL_PREF(dom_reporting_testing_enabled)
 DOM_WEBIDL_PREF(dom_reporting_featurePolicy_enabled)
 DOM_WEBIDL_PREF(javascript_options_streams)
--- a/dom/base/DocGroup.cpp
+++ b/dom/base/DocGroup.cpp
@@ -47,20 +47,18 @@ void DocGroup::RemoveDocument(Document* 
   MOZ_ASSERT(mDocuments.Contains(aDocument));
   mDocuments.RemoveElement(aDocument);
 }
 
 DocGroup::DocGroup(TabGroup* aTabGroup, const nsACString& aKey)
     : mKey(aKey), mTabGroup(aTabGroup) {
   // This method does not add itself to mTabGroup->mDocGroups as the caller does
   // it for us.
-  if (mozilla::StaticPrefs::dom_performance_enable_scheduler_timing()) {
-    mPerformanceCounter =
-        new mozilla::PerformanceCounter(NS_LITERAL_CSTRING("DocGroup:") + aKey);
-  }
+  mPerformanceCounter =
+      new mozilla::PerformanceCounter(NS_LITERAL_CSTRING("DocGroup:") + aKey);
 }
 
 DocGroup::~DocGroup() {
   MOZ_ASSERT(mDocuments.IsEmpty());
   if (!NS_IsMainThread()) {
     nsIEventTarget* target = EventTargetFor(TaskCategory::Other);
     NS_ProxyRelease("DocGroup::mReactionsStack", target,
                     mReactionsStack.forget());
--- a/dom/base/DocGroup.h
+++ b/dom/base/DocGroup.h
@@ -109,17 +109,15 @@ class DocGroup final {
   DocGroup(TabGroup* aTabGroup, const nsACString& aKey);
   ~DocGroup();
 
   nsCString mKey;
   RefPtr<TabGroup> mTabGroup;
   nsTArray<Document*> mDocuments;
   RefPtr<mozilla::dom::CustomElementReactionsStack> mReactionsStack;
   nsTArray<RefPtr<HTMLSlotElement>> mSignalSlotList;
-  // This pointer will be null if dom.performance.enable_scheduler_timing is
-  // false (default value)
   RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // defined(DocGroup_h)
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -329,36 +329,28 @@ TimeDuration TimeoutManager::CalculateDe
     result = TimeDuration::Max(
         result, TimeDuration::FromMilliseconds(gMinClampTimeoutValue));
   }
 
   return result;
 }
 
 PerformanceCounter* TimeoutManager::GetPerformanceCounter() {
-  if (!StaticPrefs::dom_performance_enable_scheduler_timing()) {
-    return nullptr;
-  }
   Document* doc = mWindow.GetDocument();
   if (doc) {
     dom::DocGroup* docGroup = doc->GetDocGroup();
     if (docGroup) {
       return docGroup->GetPerformanceCounter();
     }
   }
   return nullptr;
 }
 
 void TimeoutManager::RecordExecution(Timeout* aRunningTimeout,
                                      Timeout* aTimeout) {
-  if (!StaticPrefs::dom_performance_enable_scheduler_timing() &&
-      mWindow.IsChromeWindow()) {
-    return;
-  }
-
   TimeoutBudgetManager& budgetManager = TimeoutBudgetManager::Get();
   TimeStamp now = TimeStamp::Now();
 
   if (aRunningTimeout) {
     // If we're running a timeout callback, record any execution until
     // now.
     TimeDuration duration = budgetManager.RecordExecution(now, aRunningTimeout);
 
--- a/dom/chrome-webidl/ChromeUtils.webidl
+++ b/dom/chrome-webidl/ChromeUtils.webidl
@@ -354,17 +354,17 @@ partial namespace ChromeUtils {
    * that it belongs to.
    */
   [Throws]
   object createError(DOMString message, optional object? stack = null);
 
   /**
    * Request performance metrics to the current process & all content processes.
    */
-  [Throws, Func="DOMPrefs::dom_performance_enable_scheduler_timing"]
+  [Throws]
   Promise<sequence<PerformanceInfoDictionary>> requestPerformanceMetrics();
 
   /**
   * Returns a Promise containing a sequence of I/O activities
   */
   [Throws]
   Promise<sequence<IOActivityDataDictionary>> requestIOActivity();
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1425,17 +1425,16 @@ mozilla::ipc::IPCResult ContentChild::Ge
   // If we are talking to the GPU process, then we should recover from this on
   // the next ContentChild::RecvReinitRendering call.
   gfxCriticalNote << "Could not initialize rendering with GPU process";
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvRequestPerformanceMetrics(
     const nsID& aID) {
-  MOZ_ASSERT(mozilla::StaticPrefs::dom_performance_enable_scheduler_timing());
   RefPtr<ContentChild> self = this;
   RefPtr<AbstractThread> mainThread =
       SystemGroup::AbstractMainThreadFor(TaskCategory::Performance);
   nsTArray<RefPtr<PerformanceInfoPromise>> promises = CollectPerformanceInfo();
 
   PerformanceInfoPromise::All(mainThread, promises)
       ->Then(
           mainThread, __func__,
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3490,21 +3490,16 @@ mozilla::ipc::IPCResult ContentParent::R
     mMemoryReportRequest->Finish(aGeneration);
     mMemoryReportRequest = nullptr;
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvAddPerformanceMetrics(
     const nsID& aID, nsTArray<PerformanceInfo>&& aMetrics) {
-  if (!mozilla::StaticPrefs::dom_performance_enable_scheduler_timing()) {
-    // The pref is off, we should not get a performance metrics from the content
-    // child
-    return IPC_OK();
-  }
   nsresult rv = PerformanceMetricsCollector::DataReceived(aID, aMetrics);
   Unused << NS_WARN_IF(NS_FAILED(rv));
   return IPC_OK();
 }
 
 PCycleCollectWithLogsParent* ContentParent::AllocPCycleCollectWithLogsParent(
     const bool& aDumpAllTraces, const FileDescriptor& aGCLog,
     const FileDescriptor& aCCLog) {
--- a/dom/tests/browser/browser.ini
+++ b/dom/tests/browser/browser.ini
@@ -1,10 +1,9 @@
 [DEFAULT]
-prefs = dom.performance.enable_scheduler_timing=false
 support-files =
   browser_frame_elements.html
   page_privatestorageevent.html
   page_localstorage_e10s.html
   page_localstorage_snapshotting_e10s.html
   position.html
   test-console-api.html
   test_bug1004814.html
@@ -82,13 +81,11 @@ support-files =
   test_new_window_from_content_child.html
 [browser_xhr_sandbox.js]
 [browser_noopener.js]
 skip-if = (verify && debug && (os == 'linux'))
 support-files =
   test_noopener_source.html
   test_noopener_target.html
 [browser_noopener_null_uri.js]
-[browser_test_performance_metrics_off.js]
-skip-if = verify
 [browser_wakelock.js]
 [browser_keypressTelemetry.js]
 skip-if = webrender
\ No newline at end of file
deleted file mode 100644
--- a/dom/tests/browser/browser_test_performance_metrics_off.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-add_task(async function testNotActivated() {
-  // dom.performance.enable_scheduler_timing is set to false in browser.ini
-  waitForExplicitFinish();
-  // make sure we throw a JS exception in case the pref is off and
-  // we call requestPerformanceMetrics()
-  let failed = false;
-  try {
-    await ChromeUtils.requestPerformanceMetrics();
-  } catch (e) {
-    failed = true;
-  }
-  Assert.ok(failed, "We should get an exception if preffed off");
-});
--- a/dom/tests/browser/perfmetrics/browser.ini
+++ b/dom/tests/browser/perfmetrics/browser.ini
@@ -1,11 +1,10 @@
 [DEFAULT]
 prefs =
-  dom.performance.enable_scheduler_timing=true
   dom.performance.children_results_ipc_timeout=2000
 
 support-files =
   dummy.html
   ping_worker.html
   ping_worker2.html
   ping_worker.js
   setinterval.html
--- a/dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
+++ b/dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
@@ -39,17 +39,16 @@ function jsonrpc(tab, method, params) {
   });
 }
 
 function postMessageToWorker(tab, message) {
   return jsonrpc(tab, "postMessageToWorker", [WORKER_URL, message]);
 }
 
 add_task(async function test() {
-  // dom.performance.enable_scheduler_timing is set to true in browser.ini
   waitForExplicitFinish();
 
   // Load 3 pages and wait. The 3rd one has a worker
   let page1 = await BrowserTestUtils.openNewForegroundTab({
     gBrowser, opening: "about:about", forceNewProcess: false,
   });
 
   let page2 = await BrowserTestUtils.openNewForegroundTab({
--- a/dom/tests/browser/perfmetrics/browser_test_unresponsive.js
+++ b/dom/tests/browser/perfmetrics/browser_test_unresponsive.js
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const ROOT_URL = "http://example.com/browser/dom/tests/browser/perfmetrics";
 const PAGE_URL = ROOT_URL + "/unresponsive.html";
 
 add_task(async function test() {
-  // dom.performance.enable_scheduler_timing is set to true in browser.ini
   waitForExplicitFinish();
 
   await BrowserTestUtils.withNewTab({ gBrowser, url: PAGE_URL },
     async function(browser) {
     let dataBack = 0;
     let tabId = gBrowser.selectedBrowser.outerWindowID;
 
     function exploreResults(data, filterByWindowId) {
--- a/dom/workers/WorkerDebugger.cpp
+++ b/dom/workers/WorkerDebugger.cpp
@@ -90,19 +90,17 @@ class CompileDebuggerScriptRunnable fina
 
     if (NS_WARN_IF(!aWorkerPrivate->EnsureCSPEventListener())) {
       return false;
     }
 
     // Initialize performance state which might be used on the main thread, as
     // in CompileScriptRunnable. This runnable might execute first.
     aWorkerPrivate->EnsurePerformanceStorage();
-    if (mozilla::StaticPrefs::dom_performance_enable_scheduler_timing()) {
-      aWorkerPrivate->EnsurePerformanceCounter();
-    }
+    aWorkerPrivate->EnsurePerformanceCounter();
 
     JS::Rooted<JSObject*> global(aCx, globalScope->GetWrapper());
 
     ErrorResult rv;
     JSAutoRealm ar(aCx, global);
     workerinternals::LoadMainScript(aWorkerPrivate, nullptr, mScriptURL,
                                     DebuggerScript, rv);
     rv.WouldReportJSException();
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -328,20 +328,17 @@ class CompileScriptRunnable final : publ
       return false;
     }
 
     // PerformanceStorage & PerformanceCounter both need to be initialized
     // on the worker thread before being used on main-thread.
     // Let's be sure that it is created before any
     // content loading.
     aWorkerPrivate->EnsurePerformanceStorage();
-
-    if (mozilla::StaticPrefs::dom_performance_enable_scheduler_timing()) {
-      aWorkerPrivate->EnsurePerformanceCounter();
-    }
+    aWorkerPrivate->EnsurePerformanceCounter();
 
     ErrorResult rv;
     workerinternals::LoadMainScript(aWorkerPrivate, std::move(mOriginStack),
                                     mScriptURL, WorkerScript, rv);
     rv.WouldReportJSException();
     // Explicitly ignore NS_BINDING_ABORTED on rv.  Or more precisely, still
     // return false and don't SetWorkerScriptExecutedSuccessfully() in that
     // case, but don't throw anything on aCx.  The idea is to not dispatch error
@@ -4763,17 +4760,16 @@ void WorkerPrivate::DumpCrashInformation
     WorkerHolder* holder = iter.GetNext();
     aString.Append("|");
     aString.Append(holder->Name());
   }
 }
 
 void WorkerPrivate::EnsurePerformanceCounter() {
   AssertIsOnWorkerThread();
-  MOZ_ASSERT(mozilla::StaticPrefs::dom_performance_enable_scheduler_timing());
   if (!mPerformanceCounter) {
     nsPrintfCString workerName("Worker:%s",
                                NS_ConvertUTF16toUTF8(mWorkerName).get());
     mPerformanceCounter = new PerformanceCounter(workerName);
   }
 }
 
 PerformanceCounter* WorkerPrivate::GetPerformanceCounter() {
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -1135,18 +1135,16 @@ class WorkerPrivate : public RelativeTim
   // Protected by mMutex.
   bool mDebuggerReady;
   nsTArray<RefPtr<WorkerRunnable>> mDelayedDebuggeeRunnables;
 
   // mIsInAutomation is true when we're running in test automation.
   // We expose some extra testing functions in that case.
   bool mIsInAutomation;
 
-  // This pointer will be null if dom.performance.enable_scheduler_timing is
-  // false (default value)
   RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
 
   nsString mID;
 };
 
 class AutoSyncLoopHolder {
   WorkerPrivate* mWorkerPrivate;
   nsCOMPtr<nsIEventTarget> mTarget;
--- a/dom/workers/WorkerThread.cpp
+++ b/dom/workers/WorkerThread.cpp
@@ -138,19 +138,16 @@ void WorkerThread::SetWorker(const Worke
       mAcceptingNonWorkerRunnables = true;
 #endif
       mWorkerPrivate = nullptr;
     }
   }
 }
 
 void WorkerThread::IncrementDispatchCounter() {
-  if (!mozilla::StaticPrefs::dom_performance_enable_scheduler_timing()) {
-    return;
-  }
   MutexAutoLock lock(mLock);
   if (mWorkerPrivate) {
     PerformanceCounter* performanceCounter =
         mWorkerPrivate->GetPerformanceCounter();
     if (performanceCounter) {
       performanceCounter->IncrementDispatchCounter(DispatchCategory::Worker);
     }
   }
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -275,22 +275,16 @@ VARCACHE_PREF(
 // Historical behavior is the second, the first is being discussed at:
 // https://github.com/whatwg/html/issues/3840
 VARCACHE_PREF(
   "dom.link.disabled_attribute.enabled",
    dom_link_disabled_attribute_enabled,
   bool, true
 )
 
-VARCACHE_PREF(
-  "dom.performance.enable_scheduler_timing",
-  dom_performance_enable_scheduler_timing,
-  RelaxedAtomicBool, true
-)
-
 // Should we defer timeouts and intervals while loading a page.  Released
 // on Idle or when the page is loaded.
 VARCACHE_PREF(
   "dom.timeout.defer_during_load",
   dom_timeout_defer_during_load,
   bool, true
 )
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -149,19 +149,16 @@ pref("dom.serviceWorkers.idle_extended_t
 
 // The amount of time (milliseconds) an update request is delayed when triggered
 // by a service worker that doesn't control any clients.
 pref("dom.serviceWorkers.update_delay", 1000);
 
 // Enable test for 24 hours update, service workers will always treat last update check time is over 24 hours
 pref("dom.serviceWorkers.testUpdateOverOneDay", false);
 
-// Enable collecting of docgroup activity in the scheduler
-pref("dom.performance.enable_scheduler_timing", true);
-
 // Enable Permission API's .revoke() method
 pref("dom.permissions.revoke.enable", false);
 
 // Enable exposing timeToNonBlankPaint
 pref("dom.performance.time_to_non_blank_paint.enabled", false);
 
 // Enable exposing timeToContentfulPaint
 pref("dom.performance.time_to_contentful_paint.enabled", false);
--- a/xpcom/tests/gtest/TestThreadMetrics.cpp
+++ b/xpcom/tests/gtest/TestThreadMetrics.cpp
@@ -72,43 +72,38 @@ class TimedRunnable final : public Runna
 };
 
 /* test class used for all metrics tests
  *
  * - sets up the enable_scheduler_timing pref
  * - provides a function to dispatch runnables and spin the loop
  */
 
-static const char prefKey[] = "dom.performance.enable_scheduler_timing";
-
 class ThreadMetrics : public ::testing::Test {
  public:
   explicit ThreadMetrics() = default;
 
  protected:
   virtual void SetUp() {
-    mOldPref = Preferences::GetBool(prefKey);
-    Preferences::SetBool(prefKey, true);
     // building the TabGroup/DocGroup structure
     nsCString key = NS_LITERAL_CSTRING("key");
     RefPtr<dom::Document> doc;
     RefPtr<dom::TabGroup> tabGroup = new dom::TabGroup(false);
     mDocGroup = tabGroup->AddDocument(key, doc);
     mSchedulerGroup = new MSchedulerGroup(mDocGroup);
     mCounter = mDocGroup->GetPerformanceCounter();
     mThreadMgr = do_GetService("@mozilla.org/thread-manager;1");
     mOther = DispatchCategory(TaskCategory::Other).GetValue();
     mDispatchCount = (uint32_t)TaskCategory::Other + 1;
   }
 
   virtual void TearDown() {
     // and remove the document from the doc group (actually, a nullptr)
     mDocGroup->RemoveDocument(nullptr);
     mDocGroup = nullptr;
-    Preferences::SetBool(prefKey, mOldPref);
     ProcessAllEvents();
   }
 
   // this is used to get rid of transient events
   void initScheduler() { ProcessAllEvents(); }
 
   nsresult Dispatch(uint32_t aExecutionTime1, uint32_t aExecutionTime2,
                     uint32_t aSubExecutionTime) {
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -1115,20 +1115,17 @@ nsThread::ProcessNextEvent(bool aMayWait
       // Delay event processing to encourage whoever dispatched this event
       // to run.
       DelayForChaosMode(ChaosFeature::TaskRunning, 1000);
 
       if (IsMainThread()) {
         BackgroundHangMonitor().NotifyActivity();
       }
 
-      bool schedulerLoggingEnabled =
-          mozilla::StaticPrefs::dom_performance_enable_scheduler_timing();
-      if (schedulerLoggingEnabled &&
-          mNestedEventLoopDepth > mCurrentEventLoopDepth &&
+      if (mNestedEventLoopDepth > mCurrentEventLoopDepth &&
           mCurrentPerformanceCounter) {
         // This is a recursive call, we're saving the time
         // spent in the parent event if the runnable is linked to a DocGroup.
         mozilla::TimeDuration duration = TimeStamp::Now() - mCurrentEventStart;
         mCurrentPerformanceCounter->IncrementExecutionDuration(
             duration.ToMicroseconds());
       }
 
@@ -1165,22 +1162,20 @@ nsThread::ProcessNextEvent(bool aMayWait
 
       // The event starts to run, storing the timestamp.
       bool recursiveEvent = mNestedEventLoopDepth > mCurrentEventLoopDepth;
       mCurrentEventLoopDepth = mNestedEventLoopDepth;
       if (IsMainThread() && !recursiveEvent) {
         mCurrentEventStart = mozilla::TimeStamp::Now();
       }
       RefPtr<mozilla::PerformanceCounter> currentPerformanceCounter;
-      if (schedulerLoggingEnabled) {
-        mCurrentEventStart = mozilla::TimeStamp::Now();
-        mCurrentEvent = event;
-        mCurrentPerformanceCounter = GetPerformanceCounter(event);
-        currentPerformanceCounter = mCurrentPerformanceCounter;
-      }
+      mCurrentEventStart = mozilla::TimeStamp::Now();
+      mCurrentEvent = event;
+      mCurrentPerformanceCounter = GetPerformanceCounter(event);
+      currentPerformanceCounter = mCurrentPerformanceCounter;
 
       event->Run();
 
       mozilla::TimeDuration duration;
       // Remember the last 50ms+ task on mainthread for Long Task.
       if (IsMainThread() && !recursiveEvent) {
         TimeStamp now = TimeStamp::Now();
         duration = now - mCurrentEventStart;
@@ -1198,34 +1193,32 @@ nsThread::ProcessNextEvent(bool aMayWait
                 JS::ProfilingCategoryPair::OTHER,
                 MakeUnique<LongTaskMarkerPayload>(mCurrentEventStart, now));
           }
 #endif
         }
       }
 
       // End of execution, we can send the duration for the group
-      if (schedulerLoggingEnabled) {
-        if (recursiveEvent) {
-          // If we're in a recursive call, reset the timer,
-          // so the parent gets its remaining execution time right.
-          mCurrentEventStart = mozilla::TimeStamp::Now();
-          mCurrentPerformanceCounter = currentPerformanceCounter;
-        } else {
-          // We're done with this dispatch
-          if (currentPerformanceCounter) {
-            mozilla::TimeDuration duration =
-                TimeStamp::Now() - mCurrentEventStart;
-            currentPerformanceCounter->IncrementExecutionDuration(
-                duration.ToMicroseconds());
-          }
-          mCurrentEvent = nullptr;
-          mCurrentEventLoopDepth = -1;
-          mCurrentPerformanceCounter = nullptr;
+      if (recursiveEvent) {
+        // If we're in a recursive call, reset the timer,
+        // so the parent gets its remaining execution time right.
+        mCurrentEventStart = mozilla::TimeStamp::Now();
+        mCurrentPerformanceCounter = currentPerformanceCounter;
+      } else {
+        // We're done with this dispatch
+        if (currentPerformanceCounter) {
+          mozilla::TimeDuration duration =
+              TimeStamp::Now() - mCurrentEventStart;
+          currentPerformanceCounter->IncrementExecutionDuration(
+              duration.ToMicroseconds());
         }
+        mCurrentEvent = nullptr;
+        mCurrentEventLoopDepth = -1;
+        mCurrentPerformanceCounter = nullptr;
       }
     } else if (aMayWait) {
       MOZ_ASSERT(ShuttingDown(), "This should only happen when shutting down");
       rv = NS_ERROR_UNEXPECTED;
     }
   }
 
   NOTIFY_EVENT_OBSERVERS(EventQueue()->EventObservers(), AfterProcessNextEvent,