Bug 446984

Summary: Long document open times when the brush preset docker is filtering by a tag
Product: [Applications] krita Reporter: amyspark <amy>
Component: Resource ManagementAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: acc4commissions, ek.artifist, halla, lalakf11
Priority: NOR    
Version: 5.0.0-beta5   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description amyspark 2021-12-14 15:35:13 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
I'm experiencing a very big slowdown when any of the resource choosers is filtering by a tag. This is noticeable on two occasions: when creating or opening a new document; and also when changing from a tag to "All" (therefore disabling filtering).

STEPS TO REPRODUCE
1. Leave the brush docker filtered by a tag, e.g. "Quiralta".
2. Reopen Krita.
3. Create a new document.

OBSERVED RESULT
Creating a new document takes 5x more time if the brush docker has a tag selected.

EXPECTED RESULT
Creating a new document is as fast whether the brush docker is filtering the resources or not.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Halla Rempt 2021-12-14 15:44:48 UTC
Huh, we've been looking into this today, but only really saw it in tag translation merge request. In any case, the caching I've put in there should fix this issue, too, so please test my branch? https://invent.kde.org/graphics/krita/-/merge_requests/1227
Comment 2 amyspark 2021-12-14 18:56:18 UTC
No, sadly it does not. Random pausing Krita while it's hung shows that it's doing a full query just for sorting the resources?

