android – eglCreateWindowSurface失败,出现java.lang.IllegalArgumentException

前端之家收集整理的这篇文章主要介绍了android – eglCreateWindowSurface失败,出现java.lang.IllegalArgumentException前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在使用GLSurfaceView启动某些活动期间尝试快速按下后退按钮时,eglCreateWindowSurface会因 java.lang.IllegalArgumentException而失败.

我收到以下错误

  1. 10-08 18:05:36.490: E/GLSurfaceView(3440): eglCreateWindowSurface
  2. 10-08 18:05:36.490: E/GLSurfaceView(3440): java.lang.IllegalArgumentException: Make sure the SurfaceView or associated SurfaceHolder has a valid Surface
  3. 10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl._eglCreateWindowSurface(Native Method)
  4. 10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:90)
  5. 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$DefaultWindowSurfaceFactory.createWindowSurface(GLSurfaceView.java:798)
  6. 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$EglHelper.createSurface(GLSurfaceView.java:1065)
  7. 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1433)
  8. 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)

这些活动未在SurfaceHolder.Callback.surfaceCreated之前或SurfaceHolder.Callback.surfaceDestroyed之后调用GL操作.

有没有其他人遇到这个问题,解决方案是什么?

谢谢你的任何进步.

解决方法

在多个活动之间切换快速撕裂窗口表面.

我修补了GLSurfaceView.guardedRun()以避免GLSurfaceView的竞争条件

从:

  1. if (createEglSurface) {
  2. if (LOG_SURFACE) {
  3. Log.w("GLThread","egl createSurface");
  4. }
  5. gl = (GL10) mEglHelper.createSurface(getHolder());
  6. if (gl == null) {
  7. // Couldn't create a surface. Quit quietly.
  8. break;
  9. }
  10. sGLThreadManager.checkGLDriver(gl);
  11. createEglSurface = false;
  12. }

至:

  1. if (createEglSurface) {
  2. if (LOG_SURFACE) {
  3. Log.w("GLThread","egl createSurface");
  4. }
  5. gl = (GL10) mEglHelper.createSurface(getHolder());
  6. if (gl == null) {
  7. // If we escape,GLThread ends up. Don't escape.
  8. continue;
  9. }
  10. sGLThreadManager.checkGLDriver(gl);
  11. createEglSurface = false;
  12. }

它看起来像这个问题是fixed in JellyBean.

猜你在找的Android相关文章