Bug 419467 - Split layer can take hours on images with many colors
Summary: Split layer can take hours on images with many colors
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 4.2.9
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: efficiency-and-performance
Depends on:
Blocks:
 
Reported: 2020-03-31 21:52 UTC by Dmitry Kazakov
Modified: 2021-08-23 13:05 UTC (History)
5 users (show)

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


Attachments
simple and small range of colours (235.78 KB, application/x-krita)
2020-04-02 13:55 UTC, Ahab Greybeard
Details
small size, small range of colours (473.61 KB, application/x-krita)
2020-04-02 13:57 UTC, Ahab Greybeard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Kazakov 2020-03-31 21:52:53 UTC
STEPS TO REPRODUCE
1. Create image 3000x2000 with some data
2. Start "Split Layer"
3. Use default settings

Krita deadlocks. It might be relates to a CPU that has 16 cores.

The bug happens both in master and in 4.2.9.
Comment 1 Ahab Greybeard 2020-04-01 10:23:31 UTC
I get this with 4.2.9 but not 4.2.8. using appimages.

Progress is slow and stops at 91% complete, with one core at 100% (a 2 x 4-core system).

Setting to Confirmed
Comment 2 Halla Rempt 2020-04-01 13:48:38 UTC
Hm, I tested with the 4.3 branch and didn't get a deadlock :-(
Comment 3 Tiar 2020-04-02 12:27:25 UTC
@Dmitry, Ahab - can you please provide a file that it hangs on? And maybe even a backtrace? Neither boud or confifu can reproduce it.
Comment 4 Ahab Greybeard 2020-04-02 13:55:32 UTC
Created attachment 127201 [details]
simple and small range of colours

I attach split-test-simple.kra and  split-test-complex.kra which are 3000 x 2000 pixels. I also attach small-split-test-simple.kra which is 300 x 200 pixels.

With 4.2.9 and with the Apr-01 4.3.0 prealpha git 62b9516 appimages, the large ones lock up with 1 core at 100%.

With split-test-simple, the progress goes up rapidly and exponentially to 85% complete before locking up.

With split-test-complex, the progress goes up in a similar way to 8% complete before locking up.

With small-split-test-simple then 4.2.9 and the 4.3.0 prealpha both quickly split it into a very large number of colour layers.

4.2.8 splits it into only two layers, both called 'Salmon'. This is probably because 4.2.8 has different default settings.
Comment 5 Ahab Greybeard 2020-04-02 13:57:12 UTC
Created attachment 127202 [details]
small size, small range of colours
Comment 6 Ahab Greybeard 2020-04-02 13:59:45 UTC
split-test-complex.kra is 6.3 MB and you can download it from here:
https://www.dropbox.com/s/27w6zj2w7t42i09/split-test-complex.kra?dl=1
Comment 7 confifu 2020-04-03 02:56:01 UTC
Default options have changed for 4.2.9. I got the same behavior with 4.2.8 and 4.2.9 when I changed the options to be the same.
For 4.2.8, default options are from top to bottom are (T,F,T,F,T,T,fuzziness = 20).
For 4.2.9, default options are (T,F,T,T,T,F, fuzziness = 0).
I think this is because, we replaced KisConfig with KisDialogStateSaver in dlg_layersplit.cpp commit f6e7a99de04ebe023af444fc9e1c67d93f8f3a5a.
We didn't use any default values in the case of KisDialogStateSaver.
Comment 8 Halla Rempt 2020-05-04 08:57:23 UTC
WIth fuzziness = 0, it creates about 37000 layers... It's not hanging, it's simply going overboard! The algorithm to figure out which layer a certain pixel should go into then iterates over all the layers, so for every pixel, we check all created layers in a tight loop.
Comment 9 Tiar 2021-08-16 17:58:42 UTC
The default values for layer split options are fixed now: https://invent.kde.org/graphics/krita/-/commit/3584a78e6c461d67d466

But the problem of making way too many layers without informing the user beforehand is still there.