ntdll.dll!RtlFreeHeap() (Origen desconocido:0)
ucrtbase.dll!_free_base() (Origen desconocido:0)
qsqlite.dll!00007ffd366bc214() (Origen desconocido:0)
qsqlite.dll!00007ffd366cf66a() (Origen desconocido:0)
qsqlite.dll!00007ffd366cdce6() (Origen desconocido:0)
qsqlite.dll!00007ffd366cd60b() (Origen desconocido:0)
qsqlite.dll!00007ffd366cceee() (Origen desconocido:0)
qsqlite.dll!00007ffd366af2c4() (Origen desconocido:0)
qsqlite.dll!00007ffd36692db5() (Origen desconocido:0)
qsqlite.dll!00007ffd366d8bd6() (Origen desconocido:0)
qsqlite.dll!00007ffd36688a6d() (Origen desconocido:0)
qsqlite.dll!00007ffd36690c17() (Origen desconocido:0)
qsqlite.dll!00007ffd3668da19() (Origen desconocido:0)
qsqlite.dll!00007ffd36684e55() (Origen desconocido:0)
qsqlite.dll!00007ffd3668deea() (Origen desconocido:0)
qsqlite.dll!00007ffd366bce9e() (Origen desconocido:0)
qsqlite.dll!00007ffd365b59b9() (Origen desconocido:0)
Qt5Sql.dll!00007ffd7f7b2e2f() (Origen desconocido:0)
kritaresources.dll!KisResourceQueryMapper::variantFromResourceQueryById(int resourceId, int column, int role) Line 177 (e:\krita-win\src\libs\resources\KisResourceQueryMapper.cpp:177)
kritaresources.dll!KisAllTagResourceModel::data(const QModelIndex & index, int role) Line 93 (e:\krita-win\src\libs\resources\KisTagResourceModel.cpp:93)
Qt5Core.dll!00007ffd3d544f70() (Origen desconocido:0)
kritaresources.dll!KisResourceModel::lessThan(const QModelIndex & source_left, const QModelIndex & source_right) Line 958 (e:\krita-win\src\libs\resources\KisResourceModel.cpp:958)
Qt5Core.dll!00007ffd3d541df9() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d53fdda() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d541253() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d54b6d3() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d544d00() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d54ced5() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5421ca() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d54aea2() (Origen desconocido:0)
kritaresources.dll!KisTagFilterResourceProxyModel::updateTagFilter() Line 269 (e:\krita-win\src\libs\resources\KisTagFilterResourceProxyModel.cpp:269)
kritaresources.dll!KisTagFilterResourceProxyModel::setTagFilter(const QSharedPointer<KisTag> tag) Line 199 (e:\krita-win\src\libs\resources\KisTagFilterResourceProxyModel.cpp:199)
[Inline Frame] kritaresourcewidgets.dll!KisResourceTaggingManager::tagChooserIndexChanged(const QSharedPointer<KisTag>) Line 98 (e:\krita-win\src\libs\resourcewidgets\KisResourceTaggingManager.cpp:98)
kritaresourcewidgets.dll!KisResourceTaggingManager::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 84 (e:\krita-win\b_msvc\libs\resourcewidgets\kritaresourcewidgets_autogen\include_RelWithDebInfo\EWIEGA46WW\moc_KisResourceTaggingManager.cpp:84)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
[Inline Frame] kritaresourcewidgets.dll!KisTagChooserWidget::sigTagChosen(const QSharedPointer<KisTag>) Line 182 (e:\krita-win\b_msvc\libs\resourcewidgets\kritaresourcewidgets_autogen\include_RelWithDebInfo\EWIEGA46WW\moc_KisTagChooserWidget.cpp:182)
kritaresourcewidgets.dll!KisTagChooserWidget::tagChanged(int tagIndex) Line 124 (e:\krita-win\src\libs\resourcewidgets\KisTagChooserWidget.cpp:124)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb5e111() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb65379() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb651e2() (Origen desconocido:0)
[Inline Frame] kritaresourcewidgets.dll!KisTagChooserWidget::setCurrentIndex(int) Line 189 (e:\krita-win\src\libs\resourcewidgets\KisTagChooserWidget.cpp:189)
kritaresourcewidgets.dll!KisTagChooserWidget::tagChanged(int tagIndex) Line 128 (e:\krita-win\src\libs\resourcewidgets\KisTagChooserWidget.cpp:128)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb5e111() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb5c47b() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d524a70() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d53d7ff() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d524a70() (Origen desconocido:0)
[Inline Frame] kritaresources.dll!KisAllTagsModel::addStorage(const QString &) Line 565 (e:\krita-win\src\libs\resources\KisTagModel.cpp:565)
kritaresources.dll!KisAllTagsModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 81 (e:\krita-win\b_msvc\libs\resources\kritaresources_autogen\include_RelWithDebInfo\EWIEGA46WW\moc_KisTagModel.cpp:81)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
[Inline Frame] kritaresources.dll!KisResourceLocator::storageAdded(const QString &) Line 211 (e:\krita-win\b_msvc\libs\resources\kritaresources_autogen\include_RelWithDebInfo\EWIEGA46WW\moc_KisResourceLocator.cpp:211)
kritaresources.dll!KisResourceLocator::addStorage(const QString & storageLocation, QSharedPointer<KisResourceStorage> storage) Line 794 (e:\krita-win\src\libs\resources\KisResourceLocator.cpp:794)
kritaui.dll!KisDocument::KisDocument(bool addStorage) Line 601 (e:\krita-win\src\libs\ui\KisDocument.cpp:601)
[Inline Frame] kritaui.dll!KisPart::createDocument() Line 214 (e:\krita-win\src\libs\ui\KisPart.cpp:214)
kritaui.dll!KisCustomImageWidget::createNewImage() Line 316 (e:\krita-win\src\libs\ui\widgets\kis_custom_image_widget.cc:316)
[Inline Frame] kritaui.dll!KisCustomImageWidget::createImage() Line 275 (e:\krita-win\src\libs\ui\widgets\kis_custom_image_widget.cc:275)
kritaui.dll!KisCustomImageWidget::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 205 (e:\krita-win\b_msvc\libs\ui\kritaui_autogen\include_RelWithDebInfo\IMAN36LHMA\moc_kis_custom_image_widget.cpp:205)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ebe16c1() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4d3a6() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4d2b7() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4dfd4() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea9c416() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea76bad() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea74a39() (Origen desconocido:0)
kritaui.dll!KisApplication::notify(QObject * receiver, QEvent * event) Line 756 (e:\krita-win\src\libs\ui\KisApplication.cpp:756)
Qt5Core.dll!00007ffd3d561711() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea78064() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eac657a() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eac4600() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea76bad() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea75c0f() (Origen desconocido:0)
kritaui.dll!KisApplication::notify(QObject * receiver, QEvent * event) Line 756 (e:\krita-win\src\libs\ui\KisApplication.cpp:756)
Qt5Core.dll!00007ffd3d561711() (Origen desconocido:0)
Qt5Gui.dll!00007ffd3d980f7c() (Origen desconocido:0)
Qt5Gui.dll!00007ffd3d96b479() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5aa73b() (Origen desconocido:0)
user32.dll!UserCallWinProcCheckWow() (Origen desconocido:0)
user32.dll!DispatchMessageWorker() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5a9f51() (Origen desconocido:0)
qwindows.dll!00007ffd3cc841c9() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d55dc33() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ec3c33d() (Origen desconocido:0)
kritaui.dll!KisMainWindow::slotFileNew() Line 1711 (e:\krita-win\src\libs\ui\KisMainWindow.cpp:1711)
Qt5Core.dll!00007ffd3d581850() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4d3a6() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4d2b7() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eb4dfd4() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea9c416() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea76bad() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea74a39() (Origen desconocido:0)
kritaui.dll!KisApplication::notify(QObject * receiver, QEvent * event) Line 756 (e:\krita-win\src\libs\ui\KisApplication.cpp:756)
Qt5Core.dll!00007ffd3d561711() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea78064() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eac657a() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3eac4600() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea76bad() (Origen desconocido:0)
Qt5Widgets.dll!00007ffd3ea75c0f() (Origen desconocido:0)
kritaui.dll!KisApplication::notify(QObject * receiver, QEvent * event) Line 756 (e:\krita-win\src\libs\ui\KisApplication.cpp:756)
Qt5Core.dll!00007ffd3d561711() (Origen desconocido:0)
Qt5Gui.dll!00007ffd3d980f7c() (Origen desconocido:0)
Qt5Gui.dll!00007ffd3d96b479() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5aa73b() (Origen desconocido:0)
user32.dll!UserCallWinProcCheckWow() (Origen desconocido:0)
user32.dll!DispatchMessageWorker() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5a9f51() (Origen desconocido:0)
qwindows.dll!00007ffd3cc841c9() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d55dc33() (Origen desconocido:0)
Qt5Core.dll!00007ffd3d5605db() (Origen desconocido:0)
krita.dll!krita_main(int argc, char * * argv) Line 698 (e:\krita-win\src\krita\main.cc:698)
krita.exe!00007ff708cd1e47() (Origen desconocido:0)
krita.exe!00007ff708cd1232() (Origen desconocido:0)
kernel32.dll!BaseThreadInitThunk() (Origen desconocido:0)
ntdll.dll!RtlUserThreadStart() (Origen desconocido:0)
Comment 3 amyspark 2021-12-15 11:30:23 UTC
*** Bug 447020 has been marked as a duplicate of this bug. ***
Comment 4 Halla Rempt 2021-12-15 11:36:53 UTC
Okay, so it's not my branch, and it's relatively recent...
Comment 5 Bug Janitor Service 2021-12-15 14:06:32 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1236
Comment 6 Halla Rempt 2021-12-15 15:58:01 UTC
Git commit a3272dd378e3b622ebab450f606ebab2a1470eec by Halla Rempt.
Committed on 15/12/2021 at 15:57.
Pushed by rempt into branch 'master'.

