Bug 910191/913402 - Don't use OnPreDrawObserver on pre-HC devices (r=sriram)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 18 Sep 2013 14:50:22 -0400
changeset 147780 a0cad0d1d7fc
parent 147779 1df3efcf41b0
child 147781 803189f35921
child 147870 bcc657b11631
push id25316
push userkwierso@gmail.com
push date2013-09-19 01:00 +0000
treeherdermozilla-central@803189f35921 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs910191, 913402
milestone27.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 910191/913402 - Don't use OnPreDrawObserver on pre-HC devices (r=sriram)
mobile/android/base/animation/PropertyAnimator.java
--- a/mobile/android/base/animation/PropertyAnimator.java
+++ b/mobile/android/base/animation/PropertyAnimator.java
@@ -155,22 +155,27 @@ public class PropertyAnimator implements
         final ViewTreeObserver treeObserver;
         if (mElementsList.size() > 0) {
             treeObserver = mElementsList.get(0).view.getViewTreeObserver();
         } else {
             treeObserver = null;
         }
 
         // Try to start animation after any on-going layout round
-        // in the current view tree.
-        if (treeObserver != null && treeObserver.isAlive()) {
+        // in the current view tree. OnPreDrawListener seems broken
+        // on pre-Honeycomb devices, start animation immediatelly
+        // in this case.
+        if (Build.VERSION.SDK_INT >= 11 && treeObserver != null && treeObserver.isAlive()) {
             treeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                 @Override
                 public boolean onPreDraw() {
-                    treeObserver.removeOnPreDrawListener(this);
+                    if (treeObserver.isAlive()) {
+                        treeObserver.removeOnPreDrawListener(this);
+                    }
+
                     mFramePoster.postFirstAnimationFrame();
                     return true;
                 }
             });
         } else {
             mFramePoster.postFirstAnimationFrame();
         }