Bug 910191/913402 - Don't use OnPreDrawObserver on pre-HC devices. r=sriram, a=lsblakk
authorLucas Rocha <lucasr@mozilla.com>
Wed, 18 Sep 2013 14:50:22 -0400
changeset 160362 51a7fba55698665f661185800de9c84b139518df
parent 160361 89e6cb534865247c1af77f61066e77cb30ba537c
child 160363 c464b1da13508bcfad54ae3cde28771ed9fa06ce
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram, lsblakk
bugs910191, 913402
milestone26.0a2
Bug 910191/913402 - Don't use OnPreDrawObserver on pre-HC devices. r=sriram, a=lsblakk
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();
         }