Speedup room switching by forcing a bigger initial item size

This commit is contained in:
Nicolas Werner 2024-01-08 00:21:42 +01:00
parent 392c07adbe
commit 87c063b112
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
7 changed files with 14 additions and 11 deletions

View file

@ -4,7 +4,6 @@ option(APPVEYOR_BUILD "Build on appveyor" OFF)
option(CI_BUILD "Set when building in CI. Enables -Werror where possible" OFF) option(CI_BUILD "Set when building in CI. Enables -Werror where possible" OFF)
option(ASAN "Compile with address sanitizers" OFF) option(ASAN "Compile with address sanitizers" OFF)
option(QML_DEBUGGING "Enable qml debugging" OFF) option(QML_DEBUGGING "Enable qml debugging" OFF)
option(COMPILE_QML "Compile Qml. It will make Nheko faster, but you will need to recompile it, when you update Qt." OFF)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
option(MAN "Build man page" ON) option(MAN "Build man page" ON)
else() else()
@ -241,7 +240,6 @@ endif()
# Discover Qt dependencies. # Discover Qt dependencies.
# #
find_package(Qt6 6.5 COMPONENTS Core Widgets Gui LinguistTools Svg Multimedia Qml QuickControls2 REQUIRED) find_package(Qt6 6.5 COMPONENTS Core Widgets Gui LinguistTools Svg Multimedia Qml QuickControls2 REQUIRED)
#find_package(Qt6QuickCompiler)
find_package(Qt6DBus) find_package(Qt6DBus)
if(USE_BUNDLED_QTKEYCHAIN) if(USE_BUNDLED_QTKEYCHAIN)
@ -633,11 +631,7 @@ endif()
# #
# Bundle resources # Bundle resources
# #
if(Qt6QuickCompiler_FOUND AND COMPILE_QML)
qtquick_compiler_add_resources(QRC resources/res.qrc)
else()
qt_add_resources(QRC resources/res.qrc) qt_add_resources(QRC resources/res.qrc)
endif()
if(APPLE) if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications")

View file

@ -47,7 +47,7 @@ Item {
anchors.rightMargin: scrollbar.interactive ? scrollbar.width : 0 anchors.rightMargin: scrollbar.interactive ? scrollbar.width : 0
// reuseItems still has a few bugs, see https://bugreports.qt.io/browse/QTBUG-95105 https://bugreports.qt.io/browse/QTBUG-95107 // reuseItems still has a few bugs, see https://bugreports.qt.io/browse/QTBUG-95105 https://bugreports.qt.io/browse/QTBUG-95107
//onModelChanged: if (room) room.sendReset() //onModelChanged: if (room) room.sendReset()
//reuseItems: true reuseItems: true
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
displayMarginBeginning: height / 4 displayMarginBeginning: height / 4
displayMarginEnd: height / 4 displayMarginEnd: height / 4

View file

@ -11,7 +11,9 @@ TimelineEvent {
id: wrapper id: wrapper
ListView.delayRemove: true ListView.delayRemove: true
width: chat.delegateMaxWidth width: chat.delegateMaxWidth
height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight + reactionRow.implicitHeight + unreadRow.height, 10) // We return a larger size for any item but the most bottom one, if it isn't initialized yet, since otherwise Qt will create way too many items.
// If we did that also for the first item, it would mess with the scroll location a bit, so we don't do it for that item.
height: Math.max((section.item?.height ?? 0) + ((gridContainer.implicitHeight < 1 && index != 0) ? 100 : gridContainer.implicitHeight) + reactionRow.implicitHeight + unreadRow.height, 10)
anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter
//room: chatRoot.roommodel //room: chatRoot.roommodel

View file

@ -11,7 +11,9 @@ TimelineEvent {
id: wrapper id: wrapper
ListView.delayRemove: true ListView.delayRemove: true
width: chat.delegateMaxWidth width: chat.delegateMaxWidth
height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight + reactionRow.implicitHeight + unreadRow.height, 10) // We return a larger size for any item but the most bottom one, if it isn't initialized yet, since otherwise Qt will create way too many items.
// If we did that also for the first item, it would mess with the scroll location a bit, so we don't do it for that item.
height: Math.max((section.item?.height ?? 0) + ((gridContainer.implicitHeight < 1 && index != 0) ? 100 : gridContainer.implicitHeight) + reactionRow.implicitHeight + unreadRow.height, 10)
anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter
//room: chatRoot.roommodel //room: chatRoot.roommodel

View file

@ -35,6 +35,7 @@ Item {
// TODO: Show error in overlay or so? // TODO: Show error in overlay or so?
roomm: room roomm: room
// FIXME: This takes 500ms on my device, why and how can we avoid that?
audioOutput: AudioOutput { audioOutput: AudioOutput {
muted: mediaControls.muted muted: mediaControls.muted
volume: mediaControls.desiredVolume volume: mediaControls.desiredVolume

View file

@ -47,7 +47,7 @@
#ifdef QML_DEBUGGING #ifdef QML_DEBUGGING
#include <QQmlDebuggingEnabler> #include <QQmlDebuggingEnabler>
QQmlDebuggingEnabler enabler; QQmlTriviallyDestructibleDebuggingEnabler enabler;
#endif #endif
#if HAVE_BACKTRACE_SYMBOLS_FD #if HAVE_BACKTRACE_SYMBOLS_FD

View file

@ -997,6 +997,8 @@ TimelineModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSp
return; return;
} }
// nhlog::db()->debug("MultiData called for {}", index.row());
// HACK(Nico): fetchMore likes to break with dynamically sized delegates and reuseItems // HACK(Nico): fetchMore likes to break with dynamically sized delegates and reuseItems
if (index.row() + 1 == rowCount() && !m_paginationInProgress) if (index.row() + 1 == rowCount() && !m_paginationInProgress)
const_cast<TimelineModel *>(this)->fetchMore(index); const_cast<TimelineModel *>(this)->fetchMore(index);
@ -1025,6 +1027,8 @@ TimelineModel::multiData(const QString &id,
return; return;
} }
// nhlog::db()->debug("MultiData called for {}", id.toStdString());
auto event = events.get(id.toStdString(), relatedTo.toStdString()); auto event = events.get(id.toStdString(), relatedTo.toStdString());
if (!event) { if (!event) {