Bug 1267530 part 1 - Add some profiler marker for fullscreen transition. r=smaug,BenWa
MozReview-Commit-ID: CeFdBO9uz8C
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3149,16 +3149,17 @@ private:
nsSize mSize;
};
LinkedList<OldWindowSize> OldWindowSize::sList;
NS_IMETHODIMP
nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal)
{
+ PROFILER_MARKER("Enter fullscreen");
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_STATE(doc);
// Notify the pres shell that we are starting fullscreen change, and
// set the window dimensions in advance. Since the resize message
// comes after the fullscreen change call, doing so could avoid an
// extra resize reflow after this point.
nsRect screenRect;
@@ -3171,16 +3172,17 @@ nsDOMWindowUtils::HandleFullscreenReques
*aRetVal = nsIDocument::HandlePendingFullscreenRequests(doc);
return NS_OK;
}
nsresult
nsDOMWindowUtils::ExitFullscreen()
{
+ PROFILER_MARKER("Exit fullscreen");
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_STATE(doc);
// Although we would not use the old size if we have already exited
// fullscreen, we still want to cleanup in case we haven't.
nsSize oldSize = OldWindowSize::GetAndRemove(doc->GetWindow());
if (!doc->GetFullscreenElement()) {
return NS_OK;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -5944,17 +5944,19 @@ private:
// transition on the widget.
eBeforeToggle,
// ToggleFullscreen stage actually executes the fullscreen toggle,
// and wait for the next paint on the content to continue.
eToggleFullscreen,
// AfterToggle stage happens after we toggle the fullscreen state.
// In this stage, the task triggers the post-toggle fullscreen
// transition on the widget.
- eAfterToggle
+ eAfterToggle,
+ // End stage is triggered after the final transition finishes.
+ eEnd
};
class Observer final : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
@@ -5990,20 +5992,22 @@ FullscreenTransitionTask::Run()
mStage = Stage(mStage + 1);
if (MOZ_UNLIKELY(mWidget->Destroyed())) {
// If the widget has been destroyed before we get here, don't try to
// do anything more. Just let it go and release ourselves.
NS_WARNING("The widget to fullscreen has been destroyed");
return NS_OK;
}
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");
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;
@@ -6033,16 +6037,18 @@ FullscreenTransitionTask::Run()
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) {
mWidget->PerformFullscreenTransition(nsIWidget::eAfterFullscreenToggle,
mDuration.mFadeOut, mTransitionData,
this);
+ } else if (stage == eEnd) {
+ PROFILER_MARKER("Fullscreen transition end");
}
return NS_OK;
}
NS_IMPL_ISUPPORTS(FullscreenTransitionTask::Observer, nsIObserver)
NS_IMETHODIMP
FullscreenTransitionTask::Observer::Observe(nsISupports* aSubject,
@@ -6053,26 +6059,28 @@ FullscreenTransitionTask::Observer::Obse
if (strcmp(aTopic, FullscreenTransitionTask::kPaintedTopic) == 0) {
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(aSubject));
nsCOMPtr<nsIWidget> widget = win ?
nsGlobalWindow::Cast(win)->GetMainWidget() : nullptr;
if (widget == mTask->mWidget) {
// The paint notification arrives first. Cancel the timer.
mTask->mTimer->Cancel();
shouldContinue = true;
+ PROFILER_MARKER("Fullscreen toggle end");
}
} else {
#ifdef DEBUG
MOZ_ASSERT(strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC) == 0,
"Should only get fullscreen-painted or timer-callback");
nsCOMPtr<nsITimer> timer(do_QueryInterface(aSubject));
MOZ_ASSERT(timer && timer == mTask->mTimer,
"Should only trigger this with the timer the task created");
#endif
shouldContinue = true;
+ PROFILER_MARKER("Fullscreen toggle timeout");
}
if (shouldContinue) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
obs->RemoveObserver(this, kPaintedTopic);
mTask->mTimer = nullptr;
mTask->Run();
}
return NS_OK;