Bug 820167 - Tab open/close animation prints performance data to error console when enabled. r=jmuizelaar,dao

This commit is contained in:
Avi Halachmi 2013-01-03 21:53:15 -05:00
parent dc80ee1276
commit 35a21b9441
6 changed files with 84 additions and 19 deletions

View File

@ -1274,6 +1274,11 @@
if (t.pinned)
tabContainer._handleNewTab(t);
else {
if (tabContainer._tabAnimationLoggingEnabled) {
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.startFrameTimeRecording();
}
t._animStartTime = Date.now();
t.setAttribute("fadein", "true");
@ -1574,6 +1579,11 @@
return;
}
if (this.tabContainer._tabAnimationLoggingEnabled) {
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.startFrameTimeRecording();
}
aTab._animStartTime = Date.now();
this._blurTab(aTab);
@ -2880,6 +2890,12 @@
Services.prefs.addObserver("browser.tabs.", this._prefObserver, false);
window.addEventListener("resize", this, false);
window.addEventListener("load", this, false);
try {
this._tabAnimationLoggingEnabled = Services.prefs.getBoolPref("browser.tabs.animationLogging.enabled");
} catch (ex) {
this._tabAnimationLoggingEnabled = false;
}
]]>
</constructor>
@ -3512,6 +3528,18 @@
"FX_TAB_ANIM_OPEN_MS")
.add(Date.now() - tab._animStartTime);
tab._animStartTime = 0;
if (this._tabAnimationLoggingEnabled) {
let paints = {};
let intervals = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.stopFrameTimeRecording(paints);
let msg = "Tab " + (tab.closing ? "close" : "open") + " (Frame-interval / paint-processing):\n";
for (let i = 0; i < intervals.length; i++) {
msg += Math.round(intervals[i]) + " / " + Math.round(paints.value[i]) + "\n";
}
Services.console.logStringMessage(msg);
}
}
if (tab.getAttribute("fadein") == "true") {

View File

@ -2156,14 +2156,15 @@ nsDOMWindowUtils::StartFrameTimeRecording()
}
NS_IMETHODIMP
nsDOMWindowUtils::StopFrameTimeRecording(uint32_t *frameCount, float **frames)
nsDOMWindowUtils::StopFrameTimeRecording(float** paintTimes, uint32_t *frameCount, float **frameIntervals)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
NS_ENSURE_ARG_POINTER(frameCount);
NS_ENSURE_ARG_POINTER(frames);
NS_ENSURE_ARG_POINTER(frameIntervals);
NS_ENSURE_ARG_POINTER(paintTimes);
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
@ -2173,20 +2174,32 @@ nsDOMWindowUtils::StopFrameTimeRecording(uint32_t *frameCount, float **frames)
if (!mgr)
return NS_ERROR_FAILURE;
nsTArray<float> frameTimes;
mgr->StopFrameTimeRecording(frameTimes);
nsTArray<float> tmpFrameIntervals;
nsTArray<float> tmpPaintTimes;
mgr->StopFrameTimeRecording(tmpFrameIntervals, tmpPaintTimes);
*frames = nullptr;
*frameCount = frameTimes.Length();
*frameIntervals = nullptr;
*paintTimes = nullptr;
*frameCount = tmpFrameIntervals.Length();
if (*frameCount != 0) {
*frames = (float*)nsMemory::Alloc(*frameCount * sizeof(float*));
if (!*frames)
*frameIntervals = (float*)nsMemory::Alloc(*frameCount * sizeof(float*));
if (!*frameIntervals)
return NS_ERROR_OUT_OF_MEMORY;
/* copy over the frame times into the array we just allocated */
*paintTimes = (float*)nsMemory::Alloc(*frameCount * sizeof(float*));
if (!*paintTimes)
return NS_ERROR_OUT_OF_MEMORY;
/* copy over the frame intervals and paint times into the arrays we just allocated */
for (uint32_t i = 0; i < *frameCount; i++) {
(*frames)[i] = frameTimes[i];
(*frameIntervals)[i] = tmpFrameIntervals[i];
#ifndef ANDROID
(*paintTimes)[i] = tmpPaintTimes[i];
#else
// Waiting for bug 785597 to work on android.
(*paintTimes)[i] = 0;
#endif
}
}

