commit d69e3ab03d9cc0ddd577f3996dcfa72d211201b1
parent abbc9d779e61a42b22303023f044f90db8f0309d
Author: Andy Leiserson <aleiserson@mozilla.com>
Date: Thu, 30 Oct 2025 00:31:33 +0000
Bug 1996893 - Add use counters for WebGPU r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D270373
Diffstat:
5 files changed, 149 insertions(+), 6 deletions(-)
diff --git a/dom/base/UseCounters.conf b/dom/base/UseCounters.conf
@@ -412,6 +412,10 @@ custom feTurbulence uses the feTurbulence SVG filter.
custom WrFilterFallback triggers the blob fallback for an SVG filter.
+// WebGPU
+custom WebgpuRequestAdapter requests a WebGPU adapter
+custom WebgpuRenderOutput displays WebGPU rendering output
+
// Sanitizer API
method Sanitizer.constructor
method Sanitizer.sanitize
diff --git a/dom/base/UseCountersWorker.conf b/dom/base/UseCountersWorker.conf
@@ -99,3 +99,6 @@ custom PrivateBrowsingCachesDelete calls caches.delete in Private Browsing Mode
custom PrivateBrowsingCachesKeys calls caches.keys in Private Browsing Mode
method Scheduler.postTask
+
+// WebGPU
+custom WebgpuRequestAdapter requests a WebGPU adapter
diff --git a/dom/base/use_counter_metrics.yaml b/dom/base/use_counter_metrics.yaml
@@ -108,8 +108,8 @@ use.counter:
send_in_pings:
- use-counters
-# Total of 2367 use counter metrics (excludes denominators).
-# Total of 355 'page' use counters.
+# Total of 2374 use counter metrics (excludes denominators).
+# Total of 357 'page' use counters.
use.counter.page:
svgsvgelement_getelementbyid:
type: counter
@@ -5602,6 +5602,40 @@ use.counter.page:
send_in_pings:
- use-counters
+ webgpu_request_adapter:
+ type: counter
+ description: >
+ Whether a page requests a WebGPU adapter.
+ Compare against `use.counter.top_level_content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ webgpu_render_output:
+ type: counter
+ description: >
+ Whether a page displays WebGPU rendering output.
+ Compare against `use.counter.top_level_content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
sanitizer_constructor:
type: counter
description: >
@@ -6146,7 +6180,7 @@ use.counter.page:
send_in_pings:
- use-counters
-# Total of 355 'document' use counters.
+# Total of 357 'document' use counters.
use.counter.doc:
svgsvgelement_getelementbyid:
type: counter
@@ -11639,6 +11673,40 @@ use.counter.doc:
send_in_pings:
- use-counters
+ webgpu_request_adapter:
+ type: counter
+ description: >
+ Whether a document requests a WebGPU adapter.
+ Compare against `use.counter.content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ webgpu_render_output:
+ type: counter
+ description: >
+ Whether a document displays WebGPU rendering output.
+ Compare against `use.counter.content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
sanitizer_constructor:
type: counter
description: >
@@ -12183,7 +12251,7 @@ use.counter.doc:
send_in_pings:
- use-counters
-# Total of 53 'dedicated worker' use counters.
+# Total of 54 'dedicated worker' use counters.
use.counter.worker.dedicated:
pushmanager_subscribe:
type: counter
@@ -13086,7 +13154,24 @@ use.counter.worker.dedicated:
send_in_pings:
- use-counters
-# Total of 53 'shared worker' use counters.
+ webgpu_request_adapter:
+ type: counter
+ description: >
+ Whether a dedicated worker requests a WebGPU adapter.
+ Compare against `use.counter.dedicated_workers_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+# Total of 54 'shared worker' use counters.
use.counter.worker.shared:
pushmanager_subscribe:
type: counter
@@ -13989,7 +14074,24 @@ use.counter.worker.shared:
send_in_pings:
- use-counters
-# Total of 53 'service worker' use counters.
+ webgpu_request_adapter:
+ type: counter
+ description: >
+ Whether a shared worker requests a WebGPU adapter.
+ Compare against `use.counter.shared_workers_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+# Total of 54 'service worker' use counters.
use.counter.worker.service:
pushmanager_subscribe:
type: counter
@@ -14892,6 +14994,23 @@ use.counter.worker.service:
send_in_pings:
- use-counters
+ webgpu_request_adapter:
+ type: counter
+ description: >
+ Whether a service worker requests a WebGPU adapter.
+ Compare against `use.counter.service_workers_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
# Total of 45 'deprecated operations (page)' use counters.
use.counter.deprecated_ops.page:
components:
diff --git a/dom/webgpu/CanvasContext.cpp b/dom/webgpu/CanvasContext.cpp
@@ -258,6 +258,14 @@ Maybe<layers::SurfaceDescriptor> CanvasContext::SwapChainPresent() {
!mCurrentTexture) {
return Nothing();
}
+
+ if (mCanvasElement) {
+ JSObject* obj = mCanvasElement->GetWrapper();
+ if (obj) {
+ dom::SetUseCounter(obj, eUseCounter_custom_WebgpuRenderOutput);
+ }
+ }
+
mLastRemoteTextureId = Some(layers::RemoteTextureId::GetNext());
mChild->SwapChainPresent(mCurrentTexture->GetId(), *mLastRemoteTextureId,
*mRemoteTextureOwnerId);
diff --git a/dom/webgpu/Instance.cpp b/dom/webgpu/Instance.cpp
@@ -105,6 +105,15 @@ already_AddRefed<dom::Promise> Instance::RequestAdapter(
return nullptr;
}
+ if (NS_IsMainThread()) {
+ JSObject* obj = mOwner->GetGlobalJSObject();
+ if (obj) {
+ dom::SetUseCounter(obj, eUseCounter_custom_WebgpuRequestAdapter);
+ }
+ } else {
+ dom::SetUseCounter(UseCounterWorker::Custom_WebgpuRequestAdapter);
+ }
+
// -
// Check if we should allow the request.