diff --git a/dom/canvas/CanvasRenderingContextHelper.cpp b/dom/canvas/CanvasRenderingContextHelper.cpp index 992eb829c375..59dd28a6e75f 100644 --- a/dom/canvas/CanvasRenderingContextHelper.cpp +++ b/dom/canvas/CanvasRenderingContextHelper.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/CanvasRenderingContext2D.h" #include "mozilla/dom/OffscreenCanvasRenderingContext2D.h" #include "mozilla/GfxMessageUtils.h" +#include "mozilla/glean/DomCanvasMetrics.h" #include "mozilla/Telemetry.h" #include "mozilla/UniquePtr.h" #include "mozilla/webgpu/CanvasContext.h" @@ -147,24 +148,26 @@ CanvasRenderingContextHelper::CreateContextHelper( break; case CanvasContextType::Canvas2D: - Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1); + glean::canvas::used_2d.EnumGet(glean::canvas::Used2dLabel::eTrue).Add(); ret = new CanvasRenderingContext2D(aCompositorBackend); break; case CanvasContextType::OffscreenCanvas2D: - Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1); + glean::canvas::used_2d.EnumGet(glean::canvas::Used2dLabel::eTrue).Add(); ret = new OffscreenCanvasRenderingContext2D(aCompositorBackend); break; case CanvasContextType::WebGL1: - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1); + glean::canvas::webgl_used.EnumGet(glean::canvas::WebglUsedLabel::eTrue) + .Add(); ret = new ClientWebGLContext(/*webgl2:*/ false); break; case CanvasContextType::WebGL2: - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1); + glean::canvas::webgl_used.EnumGet(glean::canvas::WebglUsedLabel::eTrue) + .Add(); ret = new ClientWebGLContext(/*webgl2:*/ true); @@ -238,18 +241,26 @@ already_AddRefed CanvasRenderingContextHelper::GetOrCreateContext( // We want to throw only if dictionary initialization fails, // so only in case aRv has been set to some error value. if (aContextType == CanvasContextType::WebGL1) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_SUCCESS, 0); + glean::canvas::webgl_success + .EnumGet(glean::canvas::WebglSuccessLabel::eFalse) + .Add(); } else if (aContextType == CanvasContextType::WebGL2) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL2_SUCCESS, 0); + glean::canvas::webgl2_success + .EnumGet(glean::canvas::Webgl2SuccessLabel::eFalse) + .Add(); } else if (aContextType == CanvasContextType::WebGPU) { // Telemetry::Accumulate(Telemetry::CANVAS_WEBGPU_SUCCESS, 0); } return nullptr; } if (aContextType == CanvasContextType::WebGL1) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_SUCCESS, 1); + glean::canvas::webgl_success + .EnumGet(glean::canvas::WebglSuccessLabel::eTrue) + .Add(); } else if (aContextType == CanvasContextType::WebGL2) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL2_SUCCESS, 1); + glean::canvas::webgl2_success + .EnumGet(glean::canvas::Webgl2SuccessLabel::eTrue) + .Add(); } else if (aContextType == CanvasContextType::WebGPU) { // Telemetry::Accumulate(Telemetry::CANVAS_WEBGPU_SUCCESS, 1); } diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index ab8cab3d8baa..3a60b55686be 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -43,7 +43,7 @@ #include "mozilla/Services.h" #include "mozilla/StaticPrefs_webgl.h" #include "mozilla/SVGObserverUtils.h" -#include "mozilla/Telemetry.h" +#include "mozilla/glean/DomCanvasMetrics.h" #include "nsContentUtils.h" #include "nsDisplayList.h" #include "nsError.h" @@ -561,10 +561,11 @@ RefPtr WebGLContext::Create(HostWebGLContext* host, for (const auto& cur : failReasons) { // Don't try to accumulate using an empty key if |cur.key| is empty. if (cur.key.IsEmpty()) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, - "FEATURE_FAILURE_REASON_UNKNOWN"_ns); + glean::canvas::webgl_failure_id + .Get("FEATURE_FAILURE_REASON_UNKNOWN"_ns) + .Add(1); } else { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, cur.key); + glean::canvas::webgl_failure_id.Get(cur.key).Add(1); } const auto str = nsPrintfCString("\n* %s (%s)", cur.info.BeginReading(), @@ -608,7 +609,7 @@ RefPtr WebGLContext::Create(HostWebGLContext* host, if (res.isOk()) { failureId = "SUCCESS"_ns; } - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, failureId); + glean::canvas::webgl_failure_id.Get(failureId).Add(1); if (!res.isOk()) { out->error = res.unwrapErr(); diff --git a/dom/canvas/metrics.yaml b/dom/canvas/metrics.yaml new file mode 100644 index 000000000000..a9be1eb691c5 --- /dev/null +++ b/dom/canvas/metrics.yaml @@ -0,0 +1,131 @@ +# 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/. + +# Adding a new metric? We have docs for that! +# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html + +--- +$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 +$tags: + - 'Core :: Graphics: Canvas2D' + +canvas: + used_2d: + type: labeled_counter + description: > + 2D canvas used + + This metric was generated to correspond to the Legacy Telemetry boolean + histogram CANVAS_2D_USED. + labels: + - "false" + - "true" + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_2D_USED + + webgl_accl_failure_id: + type: labeled_counter + description: > + Track the failure IDs that lead us to reject attempting to create an + accelerated context. CANVAS_WEBGL_FAILURE_ID reports the overall WebGL + status with the attempt to fallback. + + This metric was generated to correspond to the Legacy Telemetry count + histogram CANVAS_WEBGL_ACCL_FAILURE_ID. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1272808 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1272808 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + - rhunt@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_WEBGL_ACCL_FAILURE_ID + + webgl_failure_id: + type: labeled_counter + description: > + WebGL runtime and dynamic failure IDs. This will record a count for each + context creation success or failure. Each failure id is a unique + identifier that can be traced back to a particular failure branch or + blocklist rule. + + This metric was generated to correspond to the Legacy Telemetry count + histogram CANVAS_WEBGL_FAILURE_ID. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1272808 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1272808 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + - rhunt@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_WEBGL_FAILURE_ID + + webgl_success: + type: labeled_counter + description: > + WebGL1 creation success + + This metric was generated to correspond to the Legacy Telemetry boolean + histogram CANVAS_WEBGL_SUCCESS. + labels: + - "false" + - "true" + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1247327 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1529352 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1247327 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1529352 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + - rhunt@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_WEBGL_SUCCESS + + webgl_used: + type: labeled_counter + description: > + WebGL canvas used + + This metric was generated to correspond to the Legacy Telemetry boolean + histogram CANVAS_WEBGL_USED. + labels: + - "false" + - "true" + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_WEBGL_USED + + webgl2_success: + type: labeled_counter + description: > + WebGL2 creation success + + This metric was generated to correspond to the Legacy Telemetry boolean + histogram CANVAS_WEBGL2_SUCCESS. + labels: + - "false" + - "true" + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1247327 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1247327 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + - rhunt@mozilla.com + expires: never + telemetry_mirror: h#CANVAS_WEBGL2_SUCCESS diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index e381dea28cd4..d26b61896329 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -12,7 +12,7 @@ #include "mozilla/Assertions.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/Logging.h" -#include "mozilla/Telemetry.h" +#include "mozilla/glean/DomCanvasMetrics.h" #include "mozilla/Tokenizer.h" #include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_gfx.h" @@ -558,7 +558,9 @@ bool GLLibraryEGL::Init(nsACString* const out_failureId) { #define SYMBOL(X) \ { \ (PRFuncPtr*)&mSymbols.f##X, { \ - { "egl" #X } \ + { \ + "egl" #X \ + } \ } \ } #define END_OF_SYMBOLS \ @@ -908,15 +910,14 @@ std::shared_ptr GLLibraryEGL::CreateDisplayLocked( // Report the acceleration status to telemetry if (!ret) { if (accelAngleFailureId.IsEmpty()) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - "FEATURE_FAILURE_ACCL_ANGLE_UNKNOWN"_ns); + glean::canvas::webgl_accl_failure_id + .Get("FEATURE_FAILURE_ACCL_ANGLE_UNKNOWN"_ns) + .Add(1); } else { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - accelAngleFailureId); + glean::canvas::webgl_accl_failure_id.Get(accelAngleFailureId).Add(1); } } else { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - "SUCCESS"_ns); + glean::canvas::webgl_accl_failure_id.Get("SUCCESS"_ns).Add(1); } // Fallback to a WARP display if ANGLE fails, or if WARP is forced diff --git a/toolkit/components/glean/metrics_index.py b/toolkit/components/glean/metrics_index.py index a07c57f830db..d6d21ce950ae 100644 --- a/toolkit/components/glean/metrics_index.py +++ b/toolkit/components/glean/metrics_index.py @@ -24,6 +24,7 @@ gecko_metrics = [ "devtools/client/shared/metrics.yaml", "docshell/base/metrics.yaml", "dom/base/use_counter_metrics.yaml", + "dom/canvas/metrics.yaml", "dom/crypto/metrics.yaml", "dom/geolocation/metrics.yaml", "dom/localstorage/metrics.yaml",