Bug 437334 - Okular crashes in CursorWrapHelper::getScreen() when wrapping cursor on wayland
Summary: Okular crashes in CursorWrapHelper::getScreen() when wrapping cursor on wayland
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: drkonqi, wayland
Depends on:
Blocks:
 
Reported: 2021-05-19 00:56 UTC by Aleix Pol
Modified: 2021-07-03 02:00 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.08
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleix Pol 2021-05-19 00:56:04 UTC
Application: okular (21.07.70)
 (Compiled from sources)
Qt Version: 5.15.1
Frameworks Version: 5.83.0
Operating System: Linux 5.12.4-arch1-2 x86_64
Windowing System: Wayland
Drkonqi Version: 5.22.80
Distribution: Arch Linux

-- Information about the crash:
- What I was doing when the application crashed:
Okular crashes as soon as the cursor leaves the window as on Wayland we don't have a global cursor position.

We won't be able to move the cursor either so the infinite scrolling can happen but not to visibly move the cursor.

The crash can be reproduced every time.

-- Backtrace:
Application: Okular (okular), signal: Aborted
Content of s_kcrashErrorMessage: [Current thread is 1 (Thread 0x7f783f287100 (LWP 10536))]
[KCrash Handler]
#5  0x00007f78428f1d22 in raise () from /usr/lib/libc.so.6
#6  0x00007f78428db862 in abort () from /usr/lib/libc.so.6
#7  0x00007f7842eb4c51 in qt_message_fatal (message=<synthetic pointer>..., context=...) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/global/qlogging.cpp:1914
#8  QMessageLogger::fatal (this=this@entry=0x7ffc94456cf8, msg=msg@entry=0x7f78431b2ec8 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/global/qlogging.cpp:893
#9  0x00007f7842eb40a6 in qt_assert_x (where=<optimized out>, what=<optimized out>, file=<optimized out>, line=<optimized out>) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/global/qglobal.cpp:3366
#10 0x00007f783c1ef3d2 in CursorWrapHelper::getScreen () at /home/apol/devel/frameworks/okular/part/cursorwraphelper.cpp:101
#11 0x00007f783c1eeb74 in CursorWrapHelper::wrapCursor (eventPosition=..., edges=...) at /home/apol/devel/frameworks/okular/part/cursorwraphelper.cpp:23
#12 0x00007f783c258b1b in PageView::mouseMoveEvent (this=0x560fa78e2670, e=0x7ffc94457840) at /home/apol/devel/frameworks/okular/part/pageview.cpp:2220
#13 0x00007f7843ca002e in QWidget::event (this=this@entry=0x560fa78e2670, event=event@entry=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qwidget.cpp:9020
#14 0x00007f7843d4846e in QFrame::event (this=0x560fa78e2670, e=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/widgets/qframe.cpp:550
#15 0x00007f783c261d9e in PageView::viewportEvent (this=0x560fa78e2670, e=0x7ffc94457840) at /home/apol/devel/frameworks/okular/part/pageview.cpp:3245
#16 0x00007f78430d1b63 in QCoreApplicationPrivate::sendThroughObjectEventFilters (event=<optimized out>, receiver=<optimized out>) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1190
#17 QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x560fa78c92e0, event=event@entry=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1179
#18 0x00007f7843c6016e in QApplicationPrivate::notify_helper (this=this@entry=0x560fa749f2e0, receiver=receiver@entry=0x560fa78c92e0, e=e@entry=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3626
#19 0x00007f7843c6706b in QApplication::notify (this=0x7ffc94457540, receiver=0x560fa78c92e0, e=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3076
#20 0x00007f78430d1dfa in QCoreApplication::notifyInternal2 (receiver=0x560fa78c92e0, event=0x7ffc94457840) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1064
#21 0x00007f7843c66096 in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x560fa78c92e0, event=event@entry=0x7ffc94457840, alienWidget=0x0, alienWidget@entry=0x560fa75690b0, nativeWidget=0x560fa75690b0, buttonDown=buttonDown@entry=0x7f78441879f0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2614
#22 0x00007f7843cb8071 in QWidgetWindow::handleMouseEvent (this=0x560fa7989f10, event=0x7ffc94457b00) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qwidgetwindow.cpp:683
#23 0x00007f7843cbb39e in QWidgetWindow::event (this=0x560fa7989f10, event=0x7ffc94457b00) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qwidgetwindow.cpp:300
#24 0x00007f7843c6017f in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x560fa7989f10, e=0x7ffc94457b00) at /home/apol/devel/frameworks/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3632
#25 0x00007f78430d1dfa in QCoreApplication::notifyInternal2 (receiver=0x560fa7989f10, event=0x7ffc94457b00) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1064
#26 0x00007f7843571593 in QGuiApplicationPrivate::processMouseEvent (e=0x7f7720019bf0) at /home/apol/devel/frameworks/qt5/qtbase/src/gui/kernel/qguiapplication.cpp:2282
#27 0x00007f784354753c in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at /home/apol/devel/frameworks/qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:1169
#28 0x00007f783fa7ba40 in userEventSourceDispatch (source=<optimized out>) at /home/apol/devel/frameworks/qt5/qtbase/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp:74
#29 0x00007f783fc1602c in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#30 0x00007f783fc69b59 in ?? () from /usr/lib/libglib-2.0.so.0
#31 0x00007f783fc13781 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#32 0x00007f78431291df in QEventDispatcherGlib::processEvents (this=0x560fa753f670, flags=...) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:423
#33 0x00007f78430d07ab in QEventLoop::exec (this=this@entry=0x7ffc94457e30, flags=..., flags@entry=...) at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/global/qflags.h:69
#34 0x00007f78430d8a30 in QCoreApplication::exec () at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/global/qflags.h:121
#35 0x0000560fa5d87822 in main (argc=2, argv=0x7ffc94458278) at /home/apol/devel/frameworks/okular/shell/main.cpp:107
[Inferior 1 (process 10536) detached]

