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

Commit 4830cd6a authored by NT Tsai's avatar NT Tsai Committed by Android (Google) Code Review
Browse files

Merge "Fail gracefully when allocating screenshot buffers" into tm-d1-dev

parents b9c09f87 d8f17c54
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -6620,8 +6620,13 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenCommon(
                                             1 /* layerCount */, usage, "screenshot");

    const status_t bufferStatus = buffer->initCheck();
    LOG_ALWAYS_FATAL_IF(bufferStatus != OK, "captureScreenCommon: Buffer failed to allocate: %d",
                        bufferStatus);
    if (bufferStatus != OK) {
        // Animations may end up being really janky, but don't crash here.
        // Otherwise an irreponsible process may cause an SF crash by allocating
        // too much.
        ALOGE("%s: Buffer failed to allocate: %d", __func__, bufferStatus);
        return ftl::yield<FenceResult>(base::unexpected(bufferStatus)).share();
    }
    const std::shared_ptr<renderengine::ExternalTexture> texture = std::make_shared<
            renderengine::impl::ExternalTexture>(buffer, getRenderEngine(),
                                                 renderengine::impl::ExternalTexture::Usage::