From d48797b7c9fdf5d1d7dfc5b6d0ac89bffc116fad Mon Sep 17 00:00:00 2001 From: Chavi Weingarten Date: Fri, 4 Aug 2023 13:11:39 +0000 Subject: Remove check for new requested sync before flushing shadow queue In transactionCommittedCallback, the code checks to make sure there are no sync transactions still in flight and checks if no new requested sync has come in before flushing shadow queue. The second check was intented to give onFrameAvailable a chance to drop these sandwiched frames. However, that can't happen because by the time onFrameAvailable is called, there is no sync in flight and it doesn't consider the frames sandwiched, but rather frames that were just submitted before the sync. Therefore, it's safe to just remove this check and attempt to flush the shadow queue. This fixes the ANR since it will ensure frames are flushed if possible by the time onFrameAvailable is called. If we have actually ran out of buffers, there's a guarantee that a release callback should occur, which will then flush the shadow queue at that point. Fixes: 293692258 Test: race condition hard to reproduce Change-Id: If3568c1db6b4063ee1b4044067d298e5c2c8b6f1 --- libs/gui/BLASTBufferQueue.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 5c324b29cd..207fa4fd31 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -303,13 +303,8 @@ void BLASTBufferQueue::transactionCommittedCallback(nsecs_t /*latchTime*/, // frame numbers that were in a sync. We remove the frame from mSyncedFrameNumbers // set and then check if it's empty. If there are no more pending syncs, we can // proceed with flushing the shadow queue. - // We also want to check if mSyncTransaction is null because it's possible another - // sync request came in while waiting, but it hasn't started processing yet. In that - // case, we don't actually want to flush the frames in between since they will get - // processed and merged with the sync transaction and released earlier than if they - // were sent to SF mSyncedFrameNumbers.erase(currFrameNumber); - if (mSyncedFrameNumbers.empty() && mSyncTransaction == nullptr) { + if (mSyncedFrameNumbers.empty()) { flushShadowQueue(); } } else { -- cgit v1.2.3-59-g8ed1b