Bug 342131

Summary: Frozen UI due to dummy QPrinter constructed (causing HTTP timeouts) when scrolling PDF
Product: [Applications] okular Reporter: Anssi Hannula <anssi.hannula>
Component: generalAssignee: Okular developers <okular-devel>
Status: RESOLVED DUPLICATE    
Severity: crash CC: aacid
Priority: NOR    
Version: 0.20.3   
Target Milestone: ---   
Platform: Mageia RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Anssi Hannula 2014-12-22 17:43:06 UTC
Sometimes okular freezes for me when scrolling. Looks like the reason is that notifyCurrentPageChanged() triggers namePaperSize() call which constructs a "dummy" QPrinter, and the QPrinter constructor triggers cups calls which cause HTTP requests, which for some reason sometimes timeout.

(gdb) bt
#0  0x00007f7a1404ba4d in poll () at /lib64/libc.so.6
#1  0x00007f79ff5ea827 in _httpWait (__timeout=60000, __nfds=1, __fds=0x7fffa5bf0ba0) at /usr/include/bits/poll2.h:46
#2  0x00007f79ff5ea827 in _httpWait (http=<optimized out>, msec=60000, usessl=<optimized out>) at http.c:3188
#3  0x00007f79ff5eab54 in httpGets (line=line@entry=0x7fffa5bf0c40 "i", length=length@entry=32768, http=http@entry=0x147b160) at http.c:1205
#4  0x00007f79ff5eb10b in _httpUpdate (http=http@entry=0x147b160, status=status@entry=0x7fffa5bf8c84) at http.c:2923
#5  0x00007f79ff5eb42b in httpUpdate (http=http@entry=0x147b160) at http.c:3112
#6  0x00007f79ff60c1d8 in cupsGetResponse (http=http@entry=0x147b160, resource=resource@entry=0x7fffa5c02a40 "/printers/Photosmart_Plus_B209a-m") at request.c:388
#7  0x00007f79ff60d0a9 in cupsDoIORequest (http=0x147b160, request=0x1edf340, resource=0x7fffa5c02a40 "/printers/Photosmart_Plus_B209a-m", infile=-1, outfile=-1) at request.c:250
#8  0x00007f79ff614f8e in cups_get_printer_uri (http=0x7fffa5bf0ba0, name=0x7fffa5c02eca "Photosmart_Plus_B209a-m", host=0x7fffa5c02240 "10.0.0.1", port=0x7fffa5c01ca0, resource=0x7fffa5c02a40 "/printers/Photosmart_Plus_B209a-m", depth=0, resourcesize=<optimized out>, hostsize=<optimized out>) at util.c:1520
#9  0x00007f79ff61628f in cupsGetPPD3 (http=0x147b160, name=0x7fffa5c02eca "Photosmart_Plus_B209a-m", modtime=0x7fffa5c02e90, buffer=0x128bb88 "", bufsize=1024) at util.c:946
#10 0x00007f79ff616910 in cupsGetPPD2 (http=0x147b160, name=0x7fffa5c02eca "Photosmart_Plus_B209a-m") at util.c:749
#11 0x00007f7a1562f053 in QCUPSSupport::setCurrentPrinter(int) (this=0x7fffa5c03330, index=21475680) at painting/qcups.cpp:282
#12 0x00007f7a156302bb in QCUPSSupport::QCUPSSupport() (this=0x7fffa5c03330) at painting/qcups.cpp:224
#13 0x00007f7a155a2600 in QPrinter::init(QPrinter::PrinterMode) (this=this@entry=0x7fffa5c03490, mode=mode@entry=QPrinter::ScreenResolution) at painting/qprinter.cpp:688
#14 0x00007f7a155a37d2 in QPrinter::QPrinter(QPrinter::PrinterMode) (this=0x7fffa5c03490, mode=QPrinter::ScreenResolution) at painting/qprinter.cpp:603
#15 0x00007f7a04dda78e in Okular::DocumentPrivate::namePaperSize(double, double) const (this=this@entry=0xdc1ba0, inchesWidth=8.2669444444444444, 
    inchesWidth@entry=11.694444444444445, inchesHeight=11.694444444444445, inchesHeight@entry=8.2669444444444444) at /usr/src/debug/okular-4.14.3/core/document.cpp:174
