Native Activity crash on EGL init in eglGetConfigAttrib

118 views
Skip to first unread message

NoAngel

unread,
Jul 7, 2014, 5:27:14 AM7/7/14
to andro...@googlegroups.com
My app uses native activity and I got crash when running an app on Fujitsu Arrowz Z, Tegra 3, Android version 4.0.3.

My source:

...
EGLint attribs[] = {
EGL_RENDERABLE_TYPE,EGL_OPENGL_ES2_BIT,
EGL_DEPTH_SIZE,24,
EGL_NONE
};
EGLConfig config;
EGLint numConfigs,format;
EGLDisplay display=eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display,0,0);
EGLBoolean ret=eglChooseConfig(display,attribs,&config,1, &numConfigs); //should return EGL_FALSE on Tegra 3
if(ret == EGL_TRUE)
{
ret = eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
}
if(ret != EGL_TRUE)
{
attribs[3] = 16; //retry with 16 bit depth buffer
ret = eglChooseConfig(display, attribs, &config, 1, &numConfigs); //returns EGL_TRUE
if(ret != EGL_TRUE)
{
return false;
}
rv = eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); //crashes
if(rv != EGL_TRUE)
{
return false;
}
}
if(ANativeWindow_setBuffersGeometry((ANativeWindow*)dh, 0, 0, format) <0)
...

crash log:

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=2404352)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
#00  /system/lib/libEGL.so
#01  /system/lib/libEGL.so (eglGetConfigAttrib)
#02  /blablabla/myapp.so

What is the workaround or fix to make it work?
My app crashes only on this device. It works fine on all other devices, including other Tegra 3 devices, I tested many.

NoAngel

unread,
Jun 14, 2016, 10:50:54 AM6/14/16
to android-ndk
I found a solution.

eglChooseConfig(display,attribs,&config,1, &numConfigs);
is wrong.

I changed it to get all device configurations, then select the best one, and it fixed.

Reply all
Reply to author
Forward
0 new messages