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/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7fada82..cb9fae3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5851,6 +5851,10 @@
getFactory().createGraphicBuffer(bufferSize.getWidth(), bufferSize.getHeight(),
static_cast<android_pixel_format>(reqPixelFormat),
1 /* layerCount */, usage, "screenshot");
+
+ const status_t bufferStatus = buffer->initCheck();
+ LOG_ALWAYS_FATAL_IF(bufferStatus != OK, "captureScreenCommon: Buffer failed to allocate: %d",
+ bufferStatus);
return captureScreenCommon(std::move(renderAreaFuture), traverseLayers, buffer,
false /* regionSampling */, grayscale, captureListener);
}