#16 0x00007f7a04ddb02c in Okular::DocumentPrivate::localizedSize(QSizeF const&) const (this=0xdc1ba0, size=...) at /usr/src/debug/okular-4.14.3/core/document.cpp:288
#17 0x00007f7a04ddb409 in Okular::Document::pageSizeString(int) const (this=0xca0520, page=page@entry=7) at /usr/src/debug/okular-4.14.3/core/document.cpp:2828
#18 0x00007f7a050f385f in PageSizeLabel::notifyCurrentPageChanged(int, int) (this=0xecacf0, previousPage=<optimized out>, currentPage=7) at /usr/src/debug/okular-4.14.3/ui/pagesizelabel.cpp:32
#19 0x00007f7a04ddb767 in Okular::Document::setViewport(Okular::DocumentViewport const&, Okular::DocumentObserver*, bool) (this=0xca0520, viewport=..., excludeObserver=0xeb6cd8, smoothMove=false)
    at /usr/src/debug/okular-4.14.3/core/document.cpp:3227
#20 0x00007f7a05108d76 in PageView::slotRequestVisiblePixmaps(int) (this=0x7fffa5bf0ba0, this@entry=0xeb6cb0, newValue=1, newValue@entry=8103) at /usr/src/debug/okular-4.14.3/ui/pageview.cpp:4485
#21 0x00007f7a051098f2 in PageView::slotRequestVisiblePixmaps(int) (this=0xeb6cb0, newValue=8103) at /usr/src/debug/okular-4.14.3/ui/pageview.cpp:4315
#22 0x00007f7a14a2888a in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0xeb7d70, m=m@entry=0x7f7a15ef6d00 <QAbstractSlider::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffa5c03960) at kernel/qobject.cpp:3567
#23 0x00007f7a15a7050e in QAbstractSlider::valueChanged(int) (this=this@entry=0xeb7d70, _t1=8103) at .moc/release-shared/moc_qabstractslider.cpp:195
#24 0x00007f7a157d5aa5 in QAbstractSlider::setValue(int) (this=this@entry=0xeb7d70, value=<optimized out>) at widgets/qabstractslider.cpp:543
#25 0x00007f7a157d5cfd in QAbstractSlider::triggerAction(QAbstractSlider::SliderAction) (this=this@entry=0xeb7d70, action=action@entry=QAbstractSlider::SliderMove) at widgets/qabstractslider.cpp:632
#26 0x00007f7a157d5eca in QAbstractSlider::setSliderPosition(int) (this=this@entry=0xeb7d70, position=<optimized out>, position@entry=8103) at widgets/qabstractslider.cpp:500
#27 0x00007f7a1585ecce in QScrollBar::mouseMoveEvent(QMouseEvent*) (this=0xeb7d70, e=0x7fffa5c03ed0) at widgets/qscrollbar.cpp:675
#28 0x00007f7a1546e4b8 in QWidget::event(QEvent*) (this=0x7fffa5bf0ba0, this@entry=0xeb7d70, event=0x1, event@entry=0x7fffa5c03ed0) at kernel/qwidget.cpp:8775
#29 0x00007f7a157d64e5 in QAbstractSlider::event(QEvent*) (this=this@entry=0xeb7d70, e=e@entry=0x7fffa5c03ed0) at widgets/qabstractslider.cpp:952
#30 0x00007f7a1585f599 in QScrollBar::event(QEvent*) (this=0xeb7d70, event=0x7fffa5c03ed0) at widgets/qscrollbar.cpp:547
#31 0x00007f7a1541e8cc in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0xbb9b90, receiver=receiver@entry=0xeb7d70, e=e@entry=0x7fffa5c03ed0) at kernel/qapplication.cpp:4565
#32 0x00007f7a154250be in QApplication::notify(QObject*, QEvent*) (this=this@entry=0x7fffa5c04690, receiver=receiver@entry=0xeb7d70, e=e@entry=0x7fffa5c03ed0) at kernel/qapplication.cpp:4108
#33 0x00007f7a1614e1ba in KApplication::notify(QObject*, QEvent*) (this=0x7fffa5c04690, receiver=0xeb7d70, event=0x7fffa5c03ed0) at /usr/src/debug/kdelibs-4.14.3/kdeui/kernel/kapplication.cpp:311
#34 0x00007f7a14a14cad in QCoreApplication::notifyInternal(QObject*, QEvent*) (this=0x7fffa5c04690, receiver=receiver@entry=0xeb7d70, event=event@entry=0x7fffa5c03ed0) at kernel/qcoreapplication.cpp:953
#35 0x00007f7a1542479f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) (event=<optimized out>, receiver=<optimized out>)
    at ../../src/corelib/kernel/qcoreapplication.h:231
