Bug 1627708 - Add boolean telemetry histograms for recording if APZ zooming occurred. r=tnikkel
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 06 Jun 2020 00:32:12 +0000
changeset 534241 0f152045a4a04b7e37e89f6b57603108039e18eb
parent 534240 4ea35d706a6be6e403bfb06d4e1b5a1827110360
child 534242 7b356f85d775897e81541c48e3aeec1b48e345ba
push id37484
push userdluca@mozilla.com
push dateSat, 06 Jun 2020 09:46:03 +0000
treeherdermozilla-central@6237102f005d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1627708
milestone79.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 1627708 - Add boolean telemetry histograms for recording if APZ zooming occurred. r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D77827
layout/base/PresShell.cpp
layout/base/PresShell.h
toolkit/components/telemetry/Histograms.json
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -816,17 +816,17 @@ PresShell::PresShell(Document* aDocument
       mIsDocumentGone(false),
       mHaveShutDown(false),
       mPaintingSuppressed(false),
       mLastRootReflowHadUnconstrainedBSize(false),
       mShouldUnsuppressPainting(false),
       mIgnoreFrameDestruction(false),
       mIsActive(true),
       mFrozen(false),
-      mIsFirstPaint(true),  // FIXME/bug 735029: find a better solution
+      mIsFirstPaint(true),
       mObservesMutationsForPrint(false),
       mWasLastReflowInterrupted(false),
       mObservingStyleFlushes(false),
       mObservingLayoutFlushes(false),
       mResizeEventPending(false),
       mFontSizeInflationForceEnabled(false),
       mFontSizeInflationDisabledInMasterProcess(false),
       mFontSizeInflationEnabled(false),
@@ -1161,27 +1161,48 @@ static void LogTextPerfStats(gfxTextPerf
          aCounts.numContentTextRuns, aCounts.numChromeTextRuns,
          aCounts.maxTextRunLen, lookups, hitRatio, aCounts.wordCacheSpaceRules,
          aCounts.wordCacheLong, aCounts.fallbackPrefs, aCounts.fallbackSystem,
          aCounts.textrunConst, aCounts.textrunDestr, aCounts.genericLookups,
          aTextPerf->cumulative.textrunDestr));
   }
 }
 
+bool PresShell::InRDMPane() {
+  if (Document* doc = GetDocument()) {
+    if (BrowsingContext* bc = doc->GetBrowsingContext()) {
+      return bc->InRDMPane();
+    }
+  }
+  return false;
+}
+
 void PresShell::Destroy() {
   // Do not add code before this line please!
   if (mHaveShutDown) {
     return;
   }
 
   NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
                "destroy called on presshell while scripts not blocked");
 
   AUTO_PROFILER_LABEL("PresShell::Destroy", LAYOUT);
 
+  // If we have a RCD that has been painted (mIsFirstPaint=false), then record
+  // whether or not it had an APZ zoom applied to it during its lifetime, and
+  // whether or not it's in responsive design mode. We omit unpainted presShells
+  // because we get a handful of transient presShells that always report no
+  // zoom, and those skew the numbers.
+  if (!mIsFirstPaint && mPresContext->IsRootContentDocumentCrossProcess()) {
+    Telemetry::HistogramID histogram = InRDMPane()
+                                           ? Telemetry::APZ_ZOOM_ACTIVITY_RDM
+                                           : Telemetry::APZ_ZOOM_ACTIVITY;
+    Telemetry::Accumulate(histogram, IsResolutionUpdatedByApz());
+  }
+
   // dump out cumulative text perf metrics
   gfxTextPerfMetrics* tp;
   if (mPresContext && (tp = mPresContext->GetTextPerfMetrics())) {
     tp->Accumulate();
     if (tp->cumulative.numChars > 0) {
       LogTextPerfStats(tp, this, tp->cumulative, 0.0, eLog_totals, nullptr);
     }
   }
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -351,16 +351,22 @@ class PresShell final : public nsStubDoc
                                                          ResizeReflowOptions);
 
   /**
    * Add this pres shell to the refresh driver to be observed for resize
    * event if applicable.
    */
   void AddResizeEventFlushObserverIfNeeded();
 
+  /**
+   * Returns true if the document hosted by this presShell is in a devtools
+   * Responsive Design Mode browsing context.
+   */
+  bool InRDMPane();
+
  private:
   /**
    * This is what ResizeReflowIgnoreOverride does when not shrink-wrapping (that
    * is, when ResizeReflowOptions::BSizeLimit is not specified).
    */
   void SimpleResizeReflow(nscoord aWidth, nscoord aHeight, ResizeReflowOptions);
 
  public:
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -15409,10 +15409,30 @@
     "record_in_processes": ["main"],
     "alert_emails": ["kgupta@mozilla.com"],
     "expires_in_version": "80",
     "kind" : "enumerated",
     "bug_numbers": [1638314],
     "description": "Action triggered by wheel event (WheelPrefs::Action)",
     "n_values": 10,
     "releaseChannelCollection": "opt-out"
+  },
+  "APZ_ZOOM_ACTIVITY" : {
+    "products": ["firefox"],
+    "record_in_processes": ["content"],
+    "alert_emails": ["kgupta@mozilla.com"],
+    "expires_in_version": "85",
+    "kind" : "boolean",
+    "bug_numbers": [1627708],
+    "description": "Whether non-RDM page had user-triggered zooming activity",
+    "releaseChannelCollection": "opt-out"
+  },
+  "APZ_ZOOM_ACTIVITY_RDM" : {
+    "products": ["firefox"],
+    "record_in_processes": ["content"],
+    "alert_emails": ["kgupta@mozilla.com"],
+    "expires_in_version": "85",
+    "kind" : "boolean",
+    "bug_numbers": [1627708],
+    "description": "Whether RDM page had user-triggered zooming activity",
+    "releaseChannelCollection": "opt-out"
   }
 }