diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-09-23 04:47:24 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-09-23 06:46:00 (GMT) |
commit | 872872f3d3f0d89010d3a196b70e8445a08d0784 (patch) | |
tree | 062bf85b1ad43a850c1d94d13e7a276b4e8e5ab4 /src/gui/egl | |
parent | a9e50cd2fe243a912a5c70f157b043bbfc6413fb (diff) | |
download | Qt-872872f3d3f0d89010d3a196b70e8445a08d0784.zip Qt-872872f3d3f0d89010d3a196b70e8445a08d0784.tar.gz Qt-872872f3d3f0d89010d3a196b70e8445a08d0784.tar.bz2 |
Fix to QtOpenGL crash
Exiting the native video recorder on Symbian and going
back to Qt app which runs on opengl graphics system
crashed on some devices because there was not enough GPU
memory and also because low GPU mem device environment
detection was flawed. This patch fixes 32MB GPU memory
detection and adds wait/retrial to EGL surface creation
if it fails.
Task-number: QTBUG-21499
Reviewed-by: Laszlo Agocs
Diffstat (limited to 'src/gui/egl')
-rw-r--r-- | src/gui/egl/qegl.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 4db4a6a..02adef8 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -684,6 +684,37 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr else props = 0; EGLSurface surf; +#ifdef Q_OS_SYMBIAN + // On Symbian there might be situations (especially on 32MB GPU devices) + // where Qt is trying to create EGL surface while some other application + // is still holding all available GPU memory but is about to release it + // soon. For an example when exiting native video recorder and going back to + // Qt application behind it. Video stack tear down takes some time and Qt + // app might be too quick in reserving its EGL surface and thus running out + // of GPU memory right away. So if EGL surface creation fails due to bad + // alloc, let's try recreating it four times within ~1 second if needed. + // This strategy gives some time for video recorder to tear down its stack + // and a chance to Qt for creating a valid surface. + int tries = 4; + while(tries--) { + if (devType == QInternal::Widget) + surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); + else + surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props); + if (surf == EGL_NO_SURFACE) { + EGLint error = eglGetError(); + if (error == EGL_BAD_ALLOC) { + if (tries) { + User::After(1000 * 250); // 250ms + continue; + } + } + qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", error); + } else { + break; + } + } +#else if (devType == QInternal::Widget) surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); else @@ -691,6 +722,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr if (surf == EGL_NO_SURFACE) { qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); } +#endif return surf; } #endif |