Bug 1413104 - Drop telemetry probes for layer size; r?botond draft
author<bbirtles@mozilla.com>
Thu, 14 Dec 2017 21:36:09 +0000
changeset 711838 fc90e22af1175e7b4ead3cd8353e5999950b16a3
parent 706008 fed6b20cf2beeb05c4a8f0e49895ab45ce1d1392
child 743899 d84cb22cf186cd93912017c29612544ee9e4b9f4
push id93171
push userbmo:bbirtles@mozilla.com
push dateThu, 14 Dec 2017 21:39:53 +0000
reviewersbotond
bugs1413104
milestone59.0a1
Bug 1413104 - Drop telemetry probes for layer size; r?botond MozReview-Commit-ID: FtpTJDC50A8
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/KeyframeEffectReadOnly.h
layout/painting/nsDisplayList.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -119,22 +119,16 @@ KeyframeEffect::SetTarget(const Nullable
 
     RequestRestyle(EffectCompositor::RestyleType::Layer);
 
     nsAutoAnimationMutationBatch mb(mTarget->mElement->OwnerDoc());
     if (mAnimation) {
       nsNodeUtils::AnimationAdded(mAnimation);
     }
   }
-
-  // If the new target frame is also oversized we should probably record that
-  // too so we have a more complete picture of the type of frame sizes we
-  // encounter, hence we reset the telemetry flag here.
-  mRecordedContentTooLarge = false;
-  mRecordedFrameSize = false;
 }
 
 void
 KeyframeEffect::SetIterationComposite(
   const IterationCompositeOperation& aIterationComposite,
   CallerType aCallerType)
 {
   // Ignore iterationComposite if the Web Animations API is not enabled,
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -2,33 +2,31 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 
 #include "FrameLayerBuilder.h"
-#include "gfxPrefs.h"
 #include "mozilla/dom/Animation.h"
 #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
   // For UnrestrictedDoubleOrKeyframeAnimationOptions;
 #include "mozilla/dom/CSSPseudoElement.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
 #include "mozilla/AnimValuesStyleRule.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/FloatingPoint.h" // For IsFinite
 #include "mozilla/GeckoStyleContext.h"
 #include "mozilla/LayerAnimationInfo.h"
 #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/ServoBindings.h"
-#include "mozilla/Telemetry.h"
 #include "mozilla/TypeTraits.h"
 #include "Layers.h" // For Layer
 #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContext
 #include "nsContentUtils.h"
 #include "nsCSSPropertyIDSet.h"
 #include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
 #include "nsCSSPseudoElements.h" // For CSSPseudoElementType
 #include "nsDocument.h" // For nsDocument::IsWebAnimationsEnabled
@@ -1678,41 +1676,16 @@ KeyframeEffectReadOnly::HasGeometricProp
   return false;
 }
 
 void
 KeyframeEffectReadOnly::SetPerformanceWarning(
   nsCSSPropertyID aProperty,
   const AnimationPerformanceWarning& aWarning)
 {
-  if (aWarning.mType == AnimationPerformanceWarning::Type::ContentTooLarge &&
-      !mRecordedContentTooLarge) {
-    // ContentTooLarge stores: frameSize (w x h),
-    //                         relativeLimit (w x h), i.e. =~ viewport size *
-    //                                                          ratioLimit
-    //                         absoluteLimit (w x h)
-    MOZ_ASSERT(aWarning.mParams && aWarning.mParams->Length() >= 4,
-               "ContentTooLarge warning should have at least 4 parameters");
-    const nsTArray<int32_t>& params = aWarning.mParams.ref();
-    uint32_t frameSize = uint32_t(params[0]) * params[1];
-    float viewportRatioX = gfxPrefs::AnimationPrerenderViewportRatioLimitX();
-    float viewportRatioY = gfxPrefs::AnimationPrerenderViewportRatioLimitY();
-    double viewportWidth = viewportRatioX ? params[2] / viewportRatioX
-                                          : params[2];
-    double viewportHeight = viewportRatioY ? params[3] / viewportRatioY
-                                           : params[3];
-    double viewportSize = viewportWidth * viewportHeight;
-    uint32_t frameToViewport = frameSize / viewportSize * 100.0;
-    Telemetry::Accumulate(
-      Telemetry::ASYNC_ANIMATION_CONTENT_TOO_LARGE_FRAME_SIZE, frameSize);
-    Telemetry::Accumulate(
-      Telemetry::ASYNC_ANIMATION_CONTENT_TOO_LARGE_PERCENTAGE, frameToViewport);
-    mRecordedContentTooLarge = true;
-  }
-
   for (AnimationProperty& property : mProperties) {
     if (property.mProperty == aProperty &&
         (!property.mPerformanceWarning ||
          *property.mPerformanceWarning != aWarning)) {
       property.mPerformanceWarning = Some(aWarning);
 
       nsAutoString localizedString;
       if (nsLayoutUtils::IsAnimationLoggingEnabled() &&
@@ -1720,24 +1693,16 @@ KeyframeEffectReadOnly::SetPerformanceWa
         nsAutoCString logMessage = NS_ConvertUTF16toUTF8(localizedString);
         AnimationUtils::LogAsyncAnimationFailure(logMessage, mTarget->mElement);
       }
       return;
     }
   }
 }
 
