Bug 459517 - [master] Performance when working under filter layers is significantly worse (likely due to layer thumbnail generation)
Summary: [master] Performance when working under filter layers is significantly worse ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Filter Layers (other bugs)
Version First Reported In: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-09-22 08:26 UTC by tomtomtomreportingin
Modified: 2023-05-08 09:58 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Stutter produced from a desaturate filter layer (3.15 MB, video/webm)
2023-04-25 20:02 UTC, tomtomtomreportingin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tomtomtomreportingin 2022-09-22 08:26:07 UTC
git 890a755

SUMMARY
Filter layer performance is noticeably worse in master, likely due to the thumbnail generation changes.

In 5.1.1, filter layer thumbnails seem to match the canvas, meaning no significant bounds calculation is necessary. In master, filter layer thumbnails match the group, meaning lag doesn't occur if the group includes a background layer.

STEPS TO REPRODUCE
1. Create a new document. 
2. Group paint layer 1.
3. Add a Desaturation filter layer to the group.
4. Paint a stroke.
5. Wait half a second.
6. Paint another stroke.

OBSERVED RESULT
The stroke in step 6 had a delay due to the filter layer thumbnail being generated.

EXPECTED RESULT
No noticeable choppiness.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian sid
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.12.12 (appimage)
Comment 1 Raghavendra kamath 2022-09-22 18:23:20 UTC

*** This bug has been marked as a duplicate of bug 458475 ***
Comment 2 Dmitry Kazakov 2023-04-25 12:53:08 UTC
Hi, tomtomtom!

Could you please test the bug in the current master? I cannot reproduce the issue it seems. Could you make a video?
Comment 3 Dmitry Kazakov 2023-04-25 13:23:06 UTC
Mark as waiting for info
Comment 4 tomtomtomreportingin 2023-04-25 20:02:35 UTC
Created attachment 158423 [details]
Stutter produced from a desaturate filter layer

I can still reproduce the issue on git 7a932e3.

I've attached a video where you can observe stutter on the initialization of delayed strokes.
Comment 5 tomtomtomreportingin 2023-04-25 20:18:24 UTC
Issue seems reproducible on a 3000x4000 canvas but not a 500x1000 canvas.
Comment 6 Dmitry Kazakov 2023-05-02 12:48:47 UTC
Hi, tomtomtom!

Could you clarify a little bit, what exactly you consider to be a stutter?

a) a small delay the brush **outline** experiences, or
b) a small delay the brush **stroke** experience

Could you also tell me if you have Instant Preview feature enabled? And does disabling it helps anyhow?

I have a feeling like the  preview generation itself is not related, by the stutter you experience is variant b) caused by the instant preview feature.
Comment 7 tomtomtomreportingin 2023-05-02 12:54:35 UTC
The delay applies to the stroke, and happens regardless of whether instant preview is enabled or not.
Comment 8 tomtomtomreportingin 2023-05-02 13:04:35 UTC
It applies to both the stroke and the outline if I enable the brush preview outline.
Comment 9 Dmitry Kazakov 2023-05-03 09:04:58 UTC
This is a regression from my exactBounds-for-thumbnails commit:

  * frame #0: 0x00007ffdbcafa4bb kritalayerdocker.dll`LayerBox::updateUI() [inlined] QMessageLogContext::QMessageLogContext(this=0x0000002ab451b918, fileName=0x0000000000000000, lineNumber=0, functionName=0x0000000000000000, categoryName=<unavailable>) at qlogging.h:70:9
    frame #1: 0x00007ffdbcafa4bb kritalayerdocker.dll`LayerBox::updateUI() [inlined] QMessageLogger::QMessageLogger(this=0x0000002ab451b918, file=0x0000000000000000, line=0, function=0x0000000000000000) at qlogging.h:91:11
    frame #2: 0x00007ffdbcafa4bb kritalayerdocker.dll`LayerBox::updateUI(this=0x000001b3b0da44a0) at LayerBox.cpp:650:5
    frame #3: 0x00007ffe04e50cbb Qt5Core.dll`void doActivate<false>(QObject*, int, void**) at qobject.cpp:3931:21
    frame #4: 0x00007ffe04ddf600 Qt5Core.dll`QAbstractItemModel::dataChanged(QModelIndex const&, QModelIndex const&, QVector<int> const&) at moc_qabstractitemmodel.cpp:557:5
    frame #5: 0x00007ffe12e07ebf libkritaui.dll`KisNodeModel::progressPercentageChanged(this=0x000001b3b0f5bea0, (null)=<unavailable>, node=<unavailable>) at kis_node_model.cpp:212:14
    frame #6: 0x00007ffe12c2aaf8 libkritaui.dll`KisNodeModel::qt_static_metacall(_o=<unavailable>, _c=<unavailable>, _id=<unavailable>, _a=<unavailable>) at moc_kis_node_model.cpp:142:22
    frame #7: 0x00007ffe04e50cbb Qt5Core.dll`void doActivate<false>(QObject*, int, void**) at qobject.cpp:3931:21
    frame #8: 0x00007ffe09ca90e5 libkritaimage.dll`KisNodeProgressProxy::percentageChanged(this=<unavailable>, _t1=<unavailable>, _t2=<unavailable>) at moc_kis_node_progress_proxy.cpp:137:5
    frame #9: 0x00007ffe09f8cf0f libkritaimage.dll`KisNodeProgressProxy::setRange(this=<unavailable>, _minimum=<unavailable>, _maximum=<unavailable>) at kis_node_progress_proxy.cpp:82:14
