Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7013b6f3 authored by Alec Mouri's avatar Alec Mouri
Browse files

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
parent e06403fa
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ std::vector<sp<GraphicBuffer>> RefreshRateOverlay::SevenSegmentDrawer::drawNumbe
                                  GRALLOC_USAGE_SW_WRITE_RARELY | GRALLOC_USAGE_HW_COMPOSER |
                                          GRALLOC_USAGE_HW_TEXTURE,
                                  "RefreshRateOverlayBuffer");
        const status_t bufferStatus = buffer->initCheck();
        LOG_ALWAYS_FATAL_IF(bufferStatus != OK, "RefreshRateOverlay: Buffer failed to allocate: %d",
                            bufferStatus);
        uint8_t* pixels;
        buffer->lock(GRALLOC_USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&pixels));
        // Clear buffer content
+3 −0
Original line number Diff line number Diff line
@@ -447,6 +447,9 @@ void RegionSamplingThread::captureSample() {
                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();
+4 −0
Original line number Diff line number Diff line
@@ -5851,6 +5851,10 @@ status_t SurfaceFlinger::captureScreenCommon(RenderAreaFuture renderAreaFuture,
            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);
}