Fix race condition in BoundsAnimationController
- The SfVsyncFrameCallbackProvider needs to be initialized with the
associated handler thread's Choreographer instance.
Bug: 111465953
Test: Take a systrace and ensure the animation is running on the right
thread
Change-Id: Ia70b09d391fd2d154e00d081cfcf0d2354e51db2
(cherry picked from commit 3749a052c9)
This commit is contained in:
@@ -31,11 +31,13 @@ import android.os.IBinder;
|
||||
import android.os.Debug;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Slog;
|
||||
import android.view.Choreographer;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -112,6 +114,7 @@ public class BoundsAnimationController {
|
||||
private final Interpolator mFastOutSlowInInterpolator;
|
||||
private boolean mFinishAnimationAfterTransition = false;
|
||||
private final AnimationHandler mAnimationHandler;
|
||||
private Choreographer mChoreographer;
|
||||
|
||||
private static final int WAIT_FOR_DRAW_TIMEOUT_MS = 3000;
|
||||
|
||||
@@ -123,6 +126,12 @@ public class BoundsAnimationController {
|
||||
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
|
||||
com.android.internal.R.interpolator.fast_out_slow_in);
|
||||
mAnimationHandler = animationHandler;
|
||||
if (animationHandler != null) {
|
||||
// If an animation handler is provided, then ensure that it runs on the sf vsync tick
|
||||
handler.runWithScissors(() -> mChoreographer = Choreographer.getSfInstance(),
|
||||
0 /* timeout */);
|
||||
animationHandler.setProvider(new SfVsyncFrameCallbackProvider(mChoreographer));
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -1005,7 +1005,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mAppTransition.registerListenerLocked(mActivityManagerAppTransitionNotifier);
|
||||
|
||||
final AnimationHandler animationHandler = new AnimationHandler();
|
||||
animationHandler.setProvider(new SfVsyncFrameCallbackProvider());
|
||||
mBoundsAnimationController = new BoundsAnimationController(context, mAppTransition,
|
||||
AnimationThread.getHandler(), animationHandler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user