Comment 10 Dmitry Kazakov 2023-05-08 09:58:18 UTC
Git commit de461c1b7f39b7e47974c6f769247bfd0c1677d8 by Dmitry Kazakov.
Committed on 05/05/2023 at 11:46.
Pushed by dkazakov into branch 'master'.

Fix hiccups when image has a big filter layer

The hiccups were caused buy the thumbnail generator that tried
to calculate the layer's exact bounds right in the middle of the
stroke. It did that in the GUI stroke, which could delay the
updates up to 200ms, which is quite visible to the user.

The patch moves thumbnail generation into a background stroke.

It uses the same technology as Overview Docker and extracts it in
a form of KisIdleTasksManager and KisIdleTaskStrokeStrategy. In the
following patch I will port OverviewDocker and other places to use
KisIdleTasksManager.

M  +5    -0    libs/image/kis_base_node.cpp
M  +6    -0    libs/image/kis_base_node.h
M  +13   -2    libs/image/kis_idle_watcher.cpp
M  +4    -1    libs/image/kis_idle_watcher.h
M  +6    -0    libs/image/kis_layer.cc
M  +2    -0    libs/image/kis_layer.h
M  +7    -0    libs/image/kis_mask.cc
M  +1    -0    libs/image/kis_mask.h
M  +8    -0    libs/image/kis_selection_based_layer.cpp
M  +2    -0    libs/image/kis_selection_based_layer.h
M  +3    -2    libs/libqml/plugins/kritasketchplugin/models/LayerModel.cpp
M  +3    -0    libs/ui/CMakeLists.txt
A  +52   -0    libs/ui/KisIdleTaskStrokeStrategy.cpp     [License: GPL(v2.0+)]
A  +38   -0    libs/ui/KisIdleTaskStrokeStrategy.h     [License: GPL(v2.0+)]
A  +125  -0    libs/ui/KisIdleTasksManager.cpp     [License: GPL(v2.0+)]
A  +83   -0    libs/ui/KisIdleTasksManager.h     [License: GPL(v2.0+)]
A  +190  -0    libs/ui/KisLayerThumbnailCache.cpp     [License: GPL(v2.0+)]
A  +48   -0    libs/ui/KisLayerThumbnailCache.h     [License: GPL(v2.0+)]
M  +1    -1    libs/ui/KisPart.cpp
M  +12   -1    libs/ui/KisViewManager.cpp
M  +3    -0    libs/ui/KisViewManager.h
M  +1    -1    libs/ui/kis_node_filter_proxy_model.cpp
M  +28   -2    libs/ui/kis_node_model.cpp
M  +6    -1    libs/ui/kis_node_model.h
M  +2    -2    libs/ui/tests/kis_model_index_converter_test.cpp
M  +5    -5    libs/ui/tests/kis_node_model_test.cpp
M  +3    -3    plugins/dockers/channeldocker/channeldocker_dock.cpp
M  +5    -5    plugins/dockers/histogram/histogramdocker_dock.cpp
M  +6    -23   plugins/dockers/layerdocker/LayerBox.cpp
M  +0    -5    plugins/dockers/layerdocker/LayerBox.h
M  +1    -1    plugins/dockers/layerdocker/tests/TestNodeView.cpp
M  +4    -4    plugins/dockers/overview/overviewwidget.cc
M  +1    -1    plugins/dockers/storyboarddocker/StoryboardModel.cpp

https://invent.kde.org/graphics/krita/commit/de461c1b7f39b7e47974c6f769247bfd0c1677d8