Fixed the bug where egl_surface_t is not deleted
This bug results in egl_surface_t objects in guest not being destroyed
properly and therefore increased memory usage.
Test: run cts -m "CtsOpenGLTestCases" -t "android.opengl.cts.WrapperTest#testThreadCleanup"
should not increase memory usage significantly (e.g 1GB).
BUG: 111076027
Change-Id: I297d6d89fcf990410cf559132af8127026354d63
Signed-off-by: Weilun Du <wdu@google.com>
(cherry picked from commit 1c9b30150c5d5c36777a11d4b7c0c2d09c281f74)
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index 4261de0..953f3f0 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -611,7 +611,10 @@
// Destroy a pending surface and set it to NULL.
static void s_destroyPendingSurfaceAndSetNull(EGLSurface* surface) {
- if (!s_display.isSurface(surface)) {
+ if (!surface)
+ return;
+
+ if (!s_display.isSurface(*surface)) {
*surface = NULL;
return;
}