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

Commit 2a09a93f authored by Alec Mouri's avatar Alec Mouri
Browse files

Check for allocation failure for the readback buffer

Bug: 431746508
Flag: com.android.graphics.surfaceflinger.flags.readback_screenshot
Test: enable debug.sf.productionize_readback_screenshot on a device that
doesn't actually support readback

Change-Id: I7d63cdd13b78bb43d4464b763a6fe628e533ba78
parent 2a39e4ba
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -7782,6 +7782,11 @@ SurfaceFlinger::setScreenshotSnapshotsAndDisplayState(ScreenshotArgs& args) {
                                                                         attributes.format),
                                                                 1 /* layerCount */, usage,
                                                                 "screenshot");

                            if (const auto status = readbackBuffer->initCheck(); status != OK) {
                                ALOGE("Failed to allocate readback buffer :(: %d", status);
                                return base::unexpected<status_t>(INVALID_OPERATION);
                            } else {
                                mReadbackRequests.emplace_back(*asPhysicalDisplayId(displayId),
                                                               readbackBuffer, args.captureListener,
                                                               args.preserveDisplayColors,
@@ -7791,6 +7796,7 @@ SurfaceFlinger::setScreenshotSnapshotsAndDisplayState(ScreenshotArgs& args) {
                            }
                        }
                    }
                }

                // Non-threaded RenderEngine eventually returns to the main thread a 2nd time
                // to complete the screenshot. Release fences should only be added during the 2nd