Lock free app animations (6/n): Move back-pressure to new animator
SurfaceFlinger was currently only back-pressuring the old animation system. Move this to the new SurfaceAnimationRunner, such that every animation frame is presented on screen. Test: go/wm-smoke Test: Insert 16ms sleep statement when applying transaction, make sure animations are still smooth. Bug: Change-Id: I510d22c9c4359659e7a061a26b7adad9c265b734
This commit is contained in:
@@ -25,6 +25,7 @@ import android.animation.Animator;
|
|||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
@@ -195,6 +196,7 @@ class SurfaceAnimationRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyTransaction() {
|
private void applyTransaction() {
|
||||||
|
mFrameTransaction.setAnimationTransaction();
|
||||||
mFrameTransaction.apply();
|
mFrameTransaction.apply();
|
||||||
mApplyScheduled = false;
|
mApplyScheduled = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,16 +140,6 @@ public class WindowAnimator {
|
|||||||
scheduleAnimation();
|
scheduleAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate back-pressure by opening and closing an empty animation transaction. This makes
|
|
||||||
// sure that an animation frame is at least presented once on the screen. We do this outside
|
|
||||||
// of the regular transaction such that we can avoid holding the window manager lock in case
|
|
||||||
// we receive back-pressure from SurfaceFlinger. Since closing an animation transaction
|
|
||||||
// without the window manager locks leads to ordering issues (as the transaction will be
|
|
||||||
// processed only at the beginning of the next frame which may result in another transaction
|
|
||||||
// that was executed later in WM side gets executed first on SF side), we don't update any
|
|
||||||
// Surface properties here such that reordering doesn't cause issues.
|
|
||||||
mService.executeEmptyAnimationTransaction();
|
|
||||||
|
|
||||||
synchronized (mService.mWindowMap) {
|
synchronized (mService.mWindowMap) {
|
||||||
mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
|
mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
|
||||||
mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
|
mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
|
||||||
|
|||||||
@@ -852,35 +852,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes an empty animation transaction without holding the WM lock to simulate
|
|
||||||
* back-pressure. See {@link WindowAnimator#animate} why this is needed.
|
|
||||||
*/
|
|
||||||
void executeEmptyAnimationTransaction() {
|
|
||||||
try {
|
|
||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "openSurfaceTransaction");
|
|
||||||
synchronized (mWindowMap) {
|
|
||||||
if (mRoot.mSurfaceTraceEnabled) {
|
|
||||||
mRoot.mRemoteEventTrace.openSurfaceTransaction();
|
|
||||||
}
|
|
||||||
SurfaceControl.openTransaction();
|
|
||||||
SurfaceControl.setAnimationTransaction();
|
|
||||||
if (mRoot.mSurfaceTraceEnabled) {
|
|
||||||
mRoot.mRemoteEventTrace.closeSurfaceTransaction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "closeSurfaceTransaction");
|
|
||||||
SurfaceControl.closeTransaction();
|
|
||||||
} finally {
|
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Listener to notify activity manager about app transitions. */
|
/** Listener to notify activity manager about app transitions. */
|
||||||
final WindowManagerInternal.AppTransitionListener mActivityManagerAppTransitionNotifier
|
final WindowManagerInternal.AppTransitionListener mActivityManagerAppTransitionNotifier
|
||||||
= new WindowManagerInternal.AppTransitionListener() {
|
= new WindowManagerInternal.AppTransitionListener() {
|
||||||
|
|||||||
Reference in New Issue
Block a user