Possible duplicates by query: bug 424911, bug 423132, bug 417285, bug 414922, bug 409419.

Reported using DrKonqi
Comment 1 Albert Astals Cid 2021-05-19 20:39:02 UTC
David can you have a look at this?
Comment 2 Laura David Hurka 2021-05-20 11:38:04 UTC
> Okular crashes as soon as the cursor leaves the window
> as on Wayland we don't have a global cursor position.
I don’t know how Wayland works (except that it doesn’t work on my computers). Can you tell me more how cursor positions work, or where I can read about it?

> We won't be able to move the cursor either so the infinite
> scrolling can happen but not to visibly move the cursor.
Provided that the cursor has a position, not being able to move it shouldn’t be a problem.
Comment 3 Aleix Pol 2021-05-20 14:43:28 UTC
Here is some information. https://wayland-book.com/

In general terms, you need to understand that in Wayland you cannot move the cursor. So in general this part should be just skipped on wayland.

The crash itself happens because it's unable to figure out the geometry of the current display. This is something that won't just fly here and should be avoided.

You might want to add a KWindowSystem::isPlatformWayland() that just does the scrolling without moving the cursor.
Comment 4 Laura David Hurka 2021-05-21 20:49:20 UTC
Thanks for the link. I will probably read more of it later. :)

Scrolling without moving the cursor would be my preferred alternative, just like Blender does it. We were already trying to do that in https://invent.kde.org/graphics/okular/-/merge_requests/134, but that method depends on calling QCursor::setPos() unconditionally, and still flickers a bit. I can’t follow you how KWindowSystem::isPlatformWayland() is related.
Comment 5 Albert Astals Cid 2021-07-02 23:14:53 UTC
Git commit b805603c58e64d63c4374ffb698aa513d73aa086 by Albert Astals Cid, on behalf of David Hurka.
Committed on 02/07/2021 at 21:36.
Pushed by aacid into branch 'master'.

CursorWrapHelper: Do not crash on Wayland.

According to https://bugs.kde.org/show_bug.cgi?id=437334
the cursor position is not necessarily known on Wayland.
That would trigger the Q_ASSERT_X, so this patch removes
it. This does not solve the problem that we can not wrap
the cursor, but it prevents crashing Okular if using the
debug build on Wayland. You’re reading rectangular text.
Related: bug 439471

M  +0    -1    part/cursorwraphelper.cpp

https://invent.kde.org/graphics/okular/commit/b805603c58e64d63c4374ffb698aa513d73aa086