-void
-KeyframeEffectReadOnly::RecordFrameSizeTelemetry(uint32_t aPixelArea) {
-  if (!mRecordedFrameSize) {
-    Telemetry::Accumulate(Telemetry::ASYNC_ANIMATION_FRAME_SIZE, aPixelArea);
-    mRecordedFrameSize = true;
-  }
-}
-
 already_AddRefed<nsStyleContext>
 KeyframeEffectReadOnly::CreateStyleContextForAnimationValue(
   nsCSSPropertyID aProperty,
   const AnimationValue& aValue,
   GeckoStyleContext* aBaseStyleContext)
 {
   MOZ_ASSERT(aBaseStyleContext,
              "CreateStyleContextForAnimationValue needs to be called "
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -249,19 +249,16 @@ public:
   // Associates a warning with the animated property on the specified frame
   // indicating why, for example, the property could not be animated on the
   // compositor. |aParams| and |aParamsLength| are optional parameters which
   // will be used to generate a localized message for devtools.
   void SetPerformanceWarning(
     nsCSSPropertyID aProperty,
     const AnimationPerformanceWarning& aWarning);
 
-  // Record telemetry about the size of the content being animated.
-  void RecordFrameSizeTelemetry(uint32_t aPixelArea);
-
   // Cumulative change hint on each segment for each property.
   // This is used for deciding the animation is paint-only.
   template<typename StyleType>
   void CalculateCumulativeChangeHint(StyleType* aStyleContext);
 
   // Returns true if all of animation properties' change hints
   // can ignore painting if the animation is not visible.
   // See nsChangeHint_Hints_CanIgnoreIfNotVisible in nsChangeHint.h
@@ -417,25 +414,16 @@ protected:
   nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>
     mBaseStyleValuesForServo;
 
   // True if this effect is in the EffectSet for its target element. This is
   // used as an optimization to avoid unnecessary hashmap lookups on the
   // EffectSet.
   bool mInEffectSet = false;
 
-  // We only want to record telemetry data for "ContentTooLarge" warnings once
-  // per effect:target pair so we use this member to record if we have already
-  // reported a "ContentTooLarge" warning for the current target.
-  bool mRecordedContentTooLarge = false;
-  // Similarly, as a point of comparison we record telemetry whether or not
-  // we get a "ContentTooLarge" warning, but again only once per effect:target
-  // pair.
-  bool mRecordedFrameSize = false;
-
 private:
   nsChangeHint mCumulativeChangeHint;
 
   template<typename StyleType>
   void DoSetKeyframes(nsTArray<Keyframe>&& aKeyframes, StyleType* aStyle);
 
   template<typename StyleType>
   void DoUpdateProperties(StyleType* aStyle);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8317,31 +8317,16 @@ nsDisplayOpacity::CanUseAsyncAnimations(
 }
 
 bool
 nsDisplayTransform::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder)
 {
   return mAllowAsyncAnimation;
 }
 
-static void
-RecordAnimationFrameSizeTelemetry(nsIFrame* aFrame, const nsSize& overflow)
-{
-  gfxSize scale = nsLayoutUtils::GetTransformToAncestorScale(aFrame);
-  nsSize frameSize = nsSize(overflow.width * scale.width,
-                            overflow.height * scale.height);
-  uint32_t pixelArea = uint32_t(nsPresContext::AppUnitsToIntCSSPixels(frameSize.width))
-                     * nsPresContext::AppUnitsToIntCSSPixels(frameSize.height);
-  if (EffectSet* effects = EffectSet::GetEffectSet(aFrame)) {
-    for (KeyframeEffectReadOnly* effect : *effects) {
-      effect->RecordFrameSizeTelemetry(pixelArea);
-    }
-  }
-}
-
 /* static */ auto
 nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder,
                                                       nsIFrame* aFrame,
                                                       nsRect* aDirtyRect) -> PrerenderDecision
 {
   // Elements whose transform has been modified recently, or which
   // have a compositor-animated transform, can be prerendered. An element
   // might have only just had its transform animated in which case
@@ -8378,27 +8363,19 @@ nsDisplayTransform::ShouldPrerenderTrans
   for (nsIFrame* container = nsLayoutUtils::GetCrossDocParentFrame(aFrame);
        container; container = nsLayoutUtils::GetCrossDocParentFrame(container)) {
     const nsStyleSVGReset *svgReset = container->StyleSVGReset();
     if (svgReset->HasMask() || svgReset->HasClipPath()) {
       return NoPrerender;
     }
   }
 
-  nsRect overflow = aFrame->GetVisualOverflowRectRelativeToSelf();
-
-  // Record telemetry about the size of the animated content.
-  // Check CanRecordExtended() so we don't do any processing if the
-  // telemetry won't be recorded anyways.
-  if (Telemetry::CanRecordExtended()) {
-    RecordAnimationFrameSizeTelemetry(aFrame, overflow.Size());
-  }
-
   // If the incoming dirty rect already contains the entire overflow area,
   // we are already rendering the entire content.
+  nsRect overflow = aFrame->GetVisualOverflowRectRelativeToSelf();
   if (aDirtyRect->Contains(overflow)) {
     return FullPrerender;
   }
 
   float viewportRatioX = gfxPrefs::AnimationPrerenderViewportRatioLimitX();
   float viewportRatioY = gfxPrefs::AnimationPrerenderViewportRatioLimitY();
   uint32_t absoluteLimitX = gfxPrefs::AnimationPrerenderAbsoluteLimitX();
   uint32_t absoluteLimitY = gfxPrefs::AnimationPrerenderAbsoluteLimitY();
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -129,47 +129,16 @@
     "record_in_processes": ["main", "content"],
     "alert_emails": ["francois@mozilla.com", "safebrowsing-telemetry@mozilla.org"],
     "expires_in_version": "never",
     "releaseChannelCollection": "opt-out",
     "kind": "boolean",
     "bug_numbers": [1172689],
     "description": "Recorded when application reputation remote lookup is performed, `true` is recorded if the lookup times out."
   },
