Bug 334708 - Accessing QPrinter to get the page size name is blocking if default printer is not connected
Summary: Accessing QPrinter to get the page size name is blocking if default printer i...
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.19.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: junior-jobs
: 338030 342131 358634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-13 14:21 UTC by Samuel Johnson
Modified: 2016-01-30 15:06 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In: KDE Applications 15.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Johnson 2014-05-13 14:21:32 UTC
When opening certain PDF files, okular freezes for exactly 30 seconds.

Reproducible: Always

Steps to Reproduce:
1. Open this file: http://www.dmhc.ca.gov/testpage.pdf
2. Watch it open the file after 30 seconds

Actual Results:  
Okular takes 30 seconds to open

Expected Results:  
Okular should have opened the file instantaneously.

Here is a snippet of strace. By the way, 172.16.0.40 is our ldap addressbook server.

fcntl(18, F_SETFL, O_RDWR|O_NONBLOCK)   = 0
connect(18, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("172.16.0.40")}, 16) = -1 EINPROGRESS (Operation now in progress)
fcntl(18, F_SETFL, O_RDWR)              = 0
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
poll([{fd=18, events=POLLIN|POLLOUT}], 1, 250) = 0 (Timeout)
close(18)                               = 0
close(-1)                               = -1 EBADF (Bad file descriptor)
open("/etc/printcap", O_RDONLY|O_CLOEXEC) = 18
fcntl(18, F_SETFD, FD_CLOEXEC)          = 0
Comment 1 Albert Astals Cid 2014-05-13 14:28:50 UTC
It's immediate here.

Please run okular under gdb and attach a backtrace of okular when it's "waiting".

What to do 
 gdb okular http://www.dmhc.ca.gov/testpage.pdf
 run
// wait for it to "hang"
 press control+c on the gdb window
 thread apply all bt
// attach the output of the thread apply all bt command
Comment 2 Samuel Johnson 2014-05-13 15:00:05 UTC
Here it is: http://pastebin.com/vtkNLdj9

BTW, it seems to be related to this bug: https://bugs.kde.org/show_bug.cgi?id=329740

Also just found out that okular loads the said file instantaneously if I disconnect from network. I'm using wicd.

