BLASTBufferQueue: Avoid duplicate calls to setDefaultBufferSize
Calling in to the consumer may acquire the BufferQueueCore mutex. We call
BLASTBufferQueue::update from the UI thread. And so we can accidentally
end up blocking the UI thread on allocateBuffers() during app start-up.
Bug: 152501005
Test: Flip BLAST. Play.
Change-Id: I89034211ed5725b5be6391cc2bac748c0acf1eb3
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index c73d92c..a8384ac 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -132,9 +132,12 @@
void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, int width, int height) {
std::unique_lock _lock{mMutex};
mSurfaceControl = surface;
- mWidth = width;
- mHeight = height;
- mBufferItemConsumer->setDefaultBufferSize(mWidth, mHeight);
+
+ if (mWidth != width || mHeight != height) {
+ mWidth = width;
+ mHeight = height;
+ mBufferItemConsumer->setDefaultBufferSize(mWidth, mHeight);
+ }
}
static void transactionCallbackThunk(void* context, nsecs_t latchTime,