mirage
mirage copied to clipboard
Scrolling Really Fast with enableKineticScrolling=false on room list crashes
Description
If I whip the scroll wheel on the room list to make it scroll really fast, it crashes it 100% of the time for me.
Your environment
- OS or distribution (e.g. Arch Linux, macOS 10.15, Windows 7...) Arch Linux
- Architecture (e.g. x86 64bit) 64bit
- How did you install Mirage?
yay -S matrix-mirage
Steps to reproduce
- Log into an account with a long room list
- Scroll down the room list really fast with the mouse (I used a Logitech M500)
Expected behavior
Scroll through the list really fast, stop at the bottom.
Actual behavior
Segmentation fault (core dumped)
(let me know if there's a way I can get a more detailed error)
- Does this happen with
enableKineticScrolling
set tofalse
in the config file? - Can you try this basic program (run with
qml Window.qml
) to see if the crash occurs?
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
width: 640
height: 480
visible: true
title: "Test"
ListView {
anchors.fill: parent
model: ListModel {}
delegate: Text {
text: model.text
font.pixelSize: 24
}
Component.onCompleted: {
for (let i = 0; i < 5000; i++)
model.append({text: "Item " + i})
}
}
}
Oh, I've had enableKineticScrolling
set to false. If I set it back to true, it no longer crashes. I had originally switched away from kinetic scrolling because I found small scrolls to be a little too aggressive in my experience (a few consecutive clicks of the scroll wheel just feels like it scrolls too far...). I can try out the qml program and report back.
I just loaded up that qml program, and scrolled through the list of items as fast as I possibly could with my mouse. I was not able to get it to crash.
The previous code used kinetic scrolling, here's a new one with the workaround to disable it:
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
width: 640
height: 480
visible: true
title: "Test"
ListView {
anchors.fill: parent
model: ListModel {}
delegate: Text {
text: model.text
font.pixelSize: 24
}
Component.onCompleted: {
for (let i = 0; i < 5000; i++)
model.append({text: "Item " + i})
}
MouseArea {
id: mouseArea
anchors.fill: parent
enabled: true
propagateComposedEvents: true
acceptedButtons: Qt.NoButton
onWheel: {
// Make components below the stack notice the wheel event
wheel.accepted = false
const pos = getNewPosition(flickable, wheel)
flickable.flick(0, 0)
flickable.contentY = pos
}
property Flickable flickable: parent
// Used to get default flickDeceleration value
readonly property Flickable dummy: Flickable {}
function getNewPosition(flickable, wheel) {
// wheel.pixelDelta will be available on high resolution trackpads.
// Otherwise use wheel.angleDelta, which is available from mouses and
// low resolution trackpads.
// When higher pixelDelta, more scroll will be applied
const pixelDelta =
wheel.pixelDelta.y ||
wheel.angleDelta.y / 8 * Qt.styleHints.wheelScrollLines
// Return current position if there was not any movement
if (flickable.contentHeight < flickable.height || !pixelDelta)
return flickable.contentY
const maxScroll =
flickable.contentHeight +
flickable.originY +
flickable.bottomMargin -
flickable.height
const minScroll = flickable.topMargin + flickable.originY
// Avoid overscrolling
return Math.max(
minScroll,
Math.min(maxScroll, flickable.contentY - pixelDelta)
)
}
Binding {
target: mouseArea.flickable
property: "maximumFlickVelocity"
value: mouseArea.enabled ? 0 : 4000
}
Binding {
target: mouseArea.flickable
property: "flickDeceleration"
value: mouseArea.enabled ? 0 : dummy.flickDeceleration
}
}
}
}
If this doesn't crash, try changing the i < 5000
on line 20 to a shorter number like 100.
I had originally switched away from kinetic scrolling because I found small scrolls to be a little too aggressive in my experience (a few consecutive clicks of the scroll wheel just feels like it scrolls too far...)
I noticed that the current kinetic scrolling does not work well for touchpads under libinput (Linux) (ie: the feature is completely unuseable). So, it's strange to see kinetic scrolling enabled by default.
In addition to what was said in #22: the way we disable kinetic scrolling is a hack since Qt doesn't offer (yet, hopefully) any solution out of the box, and is unlikely to be perfect and stable as evidenced by this issue.
I was not able to cause the qml file with the workaround to crash. I tried with 5000, as well as 100. I also tried having my scroll wheel spinning while loading it to see if I could force a crash and it scrolled through the list as expected.
As a possible workaround until this gets fixed, how does kinetic scrolling with a lower maximum velocity feel? You can test with this program, by playing with maximumFlickVelocity
's value (it's set to 4000 in Mirage):
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
width: 640
height: 480
visible: true
title: "Test"
ListView {
anchors.fill: parent
maximumFlickVelocity: 1000
model: ListModel {}
delegate: Text {
text: model.text
font.pixelSize: 24
}
Component.onCompleted: {
for (let i = 0; i < 5000; i++)
model.append({text: "Item " + i})
}
}
}
Oh wow, 1000 is noticably better (at least for my setup). It speeds up at a good rate and stops right away even on just a few scroll wheel clicks. When I changed to 4000, I noticed the over-aggressive scrolling again. Maybe this could be a variable for the user to control? I'm not sure if 4000 is acting like this for anyone else or if it's just something with my mouse maybe.
A kineticScrollingMaxSpeed
setting has been added, see https://github.com/mirukana/mirage/issues/65
I have encountered this issue as well; feels like whenever I forget about it and scroll too fast, Mirage crashes (segfault). It's more likely to happen if the room list is still loading up. Sometimes (not sure if related) Mirage crashes while room list is loading even if I don't scroll at all. I'll look more into it now when I know I'm not the only one.
I got a backtrace for this error:
Thread 1 "mirage" received signal SIGSEGV, Segmentation fault.
0x00007ffff6cfcf66 in QWindow::mapToGlobal(QPoint const&) const () from /usr/lib/libQt5Gui.so.5
(gdb) bt
#0 0x00007ffff6cfcf66 in QWindow::mapToGlobal(QPoint const&) const () from /usr/lib/libQt5Gui.so.5
#1 0x00007ffff7b20d09 in QQuickWindowPrivate::deliverSinglePointEventUntilAccepted(QQuickPointerEvent*) () from /usr/lib/libQt5Quick.so.5
#2 0x00007ffff7b21634 in QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent*) () from /usr/lib/libQt5Quick.so.5
#3 0x00007ffff7b21890 in QQuickWindow::wheelEvent(QWheelEvent*) () from /usr/lib/libQt5Quick.so.5
#4 0x00007ffff6d0428d in QWindow::event(QEvent*) () from /usr/lib/libQt5Gui.so.5
#5 0x00007ffff73751a6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#6 0x00007ffff62c189a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#7 0x00007ffff6cf5839 in QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent*) () from /usr/lib/libQt5Gui.so.5
#8 0x00007ffff6ce05e5 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5
#9 0x00007ffff2442d70 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#10 0x00007ffff4b1b52c in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#11 0x00007ffff4b6f7b9 in ?? () from /usr/lib/libglib-2.0.so.0
#12 0x00007ffff4b18c11 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#13 0x00007ffff630ca8a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#14 0x00007ffff62b9a9b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#15 0x00007ffff62c52c7 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#16 0x000055555555b659 in main ()
I think I have suffered the same issue however, in my case, it triggers when I highlight a message (ctrl+q) and go up the message list in a room (ctrl+k) a bunch and then switch to another room (alt+shift+k/j); it sometimes crashes. I usually have to smash my keys to make it crash so I don't know how accurate this all is.
Just now, after having gone up in the message history a lot, I took a 30 second pause and then tried to switch to a new room and it crashed as well.