SF: Add workaround to release screenshot buffer
Works around driver behavior to force the [E]GL driver to fully release
the screenshot buffer immediately after the screenshot is complete
rather than deferring until the next instance of client composition.
Bug: b/77935566
Test: Manual, inspect 'dumpsys SurfaceFlinger' after launching an app
and then returning home (which causes a screenshot for overview)
Change-Id: I4f33d89f3ff3020707a9f556a1fcfe34bc9b7adb
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index 4c878ae..c2233f9 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -427,6 +427,12 @@
// back to main framebuffer
unbindFramebuffer(bindHelper->mTexName, bindHelper->mFbName);
eglDestroyImageKHR(mEGLDisplay, bindHelper->mImage);
+
+ // Workaround for b/77935566 to force the EGL driver to release the
+ // screenshot buffer
+ setScissor(0, 0, 0, 0);
+ clearWithColor(0.0, 0.0, 0.0, 0.0);
+ disableScissor();
}
// ---------------------------------------------------------------------------