Merge "Clean unnecessary lock of WindowAnimator#animate" into rvc-dev am: 15b6d1e648 am: 485f5b266a

Change-Id: I6f37620d9e5fea565261390e4777ffef7a14e3b1
This commit is contained in:
Automerger Merge Worker
2020-03-16 04:20:58 +00:00
2 changed files with 75 additions and 95 deletions

View File

@@ -96,8 +96,8 @@ public class WindowAnimator {
mAnimationFrameCallback = frameTimeNs -> { mAnimationFrameCallback = frameTimeNs -> {
synchronized (mService.mGlobalLock) { synchronized (mService.mGlobalLock) {
mAnimationFrameCallbackScheduled = false; mAnimationFrameCallbackScheduled = false;
}
animate(frameTimeNs); animate(frameTimeNs);
}
}; };
} }
@@ -115,23 +115,14 @@ public class WindowAnimator {
mInitialized = true; mInitialized = true;
} }
/**
* DO NOT HOLD THE WINDOW MANAGER LOCK WHILE CALLING THIS METHOD. Reason: the method closes
* an animation transaction, that might be blocking until the next sf-vsync, so we want to make
* sure other threads can make progress if this happens.
*/
private void animate(long frameTimeNs) { private void animate(long frameTimeNs) {
synchronized (mService.mGlobalLock) {
if (!mInitialized) { if (!mInitialized) {
return; return;
} }
// Schedule next frame already such that back-pressure happens continuously // Schedule next frame already such that back-pressure happens continuously.
scheduleAnimation(); scheduleAnimation();
}
synchronized (mService.mGlobalLock) {
mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS; mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE; mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
if (DEBUG_WINDOW_TRACE) { if (DEBUG_WINDOW_TRACE) {
@@ -147,8 +138,8 @@ public class WindowAnimator {
for (int i = 0; i < numDisplays; i++) { for (int i = 0; i < numDisplays; i++) {
final int displayId = mDisplayContentsAnimators.keyAt(i); final int displayId = mDisplayContentsAnimators.keyAt(i);
final DisplayContent dc = mService.mRoot.getDisplayContent(displayId); final DisplayContent dc = mService.mRoot.getDisplayContent(displayId);
// Update animations of all applications, including those // Update animations of all applications, including those associated with
// associated with exiting/removed apps // exiting/removed apps.
dc.updateWindowsForAnimator(); dc.updateWindowsForAnimator();
dc.prepareSurfaces(); dc.prepareSurfaces();
} }
@@ -178,22 +169,16 @@ public class WindowAnimator {
ProtoLog.i(WM_SHOW_TRANSACTIONS, "<<< CLOSE TRANSACTION animate"); ProtoLog.i(WM_SHOW_TRANSACTIONS, "<<< CLOSE TRANSACTION animate");
} }
boolean hasPendingLayoutChanges = mService.mRoot.hasPendingLayoutChanges(this); final boolean hasPendingLayoutChanges = mService.mRoot.hasPendingLayoutChanges(this);
boolean doRequest = false; final boolean doRequest = mBulkUpdateParams != 0 && mService.mRoot.copyAnimToLayoutParams();
if (mBulkUpdateParams != 0) {
doRequest = mService.mRoot.copyAnimToLayoutParams();
}
if (hasPendingLayoutChanges || doRequest) { if (hasPendingLayoutChanges || doRequest) {
mService.mWindowPlacerLocked.requestTraversal(); mService.mWindowPlacerLocked.requestTraversal();
} }
final boolean rootAnimating = mService.mRoot.isAnimating(TRANSITION | CHILDREN); final boolean rootAnimating = mService.mRoot.isAnimating(TRANSITION | CHILDREN);
if (rootAnimating && !mLastRootAnimating) { if (rootAnimating && !mLastRootAnimating) {
// Usually app transitions but quite a load onto the system already (with all the things
// Usually app transitions but quite a load onto the system already (with all the // happening in app), so pause task snapshot persisting to not increase the load.
// things happening in app), so pause task snapshot persisting to not increase the
// load.
mService.mTaskSnapshotController.setPersisterPaused(true); mService.mTaskSnapshotController.setPersisterPaused(true);
Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0); Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
} }
@@ -220,7 +205,6 @@ public class WindowAnimator {
+ " hasPendingLayoutChanges=" + hasPendingLayoutChanges); + " hasPendingLayoutChanges=" + hasPendingLayoutChanges);
} }
} }
}
private static String bulkUpdateParamsToString(int bulkUpdateParams) { private static String bulkUpdateParamsToString(int bulkUpdateParams) {
StringBuilder builder = new StringBuilder(128); StringBuilder builder = new StringBuilder(128);

View File

@@ -1007,9 +1007,7 @@ public class WindowManagerService extends IWindowManager.Stub
void openSurfaceTransaction() { void openSurfaceTransaction() {
try { try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "openSurfaceTransaction"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "openSurfaceTransaction");
synchronized (mGlobalLock) {
SurfaceControl.openTransaction(); SurfaceControl.openTransaction();
}
} finally { } finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} }
@@ -1022,10 +1020,8 @@ public class WindowManagerService extends IWindowManager.Stub
void closeSurfaceTransaction(String where) { void closeSurfaceTransaction(String where) {
try { try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "closeSurfaceTransaction"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "closeSurfaceTransaction");
synchronized (mGlobalLock) {
SurfaceControl.closeTransaction(); SurfaceControl.closeTransaction();
mWindowTracing.logState(where); mWindowTracing.logState(where);
}
} finally { } finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} }