[sf] protect against out of order transactions
If the client submits transactions out of order, we could end up
in a situation where a frame barrier will never be satisfied and
bring down the client. Fix this by being more resiliant to out of
order transactions.
Bug: 272189296
Test: repro steps from bug
Change-Id: I781b7751bdd6259fc164692248734c0cb268c238
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a271083..7ace58c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4232,7 +4232,7 @@
// The current producerId is already a newer producer than the buffer that has a
// barrier. This means the incoming buffer is older and we can release it here. We
// don't wait on the barrier since we know that's stale information.
- if (layer->getDrawingState().producerId > s.bufferData->producerId) {
+ if (layer->getDrawingState().barrierProducerId > s.bufferData->producerId) {
layer->callReleaseBufferCallback(s.bufferData->releaseBufferListener,
externalTexture->getBuffer(),
s.bufferData->frameNumber,
@@ -4243,7 +4243,7 @@
return TraverseBuffersReturnValues::DELETE_AND_CONTINUE_TRAVERSAL;
}
- if (layer->getDrawingState().frameNumber < s.bufferData->barrierFrameNumber) {
+ if (layer->getDrawingState().barrierFrameNumber < s.bufferData->barrierFrameNumber) {
const bool willApplyBarrierFrame =
flushState.bufferLayersReadyToPresent.contains(s.surface.get()) &&
((flushState.bufferLayersReadyToPresent.get(s.surface.get()) >=