Created attachment 139981 [details] Flamegraph for CPU1 STEPS TO REPRODUCE 1. Open https://bugs.kde.org/attachment.cgi?id=139894 in Okular 2. File -> Printer Preview OR 2. File -> Print OBSERVED RESULT Okular uses 100% of one core for several seconds and the UI freezes until the preview is finally generated. I tried to use perf to check what it's going on, please find the flamegraph.svg attached. It seems to run on the same thread as the UI if I am not mistaken? SOFTWARE/OS VERSIONS Operating System: openSUSE Tumbleweed 20210704 KDE Plasma Version: 5.22.2 KDE Frameworks Version: 5.83.0 Qt Version: 5.15.2 Kernel Version: 5.13.0-1-default (64-bit) Source: openSUSE TW repo and source build (master)
> It seems to run on the same thread as the UI if I am not mistaken? yes, that appears to be the case. What might make sense is to change "Document::PrintError print(QPrinter &printer)" to something like "PrintJob print(QPrinter &printer)" where PrintJob is a (KJob derived) class that encapsulates an async print operation. However that touches the generator interface, which as I understand is subject to ABI constraints?
(In reply to Nicolas Fella from comment #1) > However that touches the generator interface, which as I understand is > subject to ABI constraints? We just broke ABI so if you want to break it, now it's the time https://invent.kde.org/graphics/okular/-/commit/a2576dc746767f0ca0bda174c8e2b8d4817d0c2b
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/540