Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.3.0 Beta1
-
None
-
Qt 5.3.0 beta1 for Android on Windows 7 (qt-opensource-windows-x86-android-5.3.0-beta)
Description
Any Qt3d QML examples deployed on Android that use textures will crash on exit in QGLTexture2D::TobeDeletedLater() when the OpenGLContext argument passed in is accessed.
As textures are widely used in shaderprogram and materials this affects many of the eamples and demos provided.
This is because as cleanup starts after the Quit() slot is called the OpenGL context is not in the same execution thread.
A warning as shown is seen followed by many repetitions of cleanupResources() warnings each one matching any textures used. Finally the crash comes when the context is deleted after it has already been freed.
E/libEGL (17836): call to OpenGL ES API with no current context (logged once per thread)
QGLTexture2DPrivate::cleanupResources()): cleanupResources() was called from wrong context. Some OpenGL resources are not released.
This issue was not seen in previous Qt releases of 5.2.x and is now seen on OpenGL ES 2 & 3 implementations alike. I have tried Adreno and Tegra.
I have been able to avoid this in all cases I have tried by adding the following hack to the destructor, but this essentially seems to prevent the context cleanup intended in mournGLContextDeath when I checked with a breakpoint:
QGLTexture2DPrivate::~QGLTexture2DPrivate()
{
if (!textureInfo.empty()) {
QOpenGLContext *ctx = QOpenGLContext::currentContext();
for (QList<QGLTexture2DTextureInfo*>::iterator It=textureInfo.begin(); It!=textureInfo.end(); ++It) {
if ((*It)>isLiteral==false && (*It)>tex.textureId()) {
#if defined(QT_OPENGL_ES)
if (ctx)
#else
QGLTexture2D::toBeDeletedLater(ictx, (*It)->tex.textureId());
#endif
}
}
}
qDeleteAll(textureInfo);
}