Merge "BLASTSyncEngine: Avoid overlapping syncs." into rvc-dev am: 175d91f6ee

Change-Id: Ia16b14d7f17ee20bd744cf8330611191701a48ec
This commit is contained in:
Rob Carr
2020-05-20 18:06:30 +00:00
committed by Automerger Merge Worker
3 changed files with 41 additions and 8 deletions

View File

@@ -2617,10 +2617,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return willSync; return willSync;
} }
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener, boolean setPendingListener(BLASTSyncEngine.TransactionReadyListener waitingListener,
int waitingId) { int waitingId) {
boolean willSync = true;
// If we are invisible, no need to sync, likewise if we are already engaged in a sync, // If we are invisible, no need to sync, likewise if we are already engaged in a sync,
// we can't support overlapping syncs on a single container yet. // we can't support overlapping syncs on a single container yet.
if (!isVisible() || mWaitingListener != null) { if (!isVisible() || mWaitingListener != null) {
@@ -2631,6 +2629,15 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// Make sure to set these before we call setReady in case the sync was a no-op // Make sure to set these before we call setReady in case the sync was a no-op
mWaitingSyncId = waitingId; mWaitingSyncId = waitingId;
mWaitingListener = waitingListener; mWaitingListener = waitingListener;
return true;
}
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
int waitingId) {
boolean willSync = setPendingListener(waitingListener, waitingId);
if (!willSync) {
return false;
}
int localId = mBLASTSyncEngine.startSyncSet(this); int localId = mBLASTSyncEngine.startSyncSet(this);
willSync |= addChildrenToSyncSet(localId); willSync |= addChildrenToSyncSet(localId);

View File

@@ -5707,16 +5707,20 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
@Override @Override
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener, boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
int waitingId) { int waitingId) {
if (!isVisible()) { boolean willSync = setPendingListener(waitingListener, waitingId);
if (!willSync) {
return false; return false;
} }
mWaitingListener = waitingListener;
mWaitingSyncId = waitingId;
mUsingBLASTSyncTransaction = true;
mLocalSyncId = mBLASTSyncEngine.startSyncSet(this); mLocalSyncId = mBLASTSyncEngine.startSyncSet(this);
addChildrenToSyncSet(mLocalSyncId); addChildrenToSyncSet(mLocalSyncId);
// In the WindowContainer implementation we immediately mark ready
// since a generic WindowContainer only needs to wait for its
// children to finish and is immediately ready from its own
// perspective but at the WindowState level we need to wait for ourselves
// to draw even if the children draw first our don't need to sync, so we omit
// the set ready call until later in finishDrawing()
mWmService.mH.removeMessages(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this); mWmService.mH.removeMessages(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this);
mWmService.mH.sendNewMessageDelayed(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this, mWmService.mH.sendNewMessageDelayed(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this,
BLAST_TIMEOUT_DURATION); BLAST_TIMEOUT_DURATION);

View File

@@ -757,6 +757,28 @@ public class WindowOrganizerTests extends WindowTestsBase {
.onTransactionReady(anyInt(), any()); .onTransactionReady(anyInt(), any());
} }
@Test
public void testBLASTCallbackNoDoubleAdd() {
final ActivityStack stackController1 = createStack();
final Task task = createTask(stackController1);
final ITaskOrganizer organizer = registerMockOrganizer();
final WindowState w = createAppWindow(task, TYPE_APPLICATION, "Enlightened Window");
makeWindowVisible(w);
BLASTSyncEngine bse = new BLASTSyncEngine();
BLASTSyncEngine.TransactionReadyListener transactionListener =
mock(BLASTSyncEngine.TransactionReadyListener.class);
int id = bse.startSyncSet(transactionListener);
assertTrue(bse.addToSyncSet(id, w));
assertFalse(bse.addToSyncSet(id, w));
// Clean-up
bse.setReady(id);
}
@Test @Test
public void testBLASTCallbackWithInvisibleWindow() { public void testBLASTCallbackWithInvisibleWindow() {
final ActivityStack stackController1 = createStack(); final ActivityStack stackController1 = createStack();