Bug 1057983 - Cross-compiled (mingw32) Qt5 OpenGL applications crash/do not paint, EGL fails with error 12289
Summary: Cross-compiled (mingw32) Qt5 OpenGL applications crash/do not paint, EGL fail...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw-angleproject
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Erik van Pienbroek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-26 10:54 UTC by max.mail
Modified: 2014-02-09 03:52 UTC (History)
2 users (show)

Fixed In Version: mingw-angleproject-0-0.9.svn2215.20130517.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-09 03:52:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to replace missing sprintf_s by sprintf in angleproject (Display.cpp) (584 bytes, patch)
2014-01-26 17:33 UTC, max.mail
no flags Details | Diff

Description max.mail 2014-01-26 10:54:16 UTC
Description of problem:
Qt5 apps (e.g. QOpenGLWindow or any other Qt OpenGL example, cross-compiled with mingw32) using OpenGL and compiled with Angle crash at start or do not update the OpenGL region.

Version-Release number of selected component (if applicable):
mingw32-angleproject: 0-0.7.svn2215.20130517.fc20
mingw32-qt5-qtbase: 5.2.0-4.fc20

How reproducible:
1. Compile some Qt OpenGL examples (from [0], e.g. [1]).
2. Copy the app and necessary .dlls to a Windows XP or Windows 7 machine.
3. Run the app.

Actual results:
mingw32-gdb prints out the following:
"warning: static QWindowsEGLStaticContext* QWindowsEGLStaticContext::create(): Could not initialize egl display: error 12289"
Most apps crash (Windows 7 says Qt5Gui.dll is crashing), some apps ("hellowindow", "textures" samples) just print the warning above and do not update/paint the window.

Expected results:
OpenGL applications running fine and animated.

Additional info:
* Running normal Qt5 GUI apps works fine.
* I do not know exactly which .dlls have to be provided with the app, however I copied all .dlls necessary to run normal Qt5 GUI apps and additionally provided libEGL, libGLESv2, and tried with and without d3dcompiler_43.dll.
* I did not find a working OpenGL ES 2.0 example apart from the Qt ones, so I can only suppose that this is not related to Qt, only to Angle.
* egl2info.exe (from [2]) prints: "error: eglInitialize() failed."
* I did the tests on a Windows XP and Windows 7 (both 32 bit) virtual machines in VirtualBox with full DirectX installed. Therefore the bug could be related to [3]. I will do some tests on a real Windows machine soon.
* Running the apps with Wine results in the same 12289 EGL error.

[0] http://qt-project.org/doc/qt-5.0/qtopengl/examples-widgets-opengl.html
[1] https://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html
[2] https://code.google.com/p/angleproject/downloads/detail?name=egl2info.exe&can=2&q=
[3] https://bugreports.qt-project.org/browse/QTBUG-29925

Comment 1 Erik van Pienbroek 2014-01-26 11:29:00 UTC
Hi,

I did some testing here and found the culprit. There actually are multiple issues here:

1. ANGLE expects either d3dcompiler_43.dll or d3dcompiler_46.dll to be distributed along with the executable (which are proprietary libraries which are part of the Windows SDK)
2. Due to a bug in ANGLE (already resolved in latest upstream) only a check is done whether the d3dcompiler_43.dll or d3dcompiler_46.dll libraries are already loaded in the current process. No attempt is done to LoadLibrary them
3. Due to a bug in qt5-qtbase (AFAIK not resolved yet) a segfault occurs in QOpenGLContext::shareGroup when EGL (thus ANGLE) couldn't be initialised. According Google this segfault also occurs on other environment (like Linux) when the GL stack couldn't be initialised

