Bug 499806

Summary: Gwenview's Start a Slideshow context menu entry causes Dolphin context menu appearance to be delayed in presence of a large number of files
Product: [Applications] gwenview Reporter: Andrea Ippolito <andrea.ippo>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: elvis.angelaccio, kde, meven, rthomsen6
Priority: NOR    
Version First Reported In: 24.12.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: https://bugs.kde.org/show_bug.cgi?id=499551
See Also: https://bugs.kde.org/show_bug.cgi?id=499551
https://bugs.kde.org/show_bug.cgi?id=499595
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on: 499595    
Bug Blocks:    
Attachments: flamegraph when invoking the context menu on a dir containing 30k 4KB files
enable gwenview's context menu entry

Description Andrea Ippolito 2025-02-11 10:45:55 UTC
Create lots of files, size doesn't matter as long as they're a lot, e.g.

#!/bin/bash

mkdir -p /tmp/file-gen
dd if=/dev/urandom of=/tmp/file-gen/file-random-0.bin bs=4K count=1 iflag=fullblock
for i in $(seq 1 30000);
do
    cp /tmp/file-gen/file-random-0.bin /tmp/file-gen/file-random-$i.bin
done

Open Dolphin and make sure the "Start a Slideshow" context menu entry is enabled. If it wasn't, also make sure to close all Dolphin instances (since it appears changing the context menu is only effective on new instances).

Browse to /tmp with Dolphin, then right click the file-gen dir to bring up the context menu

Expected result: context menu appears in a reasonable time
Actual result: context menu takes more than 10 or 20 seconds to appear

Disabling the Start a Slideshow context menu entry causes the context menu to appear instantly.

Useful info: a similar problem is also known for Ark's compress/uncompress actions. So if disabling the slideshow entry (and restarting Dolphin) still doesn't "solve" the problem, make sure to also disable those Ark's context menu entries, too.
With the Ark entries TBH I only noticed slow downs when invoking the context menu on a large file selection.
With the Gwenview entry the slow down happens in that case as well, but crucially ALSO when just invoking the context menu on the parent directory.

Related bugs: https://bugs.kde.org/show_bug.cgi?id=499551, https://bugs.kde.org/show_bug.cgi?id=499595

Operating System: openSUSE Tumbleweed 20250209
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.2
Kernel Version: 6.13.1-1-default (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 30.7 GiB of RAM
Graphics Processor: AMD Radeon 780M
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A7
Comment 1 Andrea Ippolito 2025-02-11 10:49:18 UTC
Created attachment 178138 [details]
flamegraph when invoking the context menu on a dir containing 30k 4KB files
Comment 2 Andrea Ippolito 2025-02-11 10:49:44 UTC
Created attachment 178139 [details]
enable gwenview's context menu entry
Comment 3 David Redondo 2025-02-12 08:37:44 UTC
Gwenview is looking if there's any image file in the list of files. Since there are non this takes a very long time.
Comment 4 Méven 2025-02-12 13:53:23 UTC
(In reply to David Redondo from comment #3)
> Gwenview is looking if there's any image file in the list of files. Since
> there are non this takes a very long time.

There is prior research https://bugs.kde.org/show_bug.cgi?id=499551#c7 btw, and the same issue in ark.
Comment 5 David Redondo 2025-02-12 14:41:24 UTC
Does Dolphin determine the mime types of files when viewing a directory? (or the thumbnailing?). If so, could this be shared?
Comment 6 Méven 2025-02-13 08:36:51 UTC
(In reply to David Redondo from comment #5)
> Does Dolphin determine the mime types of files when viewing a directory? (or
> the thumbnailing?).

I also raised the idea.
https://bugs.kde.org/show_bug.cgi?id=499551#c11
https://invent.kde.org/frameworks/kio/-/merge_requests/1813

> If so, could this be shared?

Anything is possible.
It is done for the selected files already but not for the files within a selected folder.
And they are two cases: the current folder (when you right click on a blank area of the current folder), and a selected folder within the current folder.
The first case we could share the data, the second not so much, since it might not be loaded by dolphin.
So I don't think this optimization is that great and necessary if we have what I suggest in https://invent.kde.org/frameworks/kio/-/merge_requests/1813