Languages

Menu
Sites
Language
Problems with OpenGL
Hi all! I have a problem with my application. Sometime it crashes on eglSwapBuffers. Update and drawing are in worker thread. Is it my mistake, or it is a Tizen bug? This is callstack:  0: __dynamic_cast + 0x11 (0x4216fb12) [/usr/lib/libstdc++.so.6] + 0x85b12  1: _ZNK5Tizen2Ui10Animations25_VisualElementSurfaceImpl6EqualsERKNS_4Base6ObjectE + 0x1f (0x42f76c58) [/usr/lib/osp/libosp-uifw.so] + 0x222c58  2: _ZNK5Tizen2Ui10Animations20VisualElementSurface6EqualsERKNS_4Base6ObjectE + 0x15 (0x42f767e6) [/usr/lib/osp/libosp-uifw.so] + 0x2227e6  3: _ZN5Tizen2Ui10Animations18_VisualElementImpl10SetSurfaceEPKNS1_20VisualElementSurfaceE + 0x2f (0x42f67f80) [/usr/lib/osp/libosp-uifw.so] + 0x213f80  4: _ZN5Tizen2Ui10Animations13VisualElement10SetSurfaceEPNS1_20VisualElementSurfaceE + 0x1b (0x42fa8560) [/usr/lib/osp/libosp-uifw.so] + 0x254560  5: _SglSwapBuffers + 0xb1 (0x43366dfa) [/usr/lib/osp/libosp-uifw.so] + 0x612dfa  6: _ZN2tizen11CThread4DrawEv + 0x70 (0x4453b394) [/opt/apps/111/bin/app.exe] + 0x180394   GL init:
bool CThread::InitEGL()
{
EGLint numConfigs = 1;
 
EGLint eglConfigList[] =
{ EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 0, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, EGL_NONE };
 
EGLint eglContextList[] =
{ EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
 
eglBindAPI(EGL_OPENGL_ES_API);
 
if (m_EglDisplay)
{
DestroyGL();
}
 
m_EglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
 
eglInitialize(m_EglDisplay, null, null);
 
eglChooseConfig(m_EglDisplay, eglConfigList, &m_EglConfig, 1, &numConfigs);
m_EglSurface = eglCreateWindowSurface(m_EglDisplay, m_EglConfig,
(EGLNativeWindowType) m_Form, null);
 
m_EglContext = eglCreateContext(m_EglDisplay, m_EglConfig, EGL_NO_CONTEXT,
eglContextList);
 
eglMakeCurrent(m_EglDisplay, m_EglSurface, m_EglSurface, m_EglContext);
 
return true;
}
 
Draw:
void CThread::Draw()
{
eglMakeCurrent(m_EglDisplay, m_EglSurface, m_EglSurface, m_EglContext);
// AppDraw...
eglSwapBuffers(m_EglDisplay, m_EglSurface); // <--------------- it crashes here! =(
}
 
Edited by: Artyom Tanygin on 15 Jul, 2013

Responses

5 Replies
Benjamin Blois
I had a similar problem and someone answered me here : https://developer.tizen.org/forums/native-application-development/glplayer-not-thread-safe that all OpenGL operation operations must be performed on the main thread (not a working thread. Maybe there is a way to do that anyway (that i did not find), but the best way I saw to do that is to use the event system to fill a pile of OpenGl operation. This pile is consumed periodically by the main thread.
Artyom Tanygin
I know about this problem with GlPlayer, but i'm not use it. And unfortunately, this is unacceptable to me to draw in the main thread.
Artyom Tanygin
.
muditha murthy
If possible can you attach your sample app ?
Artyom Tanygin
I have no sample app, only full project, and it is rather big. You can create sample app from GlesCube11 sample, just move OpenGl initialization and drawing in a worker thread.