summaryrefslogtreecommitdiffstats
path: root/opengl/java
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2011-10-14 07:34:05 -0700
committerJack Palevich <jackpal@google.com>2011-10-14 07:34:05 -0700
commita35c120d8fafa7dded606a25bc100b13f48ab9e3 (patch)
tree53bde00af464433a99270c6c1b7580608b027fb3 /opengl/java
parent772158a596bc97694fa82e710b5cfbe8c6f40cdc (diff)
downloadframeworks_base-a35c120d8fafa7dded606a25bc100b13f48ab9e3.zip
frameworks_base-a35c120d8fafa7dded606a25bc100b13f48ab9e3.tar.gz
frameworks_base-a35c120d8fafa7dded606a25bc100b13f48ab9e3.tar.bz2
Work around race condition when shutting down a surface flinger surface.
Works around b/4588890 Change-Id: Ie0cf1f212686aec93cda85bf112f4b7ab4197256
Diffstat (limited to 'opengl/java')
-rw-r--r--opengl/java/android/opengl/GLSurfaceView.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java
index 4c7f84e..0b4f403 100644
--- a/opengl/java/android/opengl/GLSurfaceView.java
+++ b/opengl/java/android/opengl/GLSurfaceView.java
@@ -768,6 +768,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* {@link GLSurfaceView#setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory)}
*/
public interface EGLWindowSurfaceFactory {
+ /**
+ * @return null if the surface cannot be constructed.
+ */
EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config,
Object nativeWindow);
void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface);
@@ -777,7 +780,19 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
EGLConfig config, Object nativeWindow) {
- return egl.eglCreateWindowSurface(display, config, nativeWindow, null);
+ EGLSurface result = null;
+ try {
+ result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
+ } catch (IllegalArgumentException e) {
+ // This exception indicates that the surface flinger surface
+ // is not valid. This can happen if the surface flinger surface has
+ // been torn down, but the application has not yet been
+ // notified via SurfaceHolder.Callback.surfaceDestroyed.
+ // In theory the application should be notified first,
+ // but in practice sometimes it is not. See b/4588890
+ Log.e(TAG, "eglCreateWindowSurface", e);
+ }
+ return result;
}
public void destroySurface(EGL10 egl, EGLDisplay display,
@@ -1041,9 +1056,8 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
int error = mEgl.eglGetError();
if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
Log.e("EglHelper", "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
- return null;
}
- throwEglException("createWindowSurface", error);
+ return null;
}
/*