tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1ef03f99181acd3e9e2bf88acbb9fc9e23aa1832
parent 485d9c1f017171aae044681c473ac839800b557c
Author: Ryan Hunt <rhunt@eqrion.net>
Date:   Wed, 17 Dec 2025 15:11:39 +0000

Bug 2002635 - Revert "Bug 1980396: Add a new probe that records 5 minutes of JS activity for documents with asm.js." r=smaug

We don't need this anymore.

This reverts commit 90af3b6a63d9035d59e2f818bdd2fdc2ab84f6fa.

Differential Revision: https://phabricator.services.mozilla.com/D275815

Diffstat:
Mdom/base/Document.cpp | 94+------------------------------------------------------------------------------
Mdom/base/Document.h | 8--------
Mdom/metrics.yaml | 16----------------
3 files changed, 1 insertion(+), 117 deletions(-)

diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp @@ -2058,91 +2058,6 @@ void Document::LoadEventFired() { } } -static void RecordExecutionTimeForAsmJS(Document* aDoc) { - if (aDoc->GetScopeObject()) { - AutoJSAPI jsapi; - if (!jsapi.Init(aDoc->GetScopeObject())) { - return; - } - - if (JSContext* cx = jsapi.cx()) { - // Disable the execution timer. - JS::SetMeasuringExecutionTimeEnabled(cx, false); - - // Get the execution time and accumulate it. - JS::JSTimers timers = JS::GetJSTimers(cx); - mozilla::glean::perf::js_exec_asm_js.AccumulateRawDuration( - timers.executionTime); - } - } -} - -class ASMJSExecutionTimeRecorder final : public nsITimerCallback, - public nsINamed { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSITIMERCALLBACK - NS_DECL_NSINAMED - - explicit ASMJSExecutionTimeRecorder(Document* aDocument) - : mDocument(aDocument) {} - - private: - ~ASMJSExecutionTimeRecorder() = default; - WeakPtr<Document> mDocument; -}; - -NS_IMPL_ISUPPORTS(ASMJSExecutionTimeRecorder, nsITimerCallback, nsINamed) - -NS_IMETHODIMP -ASMJSExecutionTimeRecorder::Notify(nsITimer* aTimer) { - RefPtr<Document> doc(mDocument); - if (!doc) { - return NS_OK; - } - - // Record the JS execution time to Glean. - RecordExecutionTimeForAsmJS(doc); - return NS_OK; -} - -NS_IMETHODIMP -ASMJSExecutionTimeRecorder::GetName(nsACString& aName) { - aName.AssignLiteral("ASMJSExecutionTimeRecorder"); - return NS_OK; -} - -// If an asm.js use counter is set, then enable the JS execution -// timer and record it after 5 minutes of activity. -void Document::RecordASMJSExecutionTime() { - // Skip if the document is being destroyed. - if (mIsGoingAway) { - return; - } - - // If the timer has already fired, or the use counter is already set, - // then nothing more needs to be done. - if (mASMJSExecutionTimer || HasUseCounter(eUseCounter_custom_JS_use_asm)) { - return; - } - - AutoJSContext cx; - if (static_cast<JSContext*>(cx)) { - JS::SetMeasuringExecutionTimeEnabled(cx, true); - } - - RefPtr<ASMJSExecutionTimeRecorder> callback = - new ASMJSExecutionTimeRecorder(this); - nsresult rv = - NS_NewTimerWithCallback(getter_AddRefs(mASMJSExecutionTimer), callback, - 5 * 60 * 1000, // 5min delay - nsITimer::TYPE_ONE_SHOT); - - if (NS_FAILED(rv)) { - mASMJSExecutionTimer = nullptr; - } -} - void Document::RecordPageLoadEventTelemetry() { // If the page load time is empty, then the content wasn't something we want // to report (i.e. not a top level document). @@ -12325,11 +12240,6 @@ void Document::Destroy() { mIsGoingAway = true; - if (mASMJSExecutionTimer) { - mASMJSExecutionTimer->Cancel(); - mASMJSExecutionTimer = nullptr; - RecordExecutionTimeForAsmJS(this); - } if (mScriptLoader) { mScriptLoader->Destroy(); } @@ -20821,9 +20731,7 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) { } // Stop the JS execution timer once the page is loaded. - // If the asm.js counter is active, then continue the timer - // for telemetry purposes. - if (!aDoc->HasUseCounter(eUseCounter_custom_JS_use_asm)) { + { AutoJSContext cx; if (static_cast<JSContext*>(cx)) { JS::SetMeasuringExecutionTimeEnabled(cx, false); diff --git a/dom/base/Document.h b/dom/base/Document.h @@ -3858,12 +3858,7 @@ class Document : public nsINode, // call it just before the document loses its window. void SendPageUseCounters(); - void RecordASMJSExecutionTime(); - void SetUseCounter(UseCounter aUseCounter) { - if (aUseCounter == eUseCounter_custom_JS_use_asm) { - RecordASMJSExecutionTime(); - } mUseCounters[aUseCounter] = true; } @@ -5349,9 +5344,6 @@ class Document : public nsINode, // This only applies to error pages. Might be null. nsCOMPtr<nsIChannel> mFailedChannel; - // Timer for delayed ASMJS execution time recording - nsCOMPtr<nsITimer> mASMJSExecutionTimer; - // if this document is part of a multipart document, // the ID can be used to distinguish it from the other parts. uint32_t mPartID; diff --git a/dom/metrics.yaml b/dom/metrics.yaml @@ -238,22 +238,6 @@ perf: send_in_pings: - pageload-base-domain - js_exec_asm_js: - type: timing_distribution - description: > - Time in milliseconds spent executing Javascript for top level - documents that contain the asm.js use counter. Measures 5min - of activity after the use counter is set then records - the value in this histogram. - time_unit: millisecond - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1980396 - data_reviews: - - https://phabricator.services.mozilla.com/D259436 - notification_emails: - - perf-telemetry-alerts@mozilla.com - expires: never - h3p_page_load_time: type: labeled_timing_distribution description: >