OSDN Git Service

libhwui: handle eglSwapBuffers with EGL_BAD_NATIVE_WINDOW error case
authorZhang Dongsheng <dongsheng.zhang@intel.com>
Thu, 21 Jan 2016 07:12:18 +0000 (15:12 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 20 Jul 2016 09:53:26 +0000 (17:53 +0800)
If eglSwapBuffers is called but the under surface was destroyed,
the EGL_BAD_NATIVE_WINDOW error may also be generated according
to the EGL spec 1.4.

This really shouldn't happen from the upper, but add the graceful
handling of this case also.

Change-Id: Ic0a599808b72f401d2a01c3dc40f9e6ea0e0a564
Signed-off-by: Zhang Dongsheng <dongsheng.zhang@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-12666
Reviewed-on: https://android.intel.com:443/460679

libs/hwui/renderthread/EglManager.cpp

index eb332d5..902264e 100644 (file)
@@ -291,11 +291,11 @@ bool EglManager::swapBuffers(EGLSurface surface, const SkRect& dirty,
     if (CC_LIKELY(err == EGL_SUCCESS)) {
         return true;
     }
-    if (err == EGL_BAD_SURFACE) {
+    if (err == EGL_BAD_SURFACE || err == EGL_BAD_NATIVE_WINDOW) {
         // For some reason our surface was destroyed out from under us
         // This really shouldn't happen, but if it does we can recover easily
         // by just not trying to use the surface anymore
-        ALOGW("swapBuffers encountered EGL_BAD_SURFACE on %p, halting rendering...", surface);
+        ALOGW("swapBuffers encountered EGL error %d on %p, halting rendering...", err, surface);
         return false;
     }
     LOG_ALWAYS_FATAL("Encountered EGL error %d %s during rendering",