Bug 1271160 - Add telemetry items for fullscreen transition. r=smaug
MozReview-Commit-ID: EvmLvE5VWOu
--- a/browser/base/content/browser-fullScreen.js
+++ b/browser/base/content/browser-fullScreen.js
@@ -126,20 +126,22 @@ var FullScreen = {
// to get its corresponding browser here.
let browser;
if (event.target == gBrowser) {
browser = event.originalTarget;
} else {
let topWin = event.target.ownerDocument.defaultView.top;
browser = gBrowser.getBrowserForContentWindow(topWin);
}
+ TelemetryStopwatch.start("FULLSCREEN_CHANGE_MS");
this.enterDomFullscreen(browser);
break;
}
case "MozDOMFullscreen:Exited":
+ TelemetryStopwatch.start("FULLSCREEN_CHANGE_MS");
this.cleanupDomFullscreen();
break;
}
},
receiveMessage: function(aMessage) {
let browser = aMessage.target;
switch (aMessage.name) {
@@ -152,16 +154,17 @@ var FullScreen = {
break;
}
case "DOMFullscreen:Exit": {
this._windowUtils.remoteFrameFullscreenReverted();
break;
}
case "DOMFullscreen:Painted": {
Services.obs.notifyObservers(window, "fullscreen-painted", "");
+ TelemetryStopwatch.finish("FULLSCREEN_CHANGE_MS");
break;
}
}
},
enterDomFullscreen : function(aBrowser) {
if (!document.fullscreenElement) {
return;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -6257,16 +6257,17 @@ private:
static const char* const kPaintedTopic;
RefPtr<nsGlobalWindow> mWindow;
nsCOMPtr<nsIWidget> mWidget;
nsCOMPtr<nsIScreen> mScreen;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsISupports> mTransitionData;
+ TimeStamp mFullscreenChangeStartTime;
FullscreenTransitionDuration mDuration;
Stage mStage;
bool mFullscreen;
};
const char* const
FullscreenTransitionTask::kPaintedTopic = "fullscreen-painted";
@@ -6283,16 +6284,17 @@ FullscreenTransitionTask::Run()
}
if (stage == eBeforeToggle) {
PROFILER_MARKER("Fullscreen transition start");
mWidget->PerformFullscreenTransition(nsIWidget::eBeforeFullscreenToggle,
mDuration.mFadeIn, mTransitionData,
this);
} else if (stage == eToggleFullscreen) {
PROFILER_MARKER("Fullscreen toggle start");
+ mFullscreenChangeStartTime = TimeStamp::Now();
if (MOZ_UNLIKELY(mWindow->mFullScreen != mFullscreen)) {
// This could happen in theory if several fullscreen requests in
// different direction happen continuously in a short time. We
// need to ensure the fullscreen state matches our target here,
// otherwise the widget would change the window state as if we
// toggle for Fullscreen Mode instead of Fullscreen API.
NS_WARNING("The fullscreen state of the window does not match");
mWindow->mFullScreen = mFullscreen;
@@ -6319,16 +6321,18 @@ FullscreenTransitionTask::Run()
// powerful, layout could take a long time, in which case, staying
// in black screen for that long could hurt user experience even
// more than exposing an intermediate state.
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
uint32_t timeout =
Preferences::GetUint("full-screen-api.transition.timeout", 500);
mTimer->Init(observer, timeout, nsITimer::TYPE_ONE_SHOT);
} else if (stage == eAfterToggle) {
+ Telemetry::AccumulateTimeDelta(Telemetry::FULLSCREEN_TRANSITION_BLACK_MS,
+ mFullscreenChangeStartTime);
mWidget->PerformFullscreenTransition(nsIWidget::eAfterFullscreenToggle,
mDuration.mFadeOut, mTransitionData,
this);
} else if (stage == eEnd) {
PROFILER_MARKER("Fullscreen transition end");
}
return NS_OK;
}
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -331,16 +331,36 @@
"FORGET_SKIPPABLE_MAX": {
"alert_emails": ["dev-telemetry-gc-alerts@mozilla.org"],
"expires_in_version": "never",
"kind": "exponential",
"high": 10000,
"n_buckets": 50,
"description": "Max time spent on one forget skippable (ms)"
},
+ "FULLSCREEN_TRANSITION_BLACK_MS": {
+ "alert_emails": ["xquan@mozilla.com"],
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "low": 100,
+ "high": 5000,
+ "n_buckets": 50,
+ "bug_numbers": [1271160],
+ "description": "The time spent in the fully-black screen in fullscreen transition"
+ },
+ "FULLSCREEN_CHANGE_MS": {
+ "alert_emails": ["xquan@mozilla.com"],
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "low": 100,
+ "high": 5000,
+ "n_buckets": 50,
+ "bug_numbers": [1271160],
+ "description": "The time content uses to enter/exit fullscreen regardless of fullscreen transition timeout"
+ },
"GC_REASON_2": {
"alert_emails": ["dev-telemetry-gc-alerts@mozilla.org"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Reason (enum value) for initiating a GC"
},
"GC_IS_COMPARTMENTAL": {