Created attachment 154918 [details] wrong icons in UI SUMMARY Preamble: I'm using okular to view PDF files which are on a samba network storage. The storage is mounted via CIFS to the local filesystem. I'm discovered that sometimes it will take several seconds (20 or more) to open and view small PDF files. The waiting time increases when I'm connected via VPN (OpenVpn, Wireguard, ..., doesn't matter) and it will take more than a minute to display these files. After that I was looking for some bug reports and found some old ones with okular and CIFS, but they are solved or 9 years without a message. So after some weeks I started testing again. - (Windows 10+11 shows the PDF files nearly instantly.) - Copying the file to the local storage and opening files there is way faster, than opening okular in the mounted storage path. - Evince on this machine also shows the files instantly. -> so the network connection and CIFS are working fine - Then I discovered, that PDF files on the CIFS mount path will open faster when there are no sub-directories. - The other way around: opening files in multiple subdirectores paths will cause long waiting times in okular. - Then I discovered that the same thing is happening when no file is selected at all and okular was simply started on a CIFS mount path: long sub-path -> long starting time for okular -> My thought: okular is looking for files in the current directory, may in the whole path. -> So I used some tools to track the accessed files of an okular program start. The problem: The annotation widget module of okular is looking for icon images in the current working directory when they are not included in the stamp.svg or loaded via the theme. On each start of okular, okular will look for some images with a set list of image extensions in the current working directory, when the icon/image name was not previously cached via an id in some SVG file or was loaded as icon via the theme. e.g. - there is no id 'bookmark-new' in the stamp.svg or the icon theme -> okular will look for 'bookmark-new', 'bookmark-new.3fr', ... [long list] ..., 'bookmark-new.png', ... [...].tiff, ...svg, ... in the current working directory. There are 66 lookups for this filename. This happens on each start - for each okular instance. -> the same goes for --> 'help-about', 'kde', 'okular' (see https://github.com/KDE/okular/blob/master/part/annotationwidgets.cpp#L430) -> if you open the annotation settings there will be lookups for more files. see the list in https://github.com/KDE/okular/blob/master/part/annotationwidgets.cpp#L366 -> These icon file lookups will happen when the class PixmapPreviewSelector will load some icons files. Each time an instance is created and icon names added. -> Massive slow down on 'slow' data storage drives / mount points. -> If there are files with this names, this will break the UI (See attachment). STEPS TO REPRODUCE As it is way simpler to recreate and test a broken UI, as to setup some 'slow, cifs mounted, long sub path PDF files' -> I will go with this, as it is the same bug. But there are more steps. File Lookup: 1. create / download some small png file, and copy+rename it to 'okular.png', 'kde.png', 'help-about.png', 'Note.png', 'NewParagraph.png', 'Paragraph.png', 'Insert.png', 'Help.png', 'Key.png', 'Comment.png' 2. open up a terminal/console, change the directory to the one containing the files from step 1 3. start okular from the terminal/console in this path > this will load access some of the files > you can check this e.g. with 'strace' or use she tool from the answer of this question: > https://unix.stackexchange.com/questions/18844/list-the-files-accessed-by-a-program >> command: tracefile okular | grep -E '\.\/' Broken UI: (see attachment) 4. open a PDF file 5. may enable/show annotation tools 6. open stamp list To recreate the slow okular program start follow this procedure: 1. mount some samba net storage with CIFS > mkdir /smb_cifs_mountpoint > mount -t cifs -o username=<username>,uid=$(id -u),gid=$(id -g) //<smb_host_or_ip>/share "/smb_cifs_mountpoint" 2. create long path: > mkdir -p /smb_cifs_mountpoint/a/b/c/d/e/f/g/h/i 3. change directory: > cd /smb_cifs_mountpoint/a/b/c/d/e/f/g/h/i 4. start okular: > okular OBSERVED RESULT - on CIFS mount: long waiting time to view/open a PDF file - broken UI (wrong icons) when file names exist on current path EXPECTED RESULT - no lookup of any icon image files in current working directory - only look for icon files in okular resource directory or current icon theme SOFTWARE/OS VERSIONS Linux/KDE Plasma: Ubuntu 22.10 (available in About System) KDE Plasma Version: 5.26.4 KDE Frameworks Version: 5.100.0 Qt Version: 5.16.6 ADDITIONAL INFORMATION Not all icons could be overwritten in this way. Mostly the annotation widget/module is affected. maybe the relevant place to look for the bug is: > AnnotationUtils::loadStamp in core/annotations.cpp or > PixmapPreviewSelector::setIcon in part/annotationwidgets.cpp may relevant documentation: > https://doc.qt.io/qt-6/qpixmap.html#load > https://doc.qt.io/qt-6/resources.html > https://doc.qt.io/qt-6/qstandardpaths.html#locate May the loading of some other resources (outside the annotation module) should also be checked? > https://github.com/KDE/okular/blob/master/part/data/CMakeLists.txt I don't know if there is a security problem with manipulated images - as at least 4 image files will always be loaded if present in the working path.
Created attachment 154919 [details] wrong icons in UI (updated image with more comments)
I know that stamps are not yet implemented the way we want them to be. We want them to be saved in the .pdf/.okular file, but we require their image files to be present on the user’s computer. I guess it is not correct to look for these files in the working directory, but only in those places which the user has given when they created a stamp annotation tool. Even if they shall be looked up in the working directory, it should be possible to do it only when needed, and not at startup.
I notice the performance problem on sshfs mount point. If I execute "strace okular filename.pdf" using remote mount point as current work directory I see that okular try to open a bunch of file named "bookmark-new.*", "help-about.", "kde.*". "okular.*" without path (these seems to be the slow part). If I open the same remote file but using as current work directory a local one the open is fast. So the problem seems to be that okular try to open these files without path. I hope this can help to fix the problem.
(In reply to Stefano Rosellini from comment #3) > I notice the performance problem on sshfs mount point. > If I execute "strace okular filename.pdf" using remote mount point as > current work directory I see that okular try to open a bunch of file named > "bookmark-new.*", "help-about.", "kde.*". "okular.*" without path (these > seems to be the slow part). > If I open the same remote file but using as current work directory a local > one the open is fast. > So the problem seems to be that okular try to open these files without path. > I hope this can help to fix the problem. I did some changes here iirc for 23.08 release; which version are you using?
I'm using Debian 12. Okular version is 22.12.3.
We're experiencing it over a CIFS network share. Examining the calls via wireshark we get a lot of failed attempts to open non-existant files - examples include: bookmark-new.bw help-about.ani help-about.avif kde.epsi kde.gif okular.jpg Screenshot of wireshark: https://drive.google.com/file/d/18vEk8G30uHFKy7W5PZJAWmiaSoCHc5q9/view?usp=sharing
(In reply to Bernard Gray from comment #6) > We're experiencing it over a CIFS network share. Examining the calls via > wireshark we get a lot of failed attempts to open non-existant files - Hi What version of okular are you using? /Sune
(In reply to Sune Vuorela from comment #7) > (In reply to Bernard Gray from comment #6) > > We're experiencing it over a CIFS network share. Examining the calls via > > wireshark we get a lot of failed attempts to open non-existant files - > > Hi > What version of okular are you using? > > /Sune Hi Experiencing the exact same issue since a while, i.e. horribly slow to open PDFs on a CIFFS share, fast for local files. Versions: Debian 12 / Okular 22.12.3
https://invent.kde.org/graphics/okular/-/merge_requests/777/diffs (in 23.08) is at least fixing a big part of it. Can anyone try apply that on their local setups and check ?