SF: Fix onSurfaceFrameCreated for layers without buffers
Previously we did not create surfaceframes for layers
without buffers. This behavior regressed with flattening
of the layer types and causes some jank classifications
to be eviceted from mPendingJankClassifications list
which has a max value of 25.
Fix this by checking if the layer has a buffer and also
while we are here, increase the max to 50 in anticipation
of multiple displays and multiple layers.
Test: presubmit, logcat for no logspam
Bug: 253555650
Change-Id: I0be3d7706305e059074b9efc14428316bdb41e6d
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 410e438..420fd56 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1551,7 +1551,6 @@
if (fps) {
surfaceFrame->setRenderRate(*fps);
}
- // TODO(b/178542907): Implement onSurfaceFrameCreated for BQLayer as well.
onSurfaceFrameCreated(surfaceFrame);
return surfaceFrame;
}
@@ -2973,6 +2972,10 @@
void Layer::onSurfaceFrameCreated(
const std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame) {
+ if (!hasBufferOrSidebandStreamInDrawing()) {
+ return;
+ }
+
while (mPendingJankClassifications.size() >= kPendingClassificationMaxSurfaceFrames) {
// Too many SurfaceFrames pending classification. The front of the deque is probably not
// tracked by FrameTimeline and will never be presented. This will only result in a memory
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 8ace812..d94295d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -1140,6 +1140,10 @@
return ((mSidebandStream != nullptr) || (mBufferInfo.mBuffer != nullptr));
}
+ bool hasBufferOrSidebandStreamInDrawing() const {
+ return ((mDrawingState.sidebandStream != nullptr) || (mDrawingState.buffer != nullptr));
+ }
+
bool hasSomethingToDraw() const { return hasEffect() || hasBufferOrSidebandStream(); }
void prepareBufferStateClientComposition(
compositionengine::LayerFE::LayerSettings&,
@@ -1219,7 +1223,7 @@
std::deque<std::shared_ptr<android::frametimeline::SurfaceFrame>> mPendingJankClassifications;
// An upper bound on the number of SurfaceFrames in the pending classifications deque.
- static constexpr int kPendingClassificationMaxSurfaceFrames = 25;
+ static constexpr int kPendingClassificationMaxSurfaceFrames = 50;
const std::string mBlastTransactionName{"BufferTX - " + mName};
// This integer is incremented everytime a buffer arrives at the server for this layer,