Skip to content

Commit 175d91f

Browse files
Rob CarrAndroid (Google) Code Review
authored andcommitted
Merge "BLASTSyncEngine: Avoid overlapping syncs." into rvc-dev
2 parents 606980b + 6a08d32 commit 175d91f

3 files changed

Lines changed: 41 additions & 8 deletions

File tree

services/core/java/com/android/server/wm/WindowContainer.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,10 +2617,8 @@ boolean addChildrenToSyncSet(int localId) {
26172617
return willSync;
26182618
}
26192619

2620-
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
2621-
int waitingId) {
2622-
boolean willSync = true;
2623-
2620+
boolean setPendingListener(BLASTSyncEngine.TransactionReadyListener waitingListener,
2621+
int waitingId) {
26242622
// If we are invisible, no need to sync, likewise if we are already engaged in a sync,
26252623
// we can't support overlapping syncs on a single container yet.
26262624
if (!isVisible() || mWaitingListener != null) {
@@ -2631,6 +2629,15 @@ boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
26312629
// Make sure to set these before we call setReady in case the sync was a no-op
26322630
mWaitingSyncId = waitingId;
26332631
mWaitingListener = waitingListener;
2632+
return true;
2633+
}
2634+
2635+
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
2636+
int waitingId) {
2637+
boolean willSync = setPendingListener(waitingListener, waitingId);
2638+
if (!willSync) {
2639+
return false;
2640+
}
26342641

26352642
int localId = mBLASTSyncEngine.startSyncSet(this);
26362643
willSync |= addChildrenToSyncSet(localId);

services/core/java/com/android/server/wm/WindowState.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5707,16 +5707,20 @@ SurfaceControl getClientViewRootSurface() {
57075707
@Override
57085708
boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
57095709
int waitingId) {
5710-
if (!isVisible()) {
5710+
boolean willSync = setPendingListener(waitingListener, waitingId);
5711+
if (!willSync) {
57115712
return false;
57125713
}
5713-
mWaitingListener = waitingListener;
5714-
mWaitingSyncId = waitingId;
5715-
mUsingBLASTSyncTransaction = true;
57165714

57175715
mLocalSyncId = mBLASTSyncEngine.startSyncSet(this);
57185716
addChildrenToSyncSet(mLocalSyncId);
57195717

5718+
// In the WindowContainer implementation we immediately mark ready
5719+
// since a generic WindowContainer only needs to wait for its
5720+
// children to finish and is immediately ready from its own
5721+
// perspective but at the WindowState level we need to wait for ourselves
5722+
// to draw even if the children draw first our don't need to sync, so we omit
5723+
// the set ready call until later in finishDrawing()
57205724
mWmService.mH.removeMessages(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this);
57215725
mWmService.mH.sendNewMessageDelayed(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this,
57225726
BLAST_TIMEOUT_DURATION);

services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,28 @@ public void testBLASTCallbackWithWindow() {
757757
.onTransactionReady(anyInt(), any());
758758
}
759759

760+
@Test
761+
public void testBLASTCallbackNoDoubleAdd() {
762+
final ActivityStack stackController1 = createStack();
763+
final Task task = createTask(stackController1);
764+
final ITaskOrganizer organizer = registerMockOrganizer();
765+
final WindowState w = createAppWindow(task, TYPE_APPLICATION, "Enlightened Window");
766+
makeWindowVisible(w);
767+
768+
BLASTSyncEngine bse = new BLASTSyncEngine();
769+
770+
BLASTSyncEngine.TransactionReadyListener transactionListener =
771+
mock(BLASTSyncEngine.TransactionReadyListener.class);
772+
773+
int id = bse.startSyncSet(transactionListener);
774+
assertTrue(bse.addToSyncSet(id, w));
775+
assertFalse(bse.addToSyncSet(id, w));
776+
777+
// Clean-up
778+
bse.setReady(id);
779+
}
780+
781+
760782
@Test
761783
public void testBLASTCallbackWithInvisibleWindow() {
762784
final ActivityStack stackController1 = createStack();

0 commit comments

Comments
 (0)