OSDN Git Service

Handle repeated swapBuffer errors
authorJoshua Lang <joshualang@google.com>
Thu, 8 Dec 2016 22:49:07 +0000 (14:49 -0800)
committerJoshua Lang <joshualang@google.com>
Thu, 8 Dec 2016 23:11:42 +0000 (15:11 -0800)
Changed eglSwapBuffers to actually signal an error when swapBuffers
fails. This was hiding an error log at the SurfaceFlinger callsite.

When eglSwapBuffers is called after a prior error, we should not try to
enqueue a NULL buffer which was causing a segfault that takes down
SurfaceFlinger.

Bug: 33432596
Change-Id: I72f3301e0adbc4ea75266c9c1c9e01d9169036e7

system/egl/egl.cpp

index db256c0..ea0ac2e 100644 (file)
@@ -454,6 +454,11 @@ EGLBoolean egl_window_surface_t::swapBuffers()
 
     int presentFenceFd = -1;
 
+    if (buffer == NULL) {
+        ALOGE("egl_window_surface_t::swapBuffers called with NULL buffer");
+        setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE);
+    }
+
 #if PLATFORM_SDK_VERSION <= 16
     rcEnc->rcFlushWindowColorBuffer(rcEnc, rcSurface);
     // equivalent to glFinish if no native sync
@@ -1527,10 +1532,10 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface eglSurface)
         setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE);
 
     // post the surface
-    d->swapBuffers();
+    EGLBoolean ret = d->swapBuffers();
 
     hostCon->flush();
-    return EGL_TRUE;
+    return ret;
 }
 
 EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)