View File

@ -40,7 +40,7 @@ interface nsIDOMTouch;
interface nsIDOMClientRect;
interface nsIURI;
[scriptable, uuid(2196a216-ed3c-46dd-aa24-9f5b3ac17539)]
[scriptable, uuid(c98249a5-d38a-4ec6-b6e0-6866ea87d6bb)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -1044,8 +1044,9 @@ interface nsIDOMWindowUtils : nsISupports {
readonly attribute AString layerManagerType;
void startFrameTimeRecording();
void stopFrameTimeRecording([optional] out unsigned long frameCount,
[retval, array, size_is(frameCount)] out float frameTime);
void stopFrameTimeRecording([optional, array, size_is(frameCount)] out float paintTimes,
[optional] out unsigned long frameCount,
[retval, array, size_is(frameCount)] out float frameIntervals);
/**
* Signals that we're begining to tab switch. This is used by painting code to
* determine total tab switch time.

View File

@ -913,6 +913,15 @@ void
LayerManager::StartFrameTimeRecording()
{
mLastFrameTime = TimeStamp::Now();
mPaintStartTime = mLastFrameTime;
}
void
LayerManager::SetPaintStartTime(TimeStamp& aTime)
{
if (!mLastFrameTime.IsNull()) {
mPaintStartTime = aTime;
}
}
void
@ -920,7 +929,8 @@ LayerManager::PostPresent()
{
if (!mLastFrameTime.IsNull()) {
TimeStamp now = TimeStamp::Now();
mFrameTimes.AppendElement((now - mLastFrameTime).ToMilliseconds());
mFrameIntervals.AppendElement((now - mLastFrameTime).ToMilliseconds());
mPaintTimes.AppendElement((now - mPaintStartTime).ToMilliseconds());
mLastFrameTime = now;
}
if (!mTabSwitchStart.IsNull()) {
@ -931,11 +941,13 @@ LayerManager::PostPresent()
}
void
LayerManager::StopFrameTimeRecording(nsTArray<float>& aTimes)
LayerManager::StopFrameTimeRecording(nsTArray<float>& aFrameIntervals, nsTArray<float>& aPaintTimes)
{
mLastFrameTime = TimeStamp();
aTimes.SwapElements(mFrameTimes);
mFrameTimes.Clear();
aFrameIntervals.SwapElements(mFrameIntervals);
aPaintTimes.SwapElements(mPaintTimes);
mFrameIntervals.Clear();
mPaintTimes.Clear();
}
void

View File

@ -484,7 +484,8 @@ public:
void LogSelf(const char* aPrefix="");
void StartFrameTimeRecording();
void StopFrameTimeRecording(nsTArray<float>& aTimes);
void SetPaintStartTime(TimeStamp& aTime);
void StopFrameTimeRecording(nsTArray<float>& aFrameTimes, nsTArray<float>& aProcessingTimes);
void PostPresent();
@ -516,7 +517,9 @@ protected:
bool mInTransaction;
private:
TimeStamp mLastFrameTime;
nsTArray<float> mFrameTimes;
TimeStamp mPaintStartTime;
nsTArray<float> mFrameIntervals;
nsTArray<float> mPaintTimes;
TimeStamp mTabSwitchStart;
};

View File

@ -942,6 +942,14 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
#ifdef DEBUG_INVALIDATIONS
printf("Starting ProcessPendingUpdates\n");
#endif
#ifndef ANDROID
// Waiting for bug 785597 to work on android.
nsRefPtr<layers::LayerManager> mgr = mPresContext->GetPresShell()->GetLayerManager();
if (mgr) {
mgr->SetPaintStartTime(mMostRecentRefresh);
}
#endif
mViewManagerFlushIsPending = false;
nsCOMPtr<nsIViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
vm->ProcessPendingUpdates();