Bug 438384

Summary: Slowdown when nesting more than 5 Group Layers
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73
Priority: NOR    
Version First Reported In: 4.4.5   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Tyson Tan 2021-06-10 04:58:15 UTC
Krita seems to slowdown significantly when nesting more than 5 Group Layers.

Steps to reproduce:
1) Create a new document,
2) Select a paint layer, Ctrl+G 6 times, so it's now nesting inside 6 group layers
3) Try draw something in the paint layer.

To me, the whole canvas stutter the moment when it hit the 6th nesting, the canvas become a checkerboard with some tiles of white and some tiles of transparency. All brush strokes after that was very choppy.

Tested under 4.4.5 and 5.0 nighties. Windows and Linux.
This is a bug relayed from the local community.
Comment 1 Dmitry Kazakov 2021-06-10 05:05:38 UTC
Theoretically, if all nested groups have only one layer without any custom blending, then it shouldn't do any delay. But it each group has more than one layer, then a significant delay is expected. 

I can reproduce the slowdown in the former case, so it looks like a valid bug. I'll check what happens there.
Comment 2 Dmitry Kazakov 2021-06-10 05:34:40 UTC
Okay, the slowdown happens due to too much contestion in KisGroupLayer::tryObligeChild()
Comment 3 Dmitry Kazakov 2021-06-10 09:13:50 UTC
Git commit fe2635ee8992b030e465cf33be278d2a0dcebf5a by Dmitry Kazakov.
Committed on 10/06/2021 at 09:12.
Pushed by dkazakov into branch 'master'.

Reduce contestion over oblidge-child routines in group layers

We shouldn't ask for projection() in group layers too often.

M  +25   -18   libs/image/kis_group_layer.cc
M  +1    -0    libs/image/kis_group_layer.h
M  +6    -1    libs/image/kis_layer.cc
M  +7    -0    libs/image/kis_layer.h

https://invent.kde.org/graphics/krita/commit/fe2635ee8992b030e465cf33be278d2a0dcebf5a
Comment 4 Tyson Tan 2021-06-10 11:35:30 UTC
Thank you, Dmitry! :D