-  "ASYNC_ANIMATION_CONTENT_TOO_LARGE_FRAME_SIZE": {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["bbirtles@mozilla.com"],
-    "expires_in_version": "59",
-    "kind": "exponential",
-    "high": 80000000,
-    "n_buckets": 100,
-    "bug_numbers": [1100357, 1349808],
-    "description": "The number of pixels of the frame for each time we encountered a layer that was so large we decided not to run its animations on the compositor."
-  },
-  "ASYNC_ANIMATION_CONTENT_TOO_LARGE_PERCENTAGE": {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["bbirtles@mozilla.com"],
-    "expires_in_version": "59",
-    "kind": "exponential",
-    "low": 100,
-    "high": 1000,
-    "n_buckets": 50,
-    "bug_numbers": [1100357, 1349808],
-    "description": "The ratio of the frame size (in total number of pixels) to the relative limit (~viewport size plus some tolerance factor, typically 12.5% in each dimension, i.e. ~27% tolerance in total area) for each time we encountered a layer that was so large we decided not to run its animations on the compositor expressed as a percentage (e.g. 130 = frame area was 30% larger than the relative limit)"
-  },
-  "ASYNC_ANIMATION_FRAME_SIZE": {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["bbirtles@mozilla.com"],
-    "expires_in_version": "59",
-    "kind": "exponential",
-    "high": 80000000,
-    "n_buckets": 100,
-    "bug_numbers": [1100357, 1361915],
-    "description": "The number of pixels of the frame each time we potentially run a transform animation on the compositor. Intended for comparison with ASYNC_ANIMATION_CONTENT_TOO_LARGE_FRAME_SIZE. "
-  },
   "AUDIOSTREAM_FIRST_OPEN_MS": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "50",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "description": "The length of time (in milliseconds) for the first open of AudioStream."
   },