Backed out 4 changesets (bug 1652613) for Browser-chrome failures in browser/browser_ProcessHangNotifications.js. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Fri, 24 Jul 2020 02:58:22 +0300
changeset 541842 7f26efea615b4bc6ee548842e7b4ce8bc1c615c5
parent 541841 013c081b92a50a44cbbb43c3fb29784b3241c864
child 541843 ceba0316cf3c3fce540ff8e6217969a3291ea821
push id37633
push userccoroiu@mozilla.com
push dateFri, 24 Jul 2020 09:32:06 +0000
treeherdermozilla-central@141543043270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1652613
milestone80.0a1
backs out76b5a5d243d16d4cd0ba9b640fdd4ae9d5f8555b
6f98c9b019206c198b145bc102905745fa37d3f7
1255237ce2e759fb37ffa6cd9241b4087f13cf73
bdf59854c90006afdc66aeb165d9d977530a4e73
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
Backed out 4 changesets (bug 1652613) for Browser-chrome failures in browser/browser_ProcessHangNotifications.js. CLOSED TREE Backed out changeset 76b5a5d243d1 (bug 1652613) Backed out changeset 6f98c9b01920 (bug 1652613) Backed out changeset 1255237ce2e7 (bug 1652613) Backed out changeset bdf59854c900 (bug 1652613)
browser/modules/ProcessHangMonitor.jsm
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/ipc/PProcessHangMonitor.ipdl
dom/ipc/ProcessHangMonitor.cpp
dom/ipc/ProcessHangMonitor.h
dom/ipc/nsIHangReport.idl
js/xpconnect/src/XPCJSContext.cpp
toolkit/components/telemetry/Events.yaml
--- a/browser/modules/ProcessHangMonitor.jsm
+++ b/browser/modules/ProcessHangMonitor.jsm
@@ -34,43 +34,36 @@ var ProcessHangMonitor = {
   /**
    * Should only be set to true once the quit-application-granted notification
    * has been fired.
    */
   _shuttingDown: false,
 
   /**
    * Collection of hang reports that haven't expired or been dismissed
-   * by the user. These are nsIHangReports. They are mapped to objects
-   * containing:
-   * - notificationTime: when (Cu.now()) we first showed a notification
-   * - waitCount: how often the user asked to wait for the script to finish
-   * - lastReportFromChild: when (Cu.now()) we last got hang info from the
-   *   child.
+   * by the user. These are nsIHangReports.
    */
-  _activeReports: new Map(),
+  _activeReports: new Set(),
 
   /**
    * Collection of hang reports that have been suppressed for a short
-   * period of time. Value is an object like in _activeReports, but also
-   * including a `timer` prop, which is an nsITimer for when the wait time
+   * period of time. Value is an nsITimer for when the wait time
    * expires.
    */
   _pausedReports: new Map(),
 
   /**
    * Initialize hang reporting. Called once in the parent process.
    */
   init() {
     Services.obs.addObserver(this, "process-hang-report");
     Services.obs.addObserver(this, "clear-hang-report");
     Services.obs.addObserver(this, "quit-application-granted");
     Services.obs.addObserver(this, "xpcom-shutdown");
     Services.ww.registerNotification(this);
-    Services.telemetry.setEventRecordingEnabled("slow_script_warning", true);
   },
 
   /**
    * Terminate JavaScript associated with the hang being reported for
    * the selected browser in |win|.
    */
   terminateScript(win) {
     this.handleUserInput(win, report => report.terminateScript());
@@ -89,17 +82,16 @@ var ProcessHangMonitor = {
    * being reported for the selected browser in |win|.
    */
   debugScript(win) {
     this.handleUserInput(win, report => {
       function callback() {
         report.endStartingDebugger();
       }
 
-      this._recordTelemetryForReport(report, "debugging");
       report.beginStartingDebugger();
 
       let svc = Cc["@mozilla.org/dom/slow-script-debug;1"].getService(
         Ci.nsISlowScriptDebug
       );
       let handler = svc.remoteActivationHandler;
       handler.handleSlowScriptDebug(report.scriptBrowser, callback);
     });
@@ -121,17 +113,16 @@ var ProcessHangMonitor = {
   stopIt(win) {
     let report = this.findActiveReport(win.gBrowser.selectedBrowser);
     if (!report) {
       return;
     }
 
     switch (report.hangType) {
       case report.SLOW_SCRIPT:
-        this._recordTelemetryForReport(report, "user-aborted");
         this.terminateScript(win);
         break;
       case report.PLUGIN_HANG:
         this.terminatePlugin(win);
         break;
     }
   },
 
@@ -142,30 +133,28 @@ var ProcessHangMonitor = {
   stopGlobal(win) {
     let report = this.findActiveReport(win.gBrowser.selectedBrowser);
     if (!report) {
       return;
     }
 
     switch (report.hangType) {
       case report.SLOW_SCRIPT:
-        this._recordTelemetryForReport(report, "user-aborted");
         this.terminateGlobal(win);
         break;
     }
   },
 
   /**
    * Terminate whatever is causing this report, be it an add-on, page script,
    * or plug-in. This is done without updating any report notifications.
    */
-  stopHang(report, endReason, backupInfo) {
+  stopHang(report) {
     switch (report.hangType) {
       case report.SLOW_SCRIPT: {
-        this._recordTelemetryForReport(report, endReason, backupInfo);
         if (report.addonId) {
           report.terminateGlobal();
         } else {
           report.terminateScript();
         }
         break;
       }
       case report.PLUGIN_HANG: {
@@ -179,50 +168,45 @@ var ProcessHangMonitor = {
    * Dismiss the notification, clear the report from the active list and set up
    * a new timer to track a wait period during which we won't notify.
    */
   waitLonger(win) {
     let report = this.findActiveReport(win.gBrowser.selectedBrowser);
     if (!report) {
       return;
     }
-    // Update the other info we keep.
-    let reportInfo = this._activeReports.get(report);
-    reportInfo.waitCount++;
-
     // Remove the report from the active list.
     this.removeActiveReport(report);
 
     // NOTE, we didn't call userCanceled on nsIHangReport here. This insures
     // we don't repeatedly generate and cache crash report data for this hang
     // in the process hang reporter. It already has one report for the browser
     // process we want it hold onto.
 
     // Create a new wait timer with notify callback
     let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     timer.initWithCallback(
       () => {
-        for (let [stashedReport, pausedInfo] of this._pausedReports) {
-          if (pausedInfo.timer === timer) {
+        for (let [stashedReport, otherTimer] of this._pausedReports) {
+          if (otherTimer === timer) {
             this.removePausedReport(stashedReport);
 
             // We're still hung, so move the report back to the active
             // list and update the UI.
-            this._activeReports.set(report, pausedInfo);
+            this._activeReports.add(report);
             this.updateWindows();
             break;
           }
         }
       },
       this.WAIT_EXPIRATION_TIME,
       timer.TYPE_ONE_SHOT
     );
 
-    reportInfo.timer = timer;
-    this._pausedReports.set(report, reportInfo);
+    this._pausedReports.set(report, timer);
 
     // remove the browser notification associated with this hang
     this.updateWindows();
   },
 
   /**
    * If there is a hang report associated with the selected browser in
    * |win|, invoke |func| on that report and stop notifying the user
@@ -287,34 +271,34 @@ var ProcessHangMonitor = {
   /**
    * Called early on in the shutdown sequence. We take this opportunity to
    * take any pre-existing hang reports, and terminate them. We also put
    * ourselves in a state so that if any more hang reports show up while
    * we're shutting down, we terminate them immediately.
    */
   onQuitApplicationGranted() {
     this._shuttingDown = true;
-    this.stopAllHangs("quit-application-granted");
+    this.stopAllHangs();
     this.updateWindows();
   },
 
   onWindowClosed(win) {
     let maybeStopHang = report => {
       if (report.hangType == report.SLOW_SCRIPT) {
         let hungBrowserWindow = null;
         try {
           hungBrowserWindow = report.scriptBrowser.ownerGlobal;
         } catch (e) {
           // Ignore failures to get the script browser - we'll be
           // conservative, and assume that if we cannot access the
           // window that belongs to this report that we should stop
           // the hang.
         }
         if (!hungBrowserWindow || hungBrowserWindow == win) {
-          this.stopHang(report, "window-closed");
+          this.stopHang(report);
           return true;
         }
       } else if (report.hangType == report.PLUGIN_HANG) {
         // If any window has closed during a plug-in hang, we'll
         // do the conservative thing and terminate the plug-in.
         this.stopHang(report);
         return true;
       }
@@ -333,35 +317,35 @@ var ProcessHangMonitor = {
       if (maybeStopHang(pausedReport)) {
         this.removePausedReport(pausedReport);
       }
     }
 
     this.updateWindows();
   },
 
-  stopAllHangs(endReason) {
+  stopAllHangs() {
     for (let report of this._activeReports) {
-      this.stopHang(report, endReason);
+      this.stopHang(report);
     }
 
-    this._activeReports = new Map();
+    this._activeReports = new Set();
 
     for (let [pausedReport] of this._pausedReports) {
-      this.stopHang(pausedReport, endReason);
+      this.stopHang(pausedReport);
       this.removePausedReport(pausedReport);
     }
   },
 
   /**
    * Find a active hang report for the given <browser> element.
    */
   findActiveReport(browser) {
     let frameLoader = browser.frameLoader;
-    for (let report of this._activeReports.keys()) {
+    for (let report of this._activeReports) {
       if (report.isReportForBrowser(frameLoader)) {
         return report;
       }
     }
     return null;
   },
 
   /**
@@ -373,114 +357,50 @@ var ProcessHangMonitor = {
       if (report.isReportForBrowser(frameLoader)) {
         return report;
       }
     }
     return null;
   },
 
   /**
-   * Tell telemetry about the report.
-   */
-  _recordTelemetryForReport(report, endReason, backupInfo) {
-    let info =
-      this._activeReports.get(report) ||
-      this._pausedReports.get(report) ||
-      backupInfo;
-    if (!info) {
-      return;
-    }
-    try {
-      // Only report slow script hangs.
-      if (report.hangType != report.SLOW_SCRIPT) {
-        return;
-      }
-      let uri_type;
-      if (report.addonId) {
-        uri_type = "extension";
-      } else if (report.scriptFileName?.startsWith("debugger")) {
-        uri_type = "devtools";
-      } else {
-        try {
-          let url = new URL(report.scriptFileName);
-          if (url.protocol == "chrome:" || url.protocol == "resource:") {
-            uri_type = "browser";
-          } else {
-            uri_type = "content";
-          }
-        } catch (ex) {
-          Cu.reportError(ex);
-          uri_type = "unknown";
-        }
-      }
-      let uptime = 0;
-      if (info.notificationTime) {
-        uptime = Cu.now() - info.notificationTime;
-      }
-      uptime = "" + uptime;
-      // We combine the duration of the hang in the content process with the
-      // time since we were last told about the hang in the parent. This is
-      // not the same as the time we showed a notification, as we only do that
-      // for the currently selected browser. It's as messy as it is because
-      // there is no cross-process monotonically increasing timestamp we can
-      // use. :-(
-      let hangDuration =
-        report.hangDuration + Cu.now() - info.lastReportFromChild;
-      Services.telemetry.recordEvent(
-        "slow_script_warning",
-        "shown",
-        "content",
-        null,
-        {
-          end_reason: endReason,
-          hang_duration: "" + hangDuration,
-          n_tab_deselect: "" + info.deselectCount,
-          uri_type,
-          uptime,
-          wait_count: "" + info.waitCount,
-        }
-      );
-    } catch (ex) {
-      Cu.reportError(ex);
-    }
-  },
-
-  /**
    * Remove an active hang report from the active list and cancel the timer
    * associated with it.
    */
   removeActiveReport(report) {
     this._activeReports.delete(report);
     this.updateWindows();
   },
 
   /**
    * Remove a paused hang report from the paused list and cancel the timer
    * associated with it.
    */
   removePausedReport(report) {
-    let info = this._pausedReports.get(report);
-    info?.timer?.cancel();
+    let timer = this._pausedReports.get(report);
+    if (timer) {
+      timer.cancel();
+    }
     this._pausedReports.delete(report);
   },
 
   /**
    * Iterate over all XUL windows and ensure that the proper hang
    * reports are shown for each one. Also install event handlers in
    * each window to watch for events that would cause a different hang
    * report to be displayed.
    */
   updateWindows() {
     let e = Services.wm.getEnumerator("navigator:browser");
 
     // If it turns out we have no windows (this can happen on macOS),
     // we have no opportunity to ask the user whether or not they want
     // to stop the hang or wait, so we'll opt for stopping the hang.
     if (!e.hasMoreElements()) {
-      this.stopAllHangs("no-windows-left");
+      this.stopAllHangs();
       return;
     }
 
     for (let win of e) {
       this.updateWindow(win);
 
       // Only listen for these events if there are active hang reports.
       if (this._activeReports.size) {
@@ -493,20 +413,16 @@ var ProcessHangMonitor = {
 
   /**
    * If there is a hang report for the current tab in |win|, display it.
    */
   updateWindow(win) {
     let report = this.findActiveReport(win.gBrowser.selectedBrowser);
 
     if (report) {
-      let info = this._activeReports.get(report);
-      if (info && !info.notificationTime) {
-        info.notificationTime = Cu.now();
-      }
       this.showNotification(win, report);
     } else {
       this.hideNotification(win);
     }
   },
 
   /**
    * Show the notification for a hang.
@@ -634,77 +550,58 @@ var ProcessHangMonitor = {
     );
   },
 
   handleEvent(event) {
     let win = event.target.ownerGlobal;
 
     // If a new tab is selected or if a tab changes remoteness, then
     // we may need to show or hide a hang notification.
+
     if (event.type == "TabSelect" || event.type == "TabRemotenessChange") {
-      if (event.type == "TabSelect" && event.detail.previousTab) {
-        // If we've got a notification, check the previous tab's report and
-        // indicate the user switched tabs while the notification was up.
-        let r = this.findActiveReport(event.detail.previousTab.linkedBrowser);
-        if (r) {
-          let info = this._activeReports.get(r);
-          info.deselectCount++;
-        }
-      }
       this.updateWindow(win);
     }
   },
 
   /**
    * Handle a potentially new hang report. If it hasn't been seen
    * before, show a notification for it in all open XUL windows.
    */
   reportHang(report) {
-    let now = Cu.now();
     if (this._shuttingDown) {
-      this.stopHang(report, "shutdown-in-progress", {
-        lastReportFromChild: now,
-      });
+      this.stopHang(report);
       return;
     }
 
     // If this hang was already reported reset the timer for it.
     if (this._activeReports.has(report)) {
-      this._activeReports.get(report).lastReportFromChild = now;
       // if this report is in active but doesn't have a notification associated
       // with it, display a notification.
       this.updateWindows();
       return;
     }
 
     // If this hang was already reported and paused by the user ignore it.
     if (this._pausedReports.has(report)) {
-      this._pausedReports.get(report).lastReportFromChild = now;
       return;
     }
 
     // On e10s this counts slow-script/hanged-plugin notice only once.
     // This code is not reached on non-e10s.
     if (report.hangType == report.SLOW_SCRIPT) {
       // On non-e10s, SLOW_SCRIPT_NOTICE_COUNT is probed at nsGlobalWindow.cpp
       Services.telemetry.getHistogramById("SLOW_SCRIPT_NOTICE_COUNT").add();
     } else if (report.hangType == report.PLUGIN_HANG) {
       // On non-e10s we have sufficient plugin telemetry probes,
       // so PLUGIN_HANG_NOTICE_COUNT is only probed on e10s.
       Services.telemetry.getHistogramById("PLUGIN_HANG_NOTICE_COUNT").add();
     }
 
-    this._activeReports.set(report, {
-      deselectCount: 0,
-      lastReportFromChild: now,
-      waitCount: 0,
-    });
+    this._activeReports.add(report);
     this.updateWindows();
   },
 
   clearHang(report) {
-    this._recordTelemetryForReport(report, "cleared");
-
     this.removeActiveReport(report);
     this.removePausedReport(report);
     report.userCanceled();
   },
 };
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -4715,18 +4715,17 @@ void nsGlobalWindowInner::FireOfflineSta
     name.AssignLiteral("online");
   }
   nsContentUtils::DispatchTrustedEvent(mDoc, static_cast<EventTarget*>(this),
                                        name, CanBubble::eNo, Cancelable::eNo);
 }
 
 nsGlobalWindowInner::SlowScriptResponse
 nsGlobalWindowInner::ShowSlowScriptDialog(JSContext* aCx,
-                                          const nsString& aAddonId,
-                                          const double aDuration) {
+                                          const nsString& aAddonId) {
   nsresult rv;
 
   if (Preferences::GetBool("dom.always_stop_slow_scripts")) {
     return KillSlowScript;
   }
 
   // If it isn't safe to run script, then it isn't safe to bring up the prompt
   // (since that spins the event loop). In that (rare) case, we just kill the
@@ -4764,18 +4763,17 @@ nsGlobalWindowInner::ShowSlowScriptDialo
   SetCursor("auto"_ns, IgnoreErrors());
 
   if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) {
     ProcessHangMonitor::SlowScriptAction action;
     RefPtr<ProcessHangMonitor> monitor = ProcessHangMonitor::Get();
     nsIDocShell* docShell = GetDocShell();
     nsCOMPtr<nsIBrowserChild> child =
         docShell ? docShell->GetBrowserChild() : nullptr;
-    action =
-        monitor->NotifySlowScript(child, filename.get(), aAddonId, aDuration);
+    action = monitor->NotifySlowScript(child, filename.get(), aAddonId);
     if (action == ProcessHangMonitor::Terminate) {
       return KillSlowScript;
     }
     if (action == ProcessHangMonitor::TerminateGlobal) {
       return KillScriptGlobal;
     }
 
     if (action == ProcessHangMonitor::StartDebugger) {
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -477,18 +477,17 @@ class nsGlobalWindowInner final : public
   enum SlowScriptResponse {
     ContinueSlowScript = 0,
     ContinueSlowScriptAndKeepNotifying,
     AlwaysContinueSlowScript,
     KillSlowScript,
     KillScriptGlobal
   };
   SlowScriptResponse ShowSlowScriptDialog(JSContext* aCx,
-                                          const nsString& aAddonId,
-                                          const double aDuration);
+                                          const nsString& aAddonId);
 
   // Inner windows only.
   void AddGamepad(uint32_t aIndex, mozilla::dom::Gamepad* aGamepad);
   void RemoveGamepad(uint32_t aIndex);
   void GetGamepads(nsTArray<RefPtr<mozilla::dom::Gamepad>>& aGamepads);
   already_AddRefed<mozilla::dom::Gamepad> GetGamepad(uint32_t aIndex);
   void SetHasSeenGamepadInput(bool aHasSeen);
   bool HasSeenGamepadInput();
--- a/dom/ipc/PProcessHangMonitor.ipdl
+++ b/dom/ipc/PProcessHangMonitor.ipdl
@@ -15,17 +15,16 @@ using mozilla::layers::LayersObserverEpo
 
 namespace mozilla {
 
 struct SlowScriptData
 {
   TabId tabId;
   nsCString filename;
   nsString addonId;
-  double duration;
 };
 
 struct PluginHangData
 {
   uint32_t pluginId;
   ProcessId contentProcessId;
 };
 
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -84,20 +84,19 @@ class HangMonitorChild : public PProcess
   explicit HangMonitorChild(ProcessHangMonitor* aMonitor);
   ~HangMonitorChild() override;
 
   void Bind(Endpoint<PProcessHangMonitorChild>&& aEndpoint);
 
   typedef ProcessHangMonitor::SlowScriptAction SlowScriptAction;
   SlowScriptAction NotifySlowScript(nsIBrowserChild* aBrowserChild,
                                     const char* aFileName,
-                                    const nsString& aAddonId,
-                                    const double aDuration);
+                                    const nsString& aAddonId);
   void NotifySlowScriptAsync(TabId aTabId, const nsCString& aFileName,
-                             const nsString& aAddonId, const double aDuration);
+                             const nsString& aAddonId);
 
   bool IsDebuggerStartupComplete();
 
   void NotifyPluginHang(uint32_t aPluginId);
   void NotifyPluginHangAsync(uint32_t aPluginId);
 
   void ClearHang();
   void ClearHangAsync();
@@ -585,27 +584,25 @@ void HangMonitorChild::Bind(Endpoint<PPr
   MOZ_ASSERT(ok);
 
   sInitializing = false;
   mal.Notify();
 }
 
 void HangMonitorChild::NotifySlowScriptAsync(TabId aTabId,
                                              const nsCString& aFileName,
-                                             const nsString& aAddonId,
-                                             const double aDuration) {
+                                             const nsString& aAddonId) {
   if (mIPCOpen) {
-    Unused << SendHangEvidence(
-        SlowScriptData(aTabId, aFileName, aAddonId, aDuration));
+    Unused << SendHangEvidence(SlowScriptData(aTabId, aFileName, aAddonId));
   }
 }
 
 HangMonitorChild::SlowScriptAction HangMonitorChild::NotifySlowScript(
     nsIBrowserChild* aBrowserChild, const char* aFileName,
-    const nsString& aAddonId, const double aDuration) {
+    const nsString& aAddonId) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   mSentReport = true;
 
   {
     MonitorAutoLock lock(mMonitor);
 
     if (mTerminateScript) {
@@ -627,20 +624,19 @@ HangMonitorChild::SlowScriptAction HangM
   TabId id;
   if (aBrowserChild) {
     RefPtr<BrowserChild> browserChild =
         static_cast<BrowserChild*>(aBrowserChild);
     id = browserChild->GetTabId();
   }
   nsAutoCString filename(aFileName);
 
-  Dispatch(NewNonOwningRunnableMethod<TabId, nsCString, nsString, double>(
+  Dispatch(NewNonOwningRunnableMethod<TabId, nsCString, nsString>(
       "HangMonitorChild::NotifySlowScriptAsync", this,
-      &HangMonitorChild::NotifySlowScriptAsync, id, filename, aAddonId,
-      aDuration));
+      &HangMonitorChild::NotifySlowScriptAsync, id, filename, aAddonId));
   return SlowScriptAction::Continue;
 }
 
 bool HangMonitorChild::IsDebuggerStartupComplete() {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   MonitorAutoLock lock(mMonitor);
 
@@ -850,22 +846,21 @@ void HangMonitorParent::SendHangNotifica
   nsCOMPtr<nsIObserverService> observerService =
       mozilla::services::GetObserverService();
   observerService->NotifyObservers(mProcess, "process-hang-report", nullptr);
 }
 
 void HangMonitorParent::ClearHangNotification() {
   // chrome process, main thread
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
+  mProcess->ClearHang();
 
   nsCOMPtr<nsIObserverService> observerService =
       mozilla::services::GetObserverService();
   observerService->NotifyObservers(mProcess, "clear-hang-report", nullptr);
-
-  mProcess->ClearHang();
 }
 
 // Take a minidump of the browser process if one wasn't already taken for the
 // plugin that caused the hang. Return false if a dump was already available or
 // true if new one has been taken.
 bool HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd,
                                             nsString& aCrashId) {
   MutexAutoLock lock(mBrowserCrashDumpHashLock);
@@ -1008,27 +1003,16 @@ HangMonitoredProcess::GetHangType(uint32
       MOZ_ASSERT_UNREACHABLE("Unexpected HangData type");
       return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-HangMonitoredProcess::GetHangDuration(double* aHangDuration) {
-  MOZ_RELEASE_ASSERT(NS_IsMainThread());
-  if (mHangData.type() != HangData::TSlowScriptData) {
-    *aHangDuration = -1;
-  } else {
-    *aHangDuration = mHangData.get_SlowScriptData().duration();
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 HangMonitoredProcess::GetScriptBrowser(Element** aBrowser) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (mHangData.type() != HangData::TSlowScriptData) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   TabId tabId = mHangData.get_SlowScriptData().tabId();
   if (!mContentParent) {
@@ -1278,20 +1262,20 @@ ProcessHangMonitor::Observe(nsISupports*
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     obs->RemoveObserver(this, "xpcom-shutdown");
   }
   return NS_OK;
 }
 
 ProcessHangMonitor::SlowScriptAction ProcessHangMonitor::NotifySlowScript(
     nsIBrowserChild* aBrowserChild, const char* aFileName,
-    const nsString& aAddonId, const double aDuration) {
+    const nsString& aAddonId) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   return HangMonitorChild::Get()->NotifySlowScript(aBrowserChild, aFileName,
-                                                   aAddonId, aDuration);
+                                                   aAddonId);
 }
 
 bool ProcessHangMonitor::IsDebuggerStartupComplete() {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   return HangMonitorChild::Get()->IsDebuggerStartupComplete();
 }
 
 bool ProcessHangMonitor::ShouldTimeOutCPOWs() {
--- a/dom/ipc/ProcessHangMonitor.h
+++ b/dom/ipc/ProcessHangMonitor.h
@@ -65,18 +65,17 @@ class ProcessHangMonitor final : public 
   enum SlowScriptAction {
     Continue,
     Terminate,
     StartDebugger,
     TerminateGlobal,
   };
   SlowScriptAction NotifySlowScript(nsIBrowserChild* aBrowserChild,
                                     const char* aFileName,
-                                    const nsString& aAddonId,
-                                    const double aDuration);
+                                    const nsString& aAddonId);
 
   void NotifyPluginHang(uint32_t aPluginId);
 
   bool IsDebuggerStartupComplete();
 
   void InitiateCPOWTimeout();
   bool ShouldTimeOutCPOWs();
 
--- a/dom/ipc/nsIHangReport.idl
+++ b/dom/ipc/nsIHangReport.idl
@@ -27,18 +27,16 @@ interface nsIHangReport : nsISupports
   // The type of hang being reported: SLOW_SCRIPT or PLUGIN_HANG.
   readonly attribute unsigned long hangType;
 
   // For SLOW_SCRIPT reports, these fields contain information about the
   // slow script.
   // Only valid for SLOW_SCRIPT reports.
   readonly attribute Element scriptBrowser;
   readonly attribute ACString scriptFileName;
-  // Duration of the hang so far.
-  readonly attribute double hangDuration;
   readonly attribute AString addonId;
 
   // For PLUGIN_HANGs, this field contains information about the plugin.
   // Only valid for PLUGIN_HANG reports.
   readonly attribute ACString pluginName;
 
   // Called by front end code when user ignores or cancels
   // the notification.
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -614,18 +614,17 @@ bool XPCJSContext::InterruptCallback(JSC
   // has finished bootstrapping. Avoid crashing in nsContentUtils below.
   if (!nsContentUtils::IsInitialized()) {
     return true;
   }
 
   // This is at least the second interrupt callback we've received since
   // returning to the event loop. See how long it's been, and what the limit
   // is.
-  TimeStamp now = TimeStamp::NowLoRes();
-  TimeDuration duration = now - self->mSlowScriptCheckpoint;
+  TimeDuration duration = TimeStamp::NowLoRes() - self->mSlowScriptCheckpoint;
   int32_t limit;
 
   nsString addonId;
   const char* prefName;
 
   auto principal = BasePrincipal::Cast(nsContentUtils::SubjectPrincipal(cx));
   bool chrome = principal->Is<SystemPrincipal>();
   if (chrome) {
@@ -640,23 +639,23 @@ bool XPCJSContext::InterruptCallback(JSC
     limit = Preferences::GetInt(prefName, 10);
   }
 
   // If there's no limit, or we're within the limit, let it go.
   if (limit == 0 || duration.ToSeconds() < limit / 2.0) {
     return true;
   }
 
-  self->mSlowScriptCheckpoint = now;
   self->mSlowScriptActualWait += duration;
 
   // In order to guard against time changes or laptops going to sleep, we
   // don't trigger the slow script warning until (limit/2) seconds have
   // elapsed twice.
   if (!self->mSlowScriptSecondHalf) {
+    self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();
     self->mSlowScriptSecondHalf = true;
     return true;
   }
 
   //
   // This has gone on long enough! Time to take action. ;-)
   //
 
@@ -696,18 +695,18 @@ bool XPCJSContext::InterruptCallback(JSC
   if (!chrome && !self->mTimeoutAccumulated) {
     uint32_t delay = uint32_t(self->mSlowScriptActualWait.ToMilliseconds() -
                               (limit * 1000.0));
     Telemetry::Accumulate(Telemetry::SLOW_SCRIPT_NOTIFY_DELAY, delay);
     self->mTimeoutAccumulated = true;
   }
 
   // Show the prompt to the user, and kill if requested.
-  nsGlobalWindowInner::SlowScriptResponse response = win->ShowSlowScriptDialog(
-      cx, addonId, self->mSlowScriptActualWait.ToMilliseconds());
+  nsGlobalWindowInner::SlowScriptResponse response =
+      win->ShowSlowScriptDialog(cx, addonId);
   if (response == nsGlobalWindowInner::KillSlowScript) {
     if (Preferences::GetBool("dom.global_stop_script", true)) {
       xpc::Scriptability::Get(global).Block();
     }
     return false;
   }
   if (response == nsGlobalWindowInner::KillScriptGlobal) {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@@ -731,17 +730,17 @@ bool XPCJSContext::InterruptCallback(JSC
       return false;
     }
 
     obs->NotifyObservers(supports, "kill-content-script-sandbox", nullptr);
     return false;
   }
 
   // The user chose to continue the script. Reset the timer, and disable this
-  // machinery with a pref if the user opted out of future slow-script dialogs.
+  // machinery with a pref of the user opted out of future slow-script dialogs.
   if (response != nsGlobalWindowInner::ContinueSlowScriptAndKeepNotifying) {
     self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();
   }
 
   if (response == nsGlobalWindowInner::AlwaysContinueSlowScript) {
     Preferences::SetInt(prefName, 0);
   }
 
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -2266,43 +2266,16 @@ security.ui.certerror:
     record_in_processes: ["content"]
     products:
       - firefox
     extra_keys:
       is_frame: If the error page is loaded in an iframe.
       has_sts: If the error page is for a site with HSTS headers or with a pinned key.
       panel_open: If the advanced panel was open at the time of the interaction.
 
-slow_script_warning:
-  shown:
-    bug_numbers:
-      - 1652613
-    description: >
-      Recorded when a slow script hang is resolved.
-    products:
-      - "firefox"
-    record_in_processes: ["main"]
-    release_channel_collection: opt-out
-    expiry_version: "85"
-    notification_emails:
-      - esmyth@mozilla.com
-      - gkruitbosch@mozilla.com
-    # Whether the hung script was for a content or browser process.
-    objects: [
-      "browser",
-      "content",
-    ]
-    extra_keys:
-      end_reason: Why the warning was hidden (user action, the process becoming responsive again, the browser quitting, etc.)
-      wait_count: How many times the user elected to wait.
-      hang_duration: How long we believe the hang continued (ms).
-      n_tab_deselect: How many times the user switched away from a tab affected by this hang.
-      uri_type: The kind of script URL that hung.
-      uptime: How long the notification was up (ms).
-
 webrtc.ui:
   share_display:
     objects:
       - screen
       - window
       - browser_window
     description: >
       Recorded when a display is shared. The value for this event is a unique