- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我不断收到此错误报告:
Fatal Exception: java.lang.IllegalStateException
eglMakeCurrent failed EGL_BAD_ALLOC
android.view.HardwareRenderer$GlRenderer.createSurface
...在我在 Play 商店中的应用上。
是什么导致了这个崩溃以及如何修复它?
以下是完整的错误日志:
java.lang.IllegalStateException: eglMakeCurrent failed EGL_BAD_ALLOC
at android.view.HardwareRenderer$GlRenderer.createSurface(HardwareRenderer.java:1354)
at android.view.HardwareRenderer$GlRenderer.createEglSurface(HardwareRenderer.java:1241)
at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:1058)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1811)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1235)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6472)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(NativeStart.java)
最佳答案
如果您查看 EGL specification , 这个错误有几个可能的原因。您的应用程序中的某些东西似乎导致其资源不足。规范声明如下:
3.7.3 Binding Contexts and Drawables
...
eglMakeCurrent
binds ctx to the current rendering thread and to the draw and read surfaces...Errors
... If the ancillary buffers for draw and read cannot be allocated, an
EGL_BAD_ALLOC
error is generated...
要解决此问题,您可以检查应用程序的内存使用情况。有许多不同的技术可以调查您的应用程序的 ram 使用情况,some techniques are documented quite well in this guide.
This post还描述了调用eglMakeCurrent时如果调用eglCreatePbufferSurface
时没有设置像素缓冲区的EGL_WIDTH
和EGL_HEIGHT
参数会触发错误。这是创建像素缓冲区的最小 Java 示例 (full source located here) ,确保输入的宽高大于零:
private void eglSetup(int width, int height) {
mEGL = (EGL10)EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (!mEGL.eglInitialize(mEGLDisplay, null)) {
throw new RuntimeException("unable to initialize EGL10");
}
// Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits
// to be able to tell if the frame is reasonable.
int[] attribList = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE
};
EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1];
if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, 1, numConfigs)) {
throw new RuntimeException("unable to find RGB888+pbuffer EGL config");
}
// Configure context for OpenGL ES 2.0.
int[] attrib_list = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
};
mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT,
attrib_list);
checkEglError("eglCreateContext");
if (mEGLContext == null) {
throw new RuntimeException("null context");
}
// Create a pbuffer surface. By using this for output, we can use glReadPixels
// to test values in the output.
int[] surfaceAttribs = {
EGL10.EGL_WIDTH, width,
EGL10.EGL_HEIGHT, height,
EGL10.EGL_NONE
};
mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs);
checkEglError("eglCreatePbufferSurface");
if (mEGLSurface == null) {
throw new RuntimeException("surface was null");
}
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
}
如果不了解应用程序实现的更多细节,就很难确定确切的原因。这应该是识别和解决问题的良好起点。
关于android - eglMakeCurrent() 失败 EGL_BAD_ALLOC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30393353/
我的程序在两个 Activity 之间切换,每个 Activity 都会膨胀一个使用 VBO 的派生 GLSurfaceView。 在两个Activity之间来回切换几次后,程序崩溃并抛出如下异常:
我不断收到此错误报告: Fatal Exception: java.lang.IllegalStateException eglMakeCurrent failed EGL_BAD_ALLOC and
我在 Google Play 上有一个用于倒数数字和字母的应用程序。在这个应用程序中,我有以下 Activity : 谷歌登录 文件 admob 服务 我使用 Google Analytics(分析)
我正在使用 OpenGL ES 2.0 和 Android NDK r8b。我有一个用于工作线程的共享上下文。当我尝试使用 eglMakeCurrent 将共享上下文绑定(bind)到工作线程时,我收
我正在使用抛出异常的 And 引擎开发游戏。其实我不知道发生异常的地方。市场上多次报道。 java.lang.RuntimeException: eglSwapBuffers failed:
在 Samsung Galaxy S6 上安装后第一次打开应用程序时出现 eglCreateWindowSurface GL Error EGL_BAD_ALLOC 并且相同的代码在其他设备上工作正常
我有一个处理图像的动态壁纸应用。 我在 Play 商店(但在 fabric.io 中没有)收到一些崩溃报告,其中包含此堆栈跟踪: *** *** *** *** *** *** *** *** ***
在使用 eglCreateWindowSurface() 绘制后,我无法将 Surface 锁定到 EGL(使用 Surface.lockCanvas(null))即使我用 Surface.unloc
在 Nexus 10 更新到 Android 4.4 后,我的应用程序中出现 EGL 错误:EGL_BAD_ALLOC。它会导致硬件加速关闭,后来由于以下错误而完全阻止应用程序。 为了导致错误,我使用
我是一名优秀的程序员,十分优秀!