Bug 779385 - Help CSS authors diagnose why animations aren't async r=cjones
authorDavid Zbarsky <dzbarsky@gmail.com>
Thu, 02 Aug 2012 23:32:13 -0700
changeset 101289 8bdecf300a07
parent 101288 3cffd20b3452
child 101290 f633b07099d9
push id23226
push useremorley@mozilla.com
push dateFri, 03 Aug 2012 14:29:35 +0000
treeherdermozilla-central@62d4f0efe485 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs779385
milestone17.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 779385 - Help CSS authors diagnose why animations aren't async r=cjones
layout/style/AnimationCommon.cpp
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -215,27 +215,57 @@ ComputedTimingFunction::GetValue(double 
       return StepEnd(mSteps, aPortion);
   }
 }
 
 bool
 CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *aElement,
                                                            nsCSSProperty aProperty)
 {
+  static bool sShouldLog;
+  static bool sShouldLogPrefCached;
+
+  if (!sShouldLogPrefCached) {
+    sShouldLogPrefCached = true;
+    Preferences::AddBoolVarCache(&sShouldLog,
+                                 "layers.offmainthreadcomposition.log-animations");
+  }
+
   nsIFrame* frame = aElement->GetPrimaryFrame();
   if (aProperty == eCSSProperty_opacity) {
-    return nsLayoutUtils::AreOpacityAnimationsEnabled();
+    bool enabled = nsLayoutUtils::AreOpacityAnimationsEnabled();
+    if (!enabled && sShouldLog) {
+      printf_stderr("Performance warning: Async animation of 'opacity' is disabled\n");
+    }
+    return enabled;
   }
-  if (aProperty == eCSSProperty_transform && !(frame &&
-      frame->Preserves3D() &&
-      frame->Preserves3DChildren())) {
-    if (frame && frame->IsSVGTransformed()) {
+  if (aProperty == eCSSProperty_transform) {
+    if (frame &&
+        frame->Preserves3D() &&
+        frame->Preserves3DChildren()) {
+      if (sShouldLog) {
+        printf_stderr("Gecko bug: Async animation of 'preserve-3d' transforms is not supported.  See bug 779598\n");
+      }
       return false;
     }
-    return nsLayoutUtils::AreTransformAnimationsEnabled();
+    if (frame && frame->IsSVGTransformed()) {
+      if (sShouldLog) {
+        printf_stderr("Gecko bug: Async 'transform' animations of frames with SVG transforms is not supported.  See bug 779599\n");
+      }
+      return false;
+    }
+    bool enabled = nsLayoutUtils::AreTransformAnimationsEnabled();
+    if (!enabled && sShouldLog) {
+      printf_stderr("Performance warning: Async animation of 'transform' is disabled\n");
+    }
+    return enabled;
+  }
+  if (sShouldLog) {
+    const nsAFlatCString propName = nsCSSProps::GetStringValue(aProperty);
+    printf_stderr("Performance warning: Async animation cancelled because of unsupported property '%s'\n", propName.get());
   }
   return false;
 }
 
 
 
 }
 }