зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1307242 - Add a non-blank paint telemetry probe for foreground root content documents. r=bkelly, f=bsmedberg
This adds a probe called TIME_TO_NON_BLANK_PAINT_MS which reports time to non-blank paint for root content documents whose docshell was active for the entire time between navigation start and first non-blank paint. MozReview-Commit-ID: 7JQdk5vHr1O --HG-- extra : rebase_source : 66be2aab4c4a32d20fb44c88c5270c5b5cfc0b81 extra : histedit_source : 5d6bef86d4a2a2250405d24ce28c6bfd9d654f8d
This commit is contained in:
Родитель
39097a49f3
Коммит
3994547b42
|
@ -1728,7 +1728,9 @@ nsDocShell::MaybeInitTiming()
|
|||
mTiming = new nsDOMNavigationTiming();
|
||||
}
|
||||
|
||||
mTiming->NotifyNavigationStart();
|
||||
mTiming->NotifyNavigationStart(
|
||||
mIsActive ? nsDOMNavigationTiming::DocShellState::eActive
|
||||
: nsDOMNavigationTiming::DocShellState::eInactive);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -6219,6 +6221,20 @@ nsDocShell::SetIsActive(bool aIsActive)
|
|||
}
|
||||
}
|
||||
|
||||
// Tell the nsDOMNavigationTiming about it
|
||||
RefPtr<nsDOMNavigationTiming> timing = mTiming;
|
||||
if (!timing && mContentViewer) {
|
||||
nsIDocument* doc = mContentViewer->GetDocument();
|
||||
if (doc) {
|
||||
timing = doc->GetNavigationTiming();
|
||||
}
|
||||
}
|
||||
if (timing) {
|
||||
timing->NotifyDocShellStateChanged(
|
||||
aIsActive ? nsDOMNavigationTiming::DocShellState::eActive
|
||||
: nsDOMNavigationTiming::DocShellState::eInactive);
|
||||
}
|
||||
|
||||
// Recursively tell all of our children, but don't tell <iframe mozbrowser>
|
||||
// children; they handle their state separately.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
|
|
|
@ -48,6 +48,7 @@ nsDOMNavigationTiming::Clear()
|
|||
mDOMContentLoadedEventStartSet = false;
|
||||
mDOMContentLoadedEventEndSet = false;
|
||||
mDOMCompleteSet = false;
|
||||
mDocShellHasBeenActiveSinceNavigationStart = false;
|
||||
}
|
||||
|
||||
DOMTimeMilliSec
|
||||
|
@ -66,10 +67,11 @@ DOMTimeMilliSec nsDOMNavigationTiming::DurationFromStart()
|
|||
}
|
||||
|
||||
void
|
||||
nsDOMNavigationTiming::NotifyNavigationStart()
|
||||
nsDOMNavigationTiming::NotifyNavigationStart(DocShellState aDocShellState)
|
||||
{
|
||||
mNavigationStartHighRes = (double)PR_Now() / PR_USEC_PER_MSEC;
|
||||
mNavigationStartTimeStamp = mozilla::TimeStamp::Now();
|
||||
mDocShellHasBeenActiveSinceNavigationStart = (aDocShellState == DocShellState::eActive);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -185,7 +187,7 @@ nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI)
|
|||
}
|
||||
|
||||
void
|
||||
nsDOMNavigationTiming::NotifyNonBlankPaint()
|
||||
nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mNavigationStartTimeStamp.IsNull());
|
||||
|
@ -202,10 +204,24 @@ nsDOMNavigationTiming::NotifyNonBlankPaint()
|
|||
if (mLoadedURI) {
|
||||
mLoadedURI->GetSpec(spec);
|
||||
}
|
||||
nsPrintfCString marker("Non-blank paint after %dms for URL %s",
|
||||
int(elapsed.ToMilliseconds()), spec.get());
|
||||
nsPrintfCString marker("Non-blank paint after %dms for URL %s, %s",
|
||||
int(elapsed.ToMilliseconds()), spec.get(),
|
||||
mDocShellHasBeenActiveSinceNavigationStart ? "foreground tab" : "this tab was inactive some of the time between navigation start and first non-blank paint");
|
||||
PROFILER_MARKER(marker.get());
|
||||
}
|
||||
|
||||
if (mDocShellHasBeenActiveSinceNavigationStart) {
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_NON_BLANK_PAINT_MS,
|
||||
mNavigationStartTimeStamp,
|
||||
mNonBlankPaintTimeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMNavigationTiming::NotifyDocShellStateChanged(DocShellState aDocShellState)
|
||||
{
|
||||
mDocShellHasBeenActiveSinceNavigationStart &=
|
||||
(aDocShellState == DocShellState::eActive);
|
||||
}
|
||||
|
||||
DOMTimeMilliSec
|
||||
|
|
|
@ -81,7 +81,12 @@ public:
|
|||
return mLoadEventEnd;
|
||||
}
|
||||
|
||||
void NotifyNavigationStart();
|
||||
enum class DocShellState : uint8_t {
|
||||
eActive,
|
||||
eInactive
|
||||
};
|
||||
|
||||
void NotifyNavigationStart(DocShellState aDocShellState);
|
||||
void NotifyFetchStart(nsIURI* aURI, Type aNavigationType);
|
||||
void NotifyBeforeUnload();
|
||||
void NotifyUnloadAccepted(nsIURI* aOldURI);
|
||||
|
@ -98,7 +103,8 @@ public:
|
|||
void NotifyDOMContentLoadedStart(nsIURI* aURI);
|
||||
void NotifyDOMContentLoadedEnd(nsIURI* aURI);
|
||||
|
||||
void NotifyNonBlankPaint();
|
||||
void NotifyNonBlankPaintForRootContentDocument();
|
||||
void NotifyDocShellStateChanged(DocShellState aDocShellState);
|
||||
|
||||
DOMTimeMilliSec TimeStampToDOM(mozilla::TimeStamp aStamp) const;
|
||||
|
||||
|
@ -145,6 +151,7 @@ private:
|
|||
bool mDOMContentLoadedEventStartSet : 1;
|
||||
bool mDOMContentLoadedEventEndSet : 1;
|
||||
bool mDOMCompleteSet : 1;
|
||||
bool mDocShellHasBeenActiveSinceNavigationStart : 1;
|
||||
};
|
||||
|
||||
#endif /* nsDOMNavigationTiming_h___ */
|
||||
|
|
|
@ -362,7 +362,7 @@ SVGDocumentWrapper::SetupViewer(nsIRequest* aRequest,
|
|||
// automatically. Since there is no DocShell for this wrapped SVG document,
|
||||
// we must set it up manually.
|
||||
RefPtr<nsDOMNavigationTiming> timing = new nsDOMNavigationTiming();
|
||||
timing->NotifyNavigationStart();
|
||||
timing->NotifyNavigationStart(nsDOMNavigationTiming::DocShellState::eInactive);
|
||||
viewer->SetNavigationTiming(timing);
|
||||
|
||||
nsCOMPtr<nsIParser> parser = do_QueryInterface(listener);
|
||||
|
|
|
@ -2757,9 +2757,11 @@ nsPresContext::NotifyNonBlankPaint()
|
|||
{
|
||||
MOZ_ASSERT(!mHadNonBlankPaint);
|
||||
mHadNonBlankPaint = true;
|
||||
if (IsRootContentDocument()) {
|
||||
RefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (timing) {
|
||||
timing->NotifyNonBlankPaint();
|
||||
timing->NotifyNonBlankPaintForRootContentDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10778,5 +10778,14 @@
|
|||
"n_buckets": 50,
|
||||
"description": "Time spent painting the contents of a remote browser (ms).",
|
||||
"releaseChannelCollection": "opt-out"
|
||||
},
|
||||
"TIME_TO_NON_BLANK_PAINT_MS": {
|
||||
"alert_emails": ["hkirschner@mozilla.com"],
|
||||
"expires_in_version": "55",
|
||||
"kind": "exponential",
|
||||
"high": 100000,
|
||||
"n_buckets": 100,
|
||||
"bug_numbers": [1307242],
|
||||
"description": "The time between navigation start and the first non-blank paint of a foreground root content document, in milliseconds. This only records documents that were in an active docshell throughout the whole time between navigation start and non-blank paint. The non-blank paint timestamp is taken during display list building and does not include rasterization or compositing of that paint."
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче