android - eglCreateWindowSurface 因 java.lang.IllegalArgumentException 而失败

标签 android opengl-es opengl-es-2.0 glsurfaceview

在使用 GLSurfaceView 启动某些 Activity 期间尝试快速按下后退按钮时, 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)

这些 Activity 在 SurfaceHolder.Callback.surfaceCreated 之前没有调用 GL 操作或在 SurfaceHolder.Callback.surfaceDestroyed 之后.

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

感谢任何预付款。

最佳答案

在多个 Activity 之间切换会快速撕裂窗口表面。

我修补了 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 .

关于android - eglCreateWindowSurface 因 java.lang.IllegalArgumentException 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12855103/

相关文章:

android - 扫描蓝牙设备

android - 从待机/ sleep 状态返回时无法创建 EGL 表面

c# - 使用 OpenGL 从 ffmpeg 帧渲染视频

ios - OpenGL ES 应用程序模板项目在 iOS 模拟器中崩溃

android - 在 Drive SDK v.2 和 Google Drive Android API 之间共享凭据

android - 使用 Firebase Remote Config 进行互斥 A/B 测试

android - gl_FragCoord 值始终保持静态

c++ - iOS下OpenGL ES 2.0初始化

textures - 如何在OpenGL-ES 2.0中创建带有纹理(图像)的模板缓冲区

java - 如何在我的 WebVIew 应用程序中添加“滑动刷新”功能?