Issue 1 is something which the user (not the end-user, but the user of the mingw libraries) itself is supposed to fix (in Fedora we aren't allowed to redistribute proprietary libraries)

Issue 2 should be fixed with http://koji.fedoraproject.org/koji/taskinfo?taskID=6454866

Issue 3 should be reported upstream (if this hasn't happened already..haven't checked)

Could you test the updated mingw-angleproject package (issue 2) and see if that helps?

Comment 2 max.mail 2014-01-26 16:24:12 UTC
Hi,
wow, thank you for replying that fast and finding the issues!

Issue 1: I already read this somewhere else and tried to put d3dcompiler_43.dll in the same folder, but it changed nothing.

Issue 2: Thank you very much for fixing this, on Windows 7 (on Wine as well) the library gets loaded now. I already had found the line (in Display.cpp it was, I think) where the error 12289 was thrown, but I did not see that the library was not loaded.

Issue 3: I'd not like to report this upstream, because I hardly know anything about this, apart from that Qt crashes when EGL fails initializing. I also found only [2] where QOpenGLContext::shareGroup() was crashing. Maybe you could report this upstream?

On Windows 7 the apps work quite ok. I noticed that apps like QOpenGLWindow or the Cube example do not show anything apart from a black window. However the Direct3D driver of my VirtualBox machine seems to be a bit unstable, and the machine has already crashed once, so this might be the reason.
Thank you for the hint trying GDB on Windows, this works just fine!

On Windows XP there is still an error when loading the platform plugins, and the apps crash. Apparently (according to DependencyWalker) the libEGL.dll you provided in [1] still depends on sprintf_s, which is not defined in msvcrt.dll. It would be great if you could provide an Angle build where vsprintf_s and sprintf_s are fixed and d3dcompiler_43.dll is loaded. Then all current issues should be gone.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1054481#c9
[2] http://comments.gmane.org/gmane.comp.lib.qt.qml/3060

Comment 3 max.mail 2014-01-26 17:32:05 UTC
In [1] you provided a patch to make Angle use vsprintf_s by mingw-crt. I tried the same type of patch for sprintf_s and on Arch Linux (because I have no Fedora/RPM package building experience), but Angle compilation fails: "undefined reference to `sprintf_s'". Apparently sprintf_s is not defined by mingw-crt. 
Then I just replaced sprintf_s by sprintf (and adapted function parameters, see attachment) in Display.cpp and recompiled Angle successfully. However the app crashes again, with an error as [2].
Maybe this is due to Arch Linux builds, could you please provide an Angle (and crt?) build on Fedora where vsprintf_s and sprintf_s are working and d3dcompiler_43.dll gets loaded?

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1054481#c9
[2] https://bugzilla.redhat.com/attachment.cgi?id=855337

Comment 4 max.mail 2014-01-26 17:33:29 UTC
Created attachment 855713 [details]
Patch to replace missing sprintf_s by sprintf in angleproject (Display.cpp)

This patch does not solve the main issue.

Comment 5 max.mail 2014-01-26 17:37:16 UTC
PS: When the app crashes as mentioned in #3, the following error appears on command line:
"warning: QMutex: destroying locked mutex"

Comment 6 Erik van Pienbroek 2014-01-26 19:30:11 UTC
Please keep the Windows XP compatibility issues in the other ticket (bug 1054481). They're a different issue then the crash you mentioned in this ticket. I just updated that other ticket with more details about the Windows XP compatibility.

If I understand you correctly the crash is resolved with the latest mingw-angleproject package. I don't know if the black window is due to a VirtualBox issue or a ANGLE/Qt5 issue. I tested the updated package on my local Windows 7 x64 environment and here the qtopenglwindow example works fine (it shows a triangle). Perhaps you could test it on a native Windows environment as well to be certain

Comment 7 max.mail 2014-01-26 21:01:51 UTC
I'm sorry for mixing up the issues, thanks for providing a fix there.
As I only can build packages on Arch Linux yet, I had to do the tests there. The results should be about the same.

Currently on Windows XP (on VM as well as on native machine) apps are still crashing like [1] and showing at console: "warning: QMutex: destroying locked mutex"
The dependency issues are solved however.

On Windows 7 (VM) apps display a black window, but show no EGL error, so this could be related to VirtualBox graphics. I do not have a native Windows 7 machine here, sorry.

Could you please upload a binary tarball which is working for you, or are binary uploads not allowed here (I'm new to bug trackers)?
It would be great if you could provide a Fedora build of Angle/crt with your patches of this and the other bugreport, to avoid unnecessary issues from Arch Linux builds.

I have one last question: What .dlls do you have to deploy with Qt apps and where to put them? I copied all necessary .dlls and the app itself in the same folder, but you need the platforms/ directory and qwindows.dll as well, and apparently also libEGL, libGLESv2, d3dcompiler_xx, QtCore and QtGui in the platforms/ directory to avoid the EGL 12289 error. Have I understood that correctly?
Dependency Walker shows no more unbound dependencies.

Thank you for your nice help!

[1] https://bugzilla.redhat.com/attachment.cgi?id=855337

Comment 8 Fedora Update System 2014-02-05 07:03:08 UTC
mingw-angleproject-0-0.9.svn2215.20130517.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mingw-angleproject-0-0.9.svn2215.20130517.fc20

Comment 9 Fedora Update System 2014-02-06 03:58:17 UTC
Package mingw-angleproject-0-0.9.svn2215.20130517.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing mingw-angleproject-0-0.9.svn2215.20130517.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2075/mingw-angleproject-0-0.9.svn2215.20130517.fc20
then log in and leave karma (feedback).

Comment 10 max.mail 2014-02-07 21:15:24 UTC
The package updates stated above solve all ANGLE/OpenGL related issues, and Qt5 OpenGL programs run fine on Windows XP (SP2, 32 bit) now. I left appropriate karma at the site linked above.
Thank you very much for fixing this.

(If there is anything left to do now for this bug, please let me know, I'm new to bugfixing.)

Comment 11 Fedora Update System 2014-02-09 03:52:59 UTC
mingw-angleproject-0-0.9.svn2215.20130517.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.