Remove variantFromResourceQueryByID from the resource query mapper

The mapper can now map both the KisResourceModel query and the
KisTagResourceModel query to variants, so we don't have to query
by id anymore for KistagResourceModel.

This fixes 446984, but it's still weird that this was fine in 2020,
and started making creating images slow end of 2021. In any case,
creating images is cheap again.

M  +1    -1    libs/resources/KisResourceModel.cpp
M  +24   -70   libs/resources/KisResourceQueryMapper.cpp
M  +2    -4    libs/resources/KisResourceQueryMapper.h
M  +8    -2    libs/resources/KisTagResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/a3272dd378e3b622ebab450f606ebab2a1470eec
Comment 7 Halla Rempt 2021-12-15 15:58:28 UTC
Git commit 0e4b8448bf88f07d65cbc0ad215e6ebbb1e07208 by Halla Rempt.
Committed on 15/12/2021 at 15:58.
Pushed by rempt into branch 'krita/5.0'.

Remove variantFromResourceQueryByID from the resource query mapper

The mapper can now map both the KisResourceModel query and the
KisTagResourceModel query to variants, so we don't have to query
by id anymore for KistagResourceModel.

This fixes 446984, but it's still weird that this was fine in 2020,
and started making creating images slow end of 2021. In any case,
creating images is cheap again.
(cherry picked from commit a3272dd378e3b622ebab450f606ebab2a1470eec)

M  +1    -1    libs/resources/KisResourceModel.cpp
M  +24   -70   libs/resources/KisResourceQueryMapper.cpp
M  +2    -4    libs/resources/KisResourceQueryMapper.h
M  +8    -2    libs/resources/KisTagResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/0e4b8448bf88f07d65cbc0ad215e6ebbb1e07208
Comment 8 amyspark 2021-12-15 23:15:07 UTC
*** Bug 447047 has been marked as a duplicate of this bug. ***
Comment 9 Halla Rempt 2021-12-16 08:26:22 UTC
*** Bug 447048 has been marked as a duplicate of this bug. ***
Comment 10 amyspark 2022-01-05 20:33:01 UTC
*** Bug 447586 has been marked as a duplicate of this bug. ***