Bug 1514514: Move pageload markers to TextMarker with DocShell IDs r=mstange
authorRandell Jesup <rjesup@jesup.org>
Tue, 15 Jan 2019 12:49:03 -0500
changeset 511118 39104a14a66b345dece9d434494b806f2219c67c
parent 511117 d7e75d5ad3de61c89de5ce8e3e8478d4979b34f8
child 511119 e6d86c730d0acde5ca17f2a4d07a0ded5b0113b2
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1514514
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514514: Move pageload markers to TextMarker with DocShell IDs r=mstange
dom/base/nsDOMNavigationTiming.cpp
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -24,16 +24,17 @@
 #endif
 
 using namespace mozilla;
 
 namespace mozilla {
 
 LazyLogModule gPageLoadLog("PageLoad");
 #define PAGELOAD_LOG(args) MOZ_LOG(gPageLoadLog, LogLevel::Debug, args)
+#define PAGELOAD_LOG_ENABLED() MOZ_LOG_TEST(gPageLoadLog, LogLevel::Error)
 
 }  // namespace mozilla
 
 nsDOMNavigationTiming::nsDOMNavigationTiming(nsDocShell* aDocShell) {
   Clear();
 
   mDocShell = aDocShell;
 }
@@ -317,17 +318,17 @@ void nsDOMNavigationTiming::TTITimeout(n
   }
   // XXX Implement TTI via check number of network loads, and if > 2 mark
   // to check if loads decreases to 2 (or record that point and let the
   // normal timer here handle it)
 
   mTTITimer = nullptr;
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
     TimeDuration elapsed = mTTFI - mNavigationStart;
     MOZ_ASSERT(elapsed.ToMilliseconds() > 0);
     TimeDuration elapsedLongTask =
         lastLongTaskEnded.IsNull() ? 0 : lastLongTaskEnded - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
@@ -350,30 +351,35 @@ void nsDOMNavigationTiming::NotifyNonBla
 
   if (!mNonBlankPaint.IsNull()) {
     return;
   }
 
   mNonBlankPaint = TimeStamp::Now();
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_thread_is_being_profiled()) {
+  if (profiler_thread_is_being_profiled() || PAGELOAD_LOG_ENABLED()) {
     TimeDuration elapsed = mNonBlankPaint - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
     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_add_marker(marker.get());
+    PAGELOAD_LOG(("%s", marker.get()));
+    DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
+    profiler_add_marker(
+        "FirstNonBlankPaint",
+        MakeUnique<TextMarkerPayload>(marker, mNavigationStart, mNonBlankPaint,
+                                      docShellId, docShellHistoryId));
   }
 #endif
 
   if (mDocShellHasBeenActiveSinceNavigationStart) {
     if (net::nsHttp::IsBeforeLastActiveTabLoadOptimization(mNavigationStart)) {
       Telemetry::AccumulateTimeDelta(
           Telemetry::TIME_TO_NON_BLANK_PAINT_NETOPT_MS, mNavigationStart,
           mNonBlankPaint);
@@ -394,30 +400,35 @@ void nsDOMNavigationTiming::NotifyConten
 
   if (!mContentfulPaint.IsNull()) {
     return;
   }
 
   mContentfulPaint = TimeStamp::Now();
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
     TimeDuration elapsed = mContentfulPaint - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
     nsPrintfCString marker(
         "Contentful 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_add_marker(marker.get());
+    DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
+    PAGELOAD_LOG(("%s", marker.get()));
+    profiler_add_marker("FirstContentfulPaint",
+                        MakeUnique<TextMarkerPayload>(
+                            marker, mNavigationStart, mContentfulPaint,
+                            docShellId, docShellHistoryId));
   }
 #endif
 
   if (!mTTITimer) {
     mTTITimer = NS_NewTimer();
   }
 
   // TTI is first checked 5 seconds after the FCP (non-blank-paint is very close
@@ -434,30 +445,35 @@ void nsDOMNavigationTiming::NotifyDOMCon
 
   if (!mDOMContentFlushed.IsNull()) {
     return;
   }
 
   mDOMContentFlushed = TimeStamp::Now();
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_thread_is_being_profiled()) {
+  if (profiler_thread_is_being_profiled() || PAGELOAD_LOG_ENABLED()) {
     TimeDuration elapsed = mDOMContentFlushed - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
     nsPrintfCString marker(
         "DOMContentFlushed 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 DOMContentFlushed");
-    profiler_add_marker(marker.get());
+    DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
+    PAGELOAD_LOG(("%s", marker.get()));
+    profiler_add_marker("DOMContentFlushed",
+                        MakeUnique<TextMarkerPayload>(
+                            marker, mNavigationStart, mDOMContentFlushed,
+                            docShellId, docShellHistoryId));
   }
 #endif
 }
 
 void nsDOMNavigationTiming::NotifyDocShellStateChanged(
     DocShellState aDocShellState) {
   mDocShellHasBeenActiveSinceNavigationStart &=
       (aDocShellState == DocShellState::eActive);