Bug 458143 - Opening a picture using OpenGL viewer generates an OpenGL error then digikam crashes
Summary: Opening a picture using OpenGL viewer generates an OpenGL error then digikam ...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-GLViewer (show other bugs)
Version: 8.2.0
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-21 13:38 UTC by Jean-Fred
Modified: 2023-11-20 09:23 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.2.0
Sentry Crash Report:


Attachments
DK 6.2.0 (VSPKC) : VSCode backtrace of the crash in OpenGL viever (506.78 KB, image/png)
2023-11-19 17:41 UTC, caulier.gilles
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Fred 2022-08-21 13:38:18 UTC
SUMMARY
On my system, OpenGL image viewer does not work and results in systematic digiKam crash.
It looks like OpenGL context cannot initialize properly for some reason.

STEPS TO REPRODUCE
1. Select a picture.
2. Open OpenGL viewer from menubar.
3. 

OBSERVED RESULT
In a first time an error window shows up with message like "No OpenGL context found"
Clicking on "OK" closes the error windows.
As soon as digiKam main window is clicked, it freezes briefly then exits abruptly.

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: Windows 10 Professionnel 64bits 21H2 - Build 19044.1889
Qt Version: 5.15.5

ADDITIONAL INFORMATION
DigiKam is installed from Windows bundle found on digiKam web site (digiKam-7.7.0-Win64.exe).
System display adapter (Intel HD Graphics) supports OpenGL up to 2.1 included.

Thanks!
JF
Comment 1 Jean-Fred 2022-08-21 19:22:11 UTC
More info...

Looking to DebugView log, it seems that digiKam/Qt does not manage to find a few DLLs:
...
00000644	34.28241348	[9392] digikam.dplugin.generic: 145 images loaded	
00000645	34.63073349	[9392] Failed to load libEGL (Le module spécifié est introuvable.)	
00000646	34.63084412	[9392] create: Failed to load and resolve libEGL functions	
00000647	34.63422012	[9392] Failed to load opengl32sw.dll (Le module spécifié est introuvable.)	
00000648	34.63431931	[9392] Failed to load and resolve WGL/OpenGL functions	
...

From the info I was able to gather, those also seems to be part of Mesa3d and/or angle.
Unsurprinsingly, I was not able to find any of those library anywhere on my system...
Should those libraries be part of the Windows bundle or be already part of the system?

Regards,

JF

Thanks!

JF
Comment 2 Maik Qualmann 2022-08-21 20:27:05 UTC
Yes, it crashes when working OpenGL is not available. See also Bug 437658

Is the Intel graphics driver from the Microsoft update installed?
Does Intel have a driver package for your graphics card that you can download?

Maik
Comment 3 Jean-Fred 2022-08-21 21:39:44 UTC
Hi Maik,

Yes, latest Intel driver was installed for MS update, and no, Intel does not provide directly any W10 driver pack for this (pretty old) adapter.
As a matter of fact, the driver pack provided by MS update seems to be coming directly from Intel (driver dialog reports Package provider = Intel Corp.) - MS seems to only take care of package signature.
To verify nothing is obviously wrong with my system, I ran OpenGL Extensions Viewer on my system to see what level of OpenGL is fully supported by my system. It report OpenGL 2.1 is 100% supported which should be fine for Qt5 I think.
The interesting thing is that when digiKam is running normally (i.e. before calling OpenGL viewer), Process Explorer reports it is dynamically linking opengl32.dll, which probably means OpenGL Viewer and/or other part of digiKam is using openGL through "desktop" OpenGL driver I guess.
Not sure however why digiKam/Qt requires libEGL.dll/opengl32ws.dll if a valid openGL driver is already present on the system as from what I understand those dlls are related to software and/or directx emulation of openGL calls...

Regards,

Jean-Fred
Comment 4 Jean-Fred 2022-08-22 20:02:50 UTC
Maik,

More investigation results on my side.
I did a few experiments to address the folowing things:
1 - About the missing libEGL.dll lib:
	I copied a few ANGLE related dlls from Chrome in to digiKam dir (It seems ANGLE comes from Google...)
	That changes things quite a bit:
	I first get a different error message telling that GL_ARB_texture is not managed.
	(This is confirmed by DebugView log: "00001756	47.07304001	[13568] digikam.dplugin.generic: GL_ARB_texture_rectangle not supported.")
	Process explorer shows that ligEGL.dll, d3compiler_47.dll and d3d11.dll (the one I copied) are loaded when OpenGL viewer is called.
	When clicking OK in error window no crash any more but a black OpenGL Viewer window.
	From the info I found, ANGLE seems not to support GL_ARB_texture_rectangle extension => consistent with behavior described above.
2 - About the missing opengl32sw.dll lib:
	Was no able to find an opengl32sw.dll lib that works if libEGL is not there... Probably need to match library Qt5 was linked against...
