Bug 439723 - While printing special sample file or generating a printer preview for it the UI freezes
Summary: While printing special sample file or generating a printer preview for it the...
Status: ASSIGNED
Alias: None
Product: okular
Classification: Applications
Component: printing (show other bugs)
Version: 21.04.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-10 14:41 UTC by postix
Modified: 2022-01-13 23:07 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Flamegraph for CPU1 (433.91 KB, image/svg+xml)
2021-07-10 14:41 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2021-07-10 14:41:36 UTC
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)
Comment 1 Nicolas Fella 2022-01-12 15:58:57 UTC
> 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?
Comment 2 Albert Astals Cid 2022-01-12 18:39:04 UTC
(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
Comment 3 Bug Janitor Service 2022-01-13 23:03:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/540