(In reply to comment #1)
> It's immediate here.
> 
> Please run okular under gdb and attach a backtrace of okular when it's
> "waiting".
> 
> What to do 
>  gdb okular http://www.dmhc.ca.gov/testpage.pdf
>  run
> // wait for it to "hang"
>  press control+c on the gdb window
>  thread apply all bt
> // attach the output of the thread apply all bt command

(In reply to comment #1)
> It's immediate here.
> 
> Please run okular under gdb and attach a backtrace of okular when it's
> "waiting".
> 
> What to do 
>  gdb okular http://www.dmhc.ca.gov/testpage.pdf
>  run
> // wait for it to "hang"
>  press control+c on the gdb window
>  thread apply all bt
> // attach the output of the thread apply all bt command

(In reply to comment #1)
> It's immediate here.
> 
> Please run okular under gdb and attach a backtrace of okular when it's
> "waiting".
> 
> What to do 
>  gdb okular http://www.dmhc.ca.gov/testpage.pdf
>  run
> // wait for it to "hang"
>  press control+c on the gdb window
>  thread apply all bt
> // attach the output of the thread apply all bt command
Comment 3 Albert Astals Cid 2014-05-13 20:38:11 UTC
Correct, it's the same issue, the other one i will be able to workaround more easily than this one because they have different causes.
Comment 4 Albert Astals Cid 2014-05-13 20:38:44 UTC
Basically we should copy the data of the sizes over to Okular and stop asking QPrinter for it.
Comment 5 Luigi Toscano 2014-05-13 20:44:42 UTC
(In reply to comment #4)
> Basically we should copy the data of the sizes over to Okular and stop
> asking QPrinter for it.

Maybe backport from the new QPageSize class from Qt5, if not too complicated? That would simplify the future Qt5 port:
http://www.layt.net/john/blog/odysseus/help_test_qtprintsupport_changes_in_qt_53_beta_1
Comment 6 Samuel Johnson 2014-05-14 11:51:18 UTC
(In reply to comment #3)
> Correct, it's the same issue, the other one i will be able to workaround
> more easily than this one because they have different causes.

I don't understand why this happens for only a few files. This file (http://www.ncu.edu.tw/~ncu25352/Uploads/20131231103232738561744.pdf) for instance gets loaded immediately.

I however face the 30 seconds delay if I click on [File -> Properties], [File -> Print] and [View -> Presentation] for *all* files.

Is there a way I can completely disable printing on my copy of Okular?. I rarely print.

Thanks for your efforts.
Comment 7 Albert Astals Cid 2014-05-14 18:39:16 UTC
On load it happens for files whose not all pages are the same.

You can try setting all your printers to be non default in the cups configuration, that may help.
Comment 8 Albert Astals Cid 2014-05-14 18:39:34 UTC
> On load it happens for files whose not all pages are the same.
On load it happens for files whose not all pages are the same size.
Comment 9 Samuel Johnson 2014-06-14 04:47:06 UTC
(In reply to comment #8)
> > On load it happens for files whose not all pages are the same.
> On load it happens for files whose not all pages are the same size.

I've temporarily commented 'ServerName' in cups client.conf, now okular loads super fast.

Thanks for your help.
Comment 10 Albert Astals Cid 2014-08-05 14:47:41 UTC
*** Bug 338030 has been marked as a duplicate of this bug. ***
Comment 11 Albert Astals Cid 2014-12-22 23:55:18 UTC
*** Bug 342131 has been marked as a duplicate of this bug. ***
Comment 12 Anssi Hannula 2015-01-01 04:31:12 UTC
# netstat -npA inet | grep okular | grep 631 | wc -l
433

So this might partially explain why cups server timeouts in my case (60secs) - okular is just flooding it with connections.
Comment 13 P. Varet 2015-02-17 00:17:16 UTC
Hi,

I have what appears to be the same problem, or at least a closely related one. On some PDFs, when I scroll to a new page, Okular freezes for well over 30 seconds. That makes it outright unusable. :(

I ran strace on the running process. Turns out Okular freezes while waiting for Avahi to resolve the IP of the currently turned off computer where the printer is plugged in. I assume that despite this slightly different detail, this is the same bug. If not, please let me know, and I'll open a new one.

In the meanwhile, the only workaround I've found is to just use Evince. :/
Comment 14 Albert Astals Cid 2015-07-30 10:46:53 UTC
Git commit dafd8f697285222975a0497ef6cc21e440d1369f by Albert Astals Cid.
Committed on 30/07/2015 at 10:45.
Pushed by aacid into branch 'master'.

Bring QPageSize from Qt5

Allows us to not use a dummy printer for knowing page size
Which is nice since it won't block because Qt4 QPrinter is a bit weird sometimes
FIXED-IN: KDE Applications 15.08

M  +1    -0    CMakeLists.txt
M  +40   -40   core/document.cpp
A  +904  -0    core/qpagesize.cpp     [License: LGPL (v3)]
A  +239  -0    core/qpagesize.h     [License: LGPL (v3)]

http://commits.kde.org/okular/dafd8f697285222975a0497ef6cc21e440d1369f
Comment 15 Albert Astals Cid 2015-07-30 10:47:31 UTC
Git commit 1de97322e75a43a0f04b589f2e7e1a4b50836951 by Albert Astals Cid.
Committed on 30/07/2015 at 10:47.
Pushed by aacid into branch 'Applications/15.08'.

Bring QPageSize from Qt5

Allows us to not use a dummy printer for knowing page size
Which is nice since it won't block because Qt4 QPrinter is a bit weird sometimes
FIXED-IN: KDE Applications 15.08

M  +1    -0    CMakeLists.txt
M  +40   -40   core/document.cpp
A  +904  -0    core/qpagesize.cpp     [License: LGPL (v3)]
A  +239  -0    core/qpagesize.h     [License: LGPL (v3)]

http://commits.kde.org/okular/1de97322e75a43a0f04b589f2e7e1a4b50836951
Comment 16 Albert Astals Cid 2016-01-30 15:06:43 UTC
*** Bug 358634 has been marked as a duplicate of this bug. ***