#36 0x00007f7a1542479f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) (receiver=receiver@entry=0xeb7d70, event=event@entry=0x7fffa5c03ed0, alienWidget=alienWidget@entry=0xeb7ed0, nativeWidget=nativeWidget@entry=0xcb4010, buttonDown=buttonDown@entry=0x7f7a15f084b8 <qt_button_down>, lastMouseReceiver=..., spontaneous=true)
    at kernel/qapplication.cpp:3173
#37 0x00007f7a154969e2 in QETWidget::translateMouseEvent(_XEvent const*) (this=this@entry=0xcb4010, event=event@entry=0x7fffa5c04230) at kernel/qapplication_x11.cpp:4540
#38 0x00007f7a154953dc in QApplication::x11ProcessEvent(_XEvent*) (this=0x7fffa5c04690, event=event@entry=0x7fffa5c04230) at kernel/qapplication_x11.cpp:3663
#39 0x00007f7a154bc562 in x11EventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0xbab4a0, callback=0x0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#40 0x00007f7a10e44c6d in g_main_context_dispatch (context=0xbb9f30) at gmain.c:3111
#41 0x00007f7a10e44c6d in g_main_context_dispatch (context=context@entry=0xbb9f30) at gmain.c:3710
#42 0x00007f7a10e44f18 in g_main_context_iterate (context=context@entry=0xbb9f30, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
#43 0x00007f7a10e44fbc in g_main_context_iteration (context=0xbb9f30, may_block=1) at gmain.c:3842
#44 0x00007f7a14a41dc7 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0xb72b50, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#45 0x00007f7a154bc616 in QGuiEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#46 0x00007f7a14a13931 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffa5c04600, flags=...) at kernel/qeventloop.cpp:149
#47 0x00007f7a14a13c45 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffa5c04600, flags=...) at kernel/qeventloop.cpp:204
#48 0x00007f7a14a18e59 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1225
#49 0x00007f7a1541cedc in QApplication::exec() () at kernel/qapplication.cpp:3823
#50 0x0000000000409668 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/okular-4.14.3/shell/main.cpp:64


Reproducible: Sometimes

Steps to Reproduce:
1. Have a remote CUPS server (ServerName x.y.z.u in /etc/cups/client.conf).
2. Open a PDF file and scroll it around (I've found some PDF files seem to trigger better than others - e.g. http://ec.europa.eu/taxation_customs/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf is one that triggers this).

Possibly some other configuration/network issue is needed as well - however, everything (including printing) seems to work for me, so not sure why the HTTP connection timeouts sometimes.

Actual Results:  
The UI froze.

Expected Results:  
The UI should not have frozen.

Qt 4.8.6, cups 2.0.1, remote cups server.
Comment 1 Albert Astals Cid 2014-12-22 23:55:18 UTC

*** This bug has been marked as a duplicate of bug 334708 ***
Comment 2 Anssi Hannula 2014-12-23 00:07:58 UTC
Weird, I did search for "QPrinter" in the "search for duplicate bugs" screen when submitting this bug report, but #334708 didn't show up (and still doesn't) despite having "QPrinter" in the title.