From da9374211f84b899e8c09c0600ec3fe6ed35b22f Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Fri, 26 May 2017 16:56:12 -0700 Subject: [PATCH] Fix infinite loop problem in AnimationHandler AnimationHandler.doAnimationFrame() iterates on a list that may be changed during the course of the lopp, especially when Battery Saver is enabled, or animators have zero duration, coupled with user code launching new animators when old ones end. The fix is to iterate through the old size of the list, and avoid processing new animators in the current frame. Bug: 37376806 Keyboard doesn't come up when battery saver is turned on on Android O Test: manual Change-Id: I40ca1d849e6f337779c23edbab22d80760c22f9b --- core/java/android/animation/AnimationHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/animation/AnimationHandler.java b/core/java/android/animation/AnimationHandler.java index e2e5a8f66288c..260323fe2d10c 100644 --- a/core/java/android/animation/AnimationHandler.java +++ b/core/java/android/animation/AnimationHandler.java @@ -136,7 +136,8 @@ public class AnimationHandler { private void doAnimationFrame(long frameTime) { long currentTime = SystemClock.uptimeMillis(); - for (int i = 0; i < mAnimationCallbacks.size(); i++) { + final int size = mAnimationCallbacks.size(); + for (int i = 0; i < size; i++) { final AnimationFrameCallback callback = mAnimationCallbacks.get(i); if (callback == null) { continue;