Bug 493849 - KPA goes into infinite loop when starting annotation from thumbnail view
Summary: KPA goes into infinite loop when starting annotation from thumbnail view
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: Thumbnail Viewer (show other bugs)
Version: GIT master
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-29 21:16 UTC by Andreas Schleth
Modified: 2024-10-04 11:12 UTC (History)
2 users (show)

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


Attachments
patch for the problem (816 bytes, text/plain)
2024-10-01 08:21 UTC, Andreas Schleth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schleth 2024-09-29 21:16:58 UTC
SUMMARY
With a fresh build from git master (2024/09/29) the demo DB hangs when starting the annotation dialog (in my test with 2 images) with the ever repeated message in the terminal:
"kphotoalbum.Viewer: Video backend QtAV not available. Selecting first available backend..."

My build is (was :-) without the *optional* backend QtAV. From the config:
"
-- The following OPTIONAL packages have not been found:
 * QtAV
 * LIBVLC
"

STEPS TO REPRODUCE
1. build KPA from git without these 2 packages
2. start KPA demo with the freshly built executable
3. start thumbnail viewer
4. select any images
5. hit crtl-2 and ...

OBSERVED RESULT
6. wait forever (see the error message scrolling in the terminal) 

EXPECTED RESULT
I'd like to see the annotation dialog next :-)

SOFTWARE/OS VERSIONS
Operating System: openSUSE Leap 15.6
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Kernel Version: 6.4.0-150600.23.22-default (64-bit)

ADDITIONAL INFORMATION
I am happy to reveal, that this bug disappears when the missing packages are installed.
(This is the first build after upgrading my system.)
Comment 1 Tobias Leupold 2024-09-30 07:49:42 UTC
Thanks for your report! I have to check this, and maybe Johannes has to – but at least, installed or missing QtAV does not cause this, as I don't have QtAV installed (it's not even available on Gentoo, IIRC it's unmaintained and thus has been removed)

I do have vlc installed though, and cmake finds libvlc. So maybe, this happens when no video backend is available at all?
Comment 2 Andreas Schleth 2024-09-30 11:32:43 UTC
Tobias is right: with any one of the two video back ends, the hang does not happen. 

Still, I should have phrased my "EXPECTED RESULT" as: 
I should see either a warning, saying there is no video back end installed, or simply display this error message only if I want to annotate or view a video. As the hang happens when annotating images, the video back end should not matter at all. (And the program should not hang, no matter what :-)
Comment 3 Johannes Zarl-Zierl 2024-09-30 20:59:01 UTC
I didn't have time to look into the bug, but this sounds suspiciously close to a bug that I just fixed in the kf6 branch: https://invent.kde.org/graphics/kphotoalbum/-/commit/7ac8cc0be2c01561c781f85524f59ca79a442d46
Comment 4 Johannes Zarl-Zierl 2024-09-30 21:12:11 UTC
Ok, I was probably off with my previous comment. I've looked at the code now and my guess is that you have the backend set to QtAV from your previous installation, but that's not available in your current setup when the following check is reached:

https://invent.kde.org/graphics/kphotoalbum/-/blob/4f4c4104dfeac1dddcc0c0a4e030e9f535c1b003/Viewer/ViewerWidget.cpp#L1371

-> So the code should not only select a backend if no backend was configured, but also if the backend was configured to an unknown or unavailable value. The most straightforward fix is probably to set unavailable backends to NotConfigured in SettingsData.cpp.
Comment 5 Andreas Schleth 2024-09-30 22:25:35 UTC
Hi Johannes, 
my configured back end is and was always VLC.
If any of the two back ends is configured, the infinite loop goes away. 
Only if none of the two (QtAV/LIBVLC) is included it hangs. I tried all 4 combinations.
To be clear: technically it is not a crash but an infinite loop that endlessly prints the same error message. You have to kill the program manually.
The configure script says "optional" when one or both of the libraries are missing ... and it should be. When someone has no videos they don't need any video back ends.
Right now, it is not a game stopper for me and it will probably only show if someone builds from the sources.
Comment 6 Andreas Schleth 2024-10-01 08:21:56 UTC
Created attachment 174254 [details]
patch for the problem

Attached please find a patch that results in the display of a warning message. After selecting "continue", the settings select Phonon and from then on the annotation works as intended. 
Now, I had to check, what happens if I also remove Phonon-devel ... and Bingo! This is flagged as an error during cmake as it should.

The patch is just a quick-and-dirty solution as I do not know whether it has any unwanted side effects.
Comment 7 Johannes Zarl-Zierl 2024-10-01 20:19:21 UTC
Git commit d37ae8b7daa88e6d9ae54a40cd91b4801ce63df1 by Johannes Zarl-Zierl.
Committed on 01/10/2024 at 20:19.
Pushed by johanneszarl into branch 'master'.

Prevent incorrect config values for video backend

If a video backend was previously configured but is no longer available
in the current build of kphotoalbum, an infinite loop could occur.
This patch fixes that by checking for unsupported values at a
configuration level.

M  +1    -0    CHANGELOG.md
M  +0    -5    CMakeLists.txt
M  +15   -4    MainWindow/FeatureDialog.cpp
M  +4    -3    Settings/VideoPlayerSelectorDialog.cpp
M  +2    -2    Viewer/ViewerWidget.cpp
M  +2    -0    lib/CMakeLists.txt
M  +23   -7    lib/kpabase/SettingsData.cpp
R  +0    -0    lib/kpabase/config-kpa-videobackends.h.in [from: config-kpa-videobackends.h.in - 100% similarity]

https://invent.kde.org/graphics/kphotoalbum/-/commit/d37ae8b7daa88e6d9ae54a40cd91b4801ce63df1
Comment 8 Johannes Zarl-Zierl 2024-10-01 20:19:34 UTC
Hi Andreas,

Thanks for checking all this. The patch confirms my assumptions on what goes wrong.
Can you check if my fix solves the problem as well?

Cheers,
  Johannes
Comment 9 Andreas Schleth 2024-10-02 10:44:20 UTC
Hi Johannes,
I checked and it works :-)
So I am now on v5.12.0-194-g034582ee for the foreseeable future.
Thanks for the quick fix!
Andreas
Comment 10 Johannes Zarl-Zierl 2024-10-04 11:12:43 UTC
Git commit 406a4fc07e69c68dba063f4e7766c295e9ccc007 by Johannes Zarl-Zierl.
Committed on 04/10/2024 at 10:59.
Pushed by johanneszarl into branch 'kf6'.

Prevent incorrect config values for video backend

If a video backend was previously configured but is no longer available
in the current build of kphotoalbum, an infinite loop could occur.
This patch fixes that by checking for unsupported values at a
configuration level.

M  +1    -0    CHANGELOG.md
M  +0    -5    CMakeLists.txt
M  +15   -4    MainWindow/FeatureDialog.cpp
M  +4    -3    Settings/VideoPlayerSelectorDialog.cpp
M  +2    -2    Viewer/ViewerWidget.cpp
M  +2    -0    lib/CMakeLists.txt
M  +22   -7    lib/kpabase/SettingsData.cpp
R  +0    -0    lib/kpabase/config-kpa-videobackends.h.in [from: config-kpa-videobackends.h.in - 100% similarity]

https://invent.kde.org/graphics/kphotoalbum/-/commit/406a4fc07e69c68dba063f4e7766c295e9ccc007