在使用GLSurfaceView启动某些活动期间尝试快速按下后退按钮时,eglCreateWindowSurface会因
java.lang.IllegalArgumentException而失败.
我收到以下错误:
10-08 18:05:36.490: E/GLSurfaceView(3440): eglCreateWindowSurface 10-08 18:05:36.490: E/GLSurfaceView(3440): java.lang.IllegalArgumentException: Make sure the SurfaceView or associated SurfaceHolder has a valid Surface 10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl._eglCreateWindowSurface(Native Method) 10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:90) 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$DefaultWindowSurfaceFactory.createWindowSurface(GLSurfaceView.java:798) 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$EglHelper.createSurface(GLSurfaceView.java:1065) 10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1433) 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的竞争条件
从:
if (createEglSurface) { if (LOG_SURFACE) { Log.w("GLThread","egl createSurface"); } gl = (GL10) mEglHelper.createSurface(getHolder()); if (gl == null) { // Couldn't create a surface. Quit quietly. break; } sGLThreadManager.checkGLDriver(gl); createEglSurface = false; }
至:
if (createEglSurface) { if (LOG_SURFACE) { Log.w("GLThread","egl createSurface"); } gl = (GL10) mEglHelper.createSurface(getHolder()); if (gl == null) { // If we escape,GLThread ends up. Don't escape. continue; } sGLThreadManager.checkGLDriver(gl); createEglSurface = false; }
它看起来像这个问题是fixed in JellyBean.