3 - About understanding why my openGL seems not to work with digiKam:
    Looking to Qt5 doc, there is a way to force the use of desktop OpenGL driver through the use of an env. var.
    I tried this from a command prompt: "set QT_OPENGL=desktop" then start digiKam from same prompt.
	Doing so digiKam OpenGL viewer operates flawlessly - no doubt that display is hardware acelerated considering how fast display refreshes.
	(Whether the extra libegl:... libraries are in digiKam dir or not does not chnage anything.)
I guess that the way Qt5 manages OpenGL is that it first checks if a desktop openGL driver is available if not it tries ANGLE (which will fail if libegl and its dependencies are not there) and finally tries openGL software emulation (which fails if opengl32sw is not there).
On my system, not sure why, it seems Qt5 fails to detect if an openGL desktop driver is there...
To conclude with this, I added QT_OPENGL in my environment variable and that works.
However I think that's not very clean as this may interfere with other Qt apps...
Maybe there are other ways to force Qt using desktop driver usage from inside the app, that may allow implementation of a "OpenGL driver" checkbox/combobox inside digiKam config.
Not sure why Qt5 does fail detecting my openGL driver (a bug?).
As a side note, maybe libegl and related libs as well as opengl32sw lib need to be added to the window bundle (even though libegl does not help) to get all dependencies fullfilled?

Regards,

Jean-Fred
Comment 5 caulier.gilles 2023-04-19 05:48:18 UTC
@Jean-fred

digiKam 8.0.0 is released. This file still valid ?

Gilles Caulier
Comment 6 caulier.gilles 2023-10-15 08:22:05 UTC
@Jean-fred,

This problem still reproducible with the new digiKam 8.2.0 pre-release Windows
installer available at usual place:

https://files.kde.org/digikam/

This new bundle is based on last Qt framework 5.15.11 and KDE framework 5.110.

Thanks in advance

Gilles Caulier
Comment 7 caulier.gilles 2023-11-19 17:05:03 UTC
Maik,

Crash is reproducible with VCPKG version, but after the dialog indicating that OpenGL context is missing.

1/ It miss probably the DirectX stuff in background.
2/ It must not crash without context.

Gilles
Comment 8 caulier.gilles 2023-11-19 17:06:18 UTC
*** Bug 437658 has been marked as a duplicate of this bug. ***
Comment 9 caulier.gilles 2023-11-19 17:41:34 UTC
Created attachment 163294 [details]
DK 6.2.0 (VSPKC) : VSCode backtrace of the crash in OpenGL viever

Maik,

It's clear. Without opengl, the instance is null.

Gilles
Comment 10 caulier.gilles 2023-11-19 22:40:24 UTC
Git commit aaf8a75f033e6841d125574716f1ed55136a79e0 by Gilles Caulier.
Committed on 19/11/2023 at 23:39.
Pushed by cgilles into branch 'master'.

add guards if texture is numm to prevent crash
Related: bug 437658

M  +1    -1    core/dplugins/generic/view/glviewer/CMakeLists.txt
M  +1    -1    core/dplugins/generic/view/glviewer/glviewerglobal.h
M  +2    -2    core/dplugins/generic/view/glviewer/glviewerplugin.cpp
M  +1    -1    core/dplugins/generic/view/glviewer/glviewerplugin.h
M  +1    -1    core/dplugins/generic/view/glviewer/glviewertexture.cpp
M  +1    -1    core/dplugins/generic/view/glviewer/glviewertexture.h
M  +1    -1    core/dplugins/generic/view/glviewer/glviewertimer.cpp
M  +1    -1    core/dplugins/generic/view/glviewer/glviewertimer.h
M  +16   -12   core/dplugins/generic/view/glviewer/glviewerwidget.cpp
M  +1    -1    core/dplugins/generic/view/glviewer/glviewerwidget.h

https://invent.kde.org/graphics/digikam/-/commit/aaf8a75f033e6841d125574716f1ed55136a79e0
Comment 11 caulier.gilles 2023-11-20 08:01:35 UTC
Git commit c74ba8faed0ba1d7b2ebe6fdbbc25071356af7a1 by Gilles Caulier.
Committed on 20/11/2023 at 09:00.
Pushed by cgilles into branch 'master'.

Check if files are selected before to create GL widget instance
Close GL widget if an OpenGL error occurs at init.
Related: bug 437658

M  +31   -5    core/dplugins/generic/view/glviewer/glviewerplugin.cpp
M  +9    -39   core/dplugins/generic/view/glviewer/glviewerwidget.cpp
M  +4    -2    core/dplugins/generic/view/glviewer/glviewerwidget.h

https://invent.kde.org/graphics/digikam/-/commit/c74ba8faed0ba1d7b2ebe6fdbbc25071356af7a1
Comment 12 caulier.gilles 2023-11-20 09:23:26 UTC
Git commit 48f529839a3a02f9fbf5306358be90fcbf1517ff by Gilles Caulier.
Committed on 20/11/2023 at 10:22.
Pushed by cgilles into branch 'master'.

These 2 files are now fixed
Related: bug 437658
FIXED-IN: 8.2.0

M  +7    -2    NEWS

https://invent.kde.org/graphics/digikam/-/commit/48f529839a3a02f9fbf5306358be90fcbf1517ff