Check status codes of GraphicBuffers on allocation
We're getting reports of buffers transiently missing usage bits when
allocated from SurfaceFlinger causing strange issues. Fatal logging when
there is an allocation error will hopefully aid in triaging future bug
reports.
Bug: 157562905
Bug: 179786581
Test: build, boots
Change-Id: I715295c0b6b3450e71181d93391dd99616f89d26
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 9186538..09615f9 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -447,6 +447,9 @@
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
buffer = new GraphicBuffer(sampledBounds.getWidth(), sampledBounds.getHeight(),
PIXEL_FORMAT_RGBA_8888, 1, usage, "RegionSamplingThread");
+ const status_t bufferStatus = buffer->initCheck();
+ LOG_ALWAYS_FATAL_IF(bufferStatus != OK, "captureSample: Buffer failed to allocate: %d",
+ bufferStatus);
}
const sp<SyncScreenCaptureListener> captureListener = new SyncScreenCaptureListener();