Bug 1950710 - Migrate histograms to use Glean APIs for FULLSCREEN_CHANGE_MS, r=chutten,pip-reviewers,mconley.

Differential Revision: https://phabricator.services.mozilla.com/D242233
This commit is contained in:
Florian Quèze
2025-03-26 15:25:39 +00:00
parent 0e492d56a9
commit 9bc61f69d8
6 changed files with 50 additions and 11 deletions

View File

@@ -174,7 +174,8 @@ export class DOMFullscreenParent extends JSWindowActorParent {
this.waitingForChildExitFullscreen = false;
Services.obs.notifyObservers(window, "fullscreen-painted");
this.sendAsyncMessage("DOMFullscreen:Painted", {});
TelemetryStopwatch.finish("FULLSCREEN_CHANGE_MS");
Glean.fullscreen.change.stopAndAccumulate(this.timerId);
this.timerId = null;
break;
}
}
@@ -215,7 +216,7 @@ export class DOMFullscreenParent extends JSWindowActorParent {
window.gXPInstallObserver.removeAllNotifications(browser);
}
TelemetryStopwatch.start("FULLSCREEN_CHANGE_MS");
this.timerId = Glean.fullscreen.change.start();
window.FullScreen.enterDomFullscreen(browser, this);
this.updateFullscreenWindowReference(window);
@@ -227,7 +228,7 @@ export class DOMFullscreenParent extends JSWindowActorParent {
break;
}
case "MozDOMFullscreen:Exited": {
TelemetryStopwatch.start("FULLSCREEN_CHANGE_MS");
this.timerId = Glean.fullscreen.change.start();
// Make sure that the actor has not been destroyed before
// accessing its browsing context. Otherwise, a error may

View File

@@ -0,0 +1,30 @@
# 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:
- 'Firefox :: General'
fullscreen:
change:
type: timing_distribution
description: >
The time content uses to enter/exit fullscreen regardless of fullscreen
transition timeout
This metric was generated to correspond to the Legacy Telemetry
exponential histogram FULLSCREEN_CHANGE_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1271160
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1271160
notification_emails:
- mozilla-telemetry@upsuper.org
expires: never
telemetry_mirror: FULLSCREEN_CHANGE_MS

View File

@@ -525,7 +525,7 @@ var FullScreen = {
// If there is no appropriate actor to send the message we have
// no way to complete the transition and should abort by exiting
// fullscreen.
this._abortEnterFullscreen();
this._abortEnterFullscreen(aActor);
return;
}
// Record that the actor is waiting for its child to enter
@@ -552,7 +552,7 @@ var FullScreen = {
// full-screen was made. Cancel full-screen.
Services.focus.activeWindow != window
) {
this._abortEnterFullscreen();
this._abortEnterFullscreen(aActor);
return;
}
@@ -670,17 +670,18 @@ var FullScreen = {
return needToWaitForChildExit;
},
_abortEnterFullscreen() {
_abortEnterFullscreen(aActor) {
// This function is called synchronously in fullscreen change, so
// we have to avoid calling exitFullscreen synchronously here.
//
// This could reject if we're not currently in fullscreen
// so just ignore rejection.
setTimeout(() => document.exitFullscreen().catch(() => {}), 0);
if (TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS")) {
if (aActor.timerId) {
// Cancel the stopwatch for any fullscreen change to avoid
// errors if it is started again.
TelemetryStopwatch.cancel("FULLSCREEN_CHANGE_MS");
Glean.fullscreen.change.cancel(aActor.timerId);
aActor.timerId = null;
}
},

View File

@@ -1332,7 +1332,9 @@ add_task(async function test_dom_full_screen() {
await exited;
await BrowserTestUtils.waitForCondition(() => {
return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
return !gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.getActor(
"DOMFullscreen"
).timerId;
});
if (AppConstants.platform == "macosx") {

View File

@@ -104,6 +104,7 @@ gecko_metrics = [
# Metrics that are sent by Firefox Desktop
# Order is lexicographical, enforced by t/c/glean/tests/pytest/test_yaml_indices.py
firefox_desktop_metrics = [
"browser/actors/metrics.yaml",
"browser/components/asrouter/metrics.yaml",
"browser/components/backup/metrics.yaml",
"browser/components/doh/metrics.yaml",

View File

@@ -873,7 +873,9 @@ async function promiseFullscreenEntered(window, asyncFn) {
await entered;
await BrowserTestUtils.waitForCondition(() => {
return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
return !gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.getActor(
"DOMFullscreen"
).timerId;
});
if (AppConstants.platform == "macosx") {
@@ -907,7 +909,9 @@ async function promiseFullscreenExited(window, asyncFn) {
await exited;
await BrowserTestUtils.waitForCondition(() => {
return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
return !gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.getActor(
"DOMFullscreen"
).timerId;
});
if (AppConstants.platform == "macosx") {