https://bugs.kde.org/show_bug.cgi?id=493436
Bug ID: 493436 Summary: Layer style + transformed clones + large canvas = extremely long file loading times. Classification: Applications Product: krita Version: 5.2.3 Platform: Appimage OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: * Unknown Assignee: krita-bugs-n...@kde.org Reporter: krzysztof.jajesn...@gmail.com Target Milestone: --- Created attachment 173933 --> https://bugs.kde.org/attachment.cgi?id=173933&action=edit Minimal example reproducing the problem. The file takes several minutes to open in Krita, removing the transform masks brings it down to a few seconds. SUMMARY The following layer structure combined with a large canvas size cause a .kra file to take extremely long to load: - Clone of Group 1 - Transform mask - (many more clones of Group 1, each with a transform mask) - Group 1 - Paint layer 1 with a layer style enabled. This is purely a performance problem. Normally I wouldn't report something like this, but the sheer length of the resulting loading time and things which affect that loading time make me suspect that there might be be some sort of combinatorial explosion or livelock happening under the hood. STEPS TO REPRODUCE 1. Create a new .kra file with a somewhat large canvas size (e.g. A4 300PPI) 2. Create a group layer (let's call it "Group 1") 3. Create a paint layer (let's call it "Paint layer 1") in "Group 1" and paint something on it. 4. Add a layer style to "Paint layer 1" (tested with outer glow and drop shadow, not sure about other styles) 5. Create multiple clone layers of "Group 1". Transform each clone using a transform mask. 6. Save and close the file. 7. Attempt to open the file. OBSERVED RESULT The .kra file takes an extremely long time to load, on the order of several minutes (the file I've attached takes about 5 minutes on my machine). I've verified this is not caused by me running out of RAM and swapping to disk - I have way more than enough RAM to open the file (I've also checked Krita's memory limit just to be sure). Removing the transform masks completely eliminates the slowdown (the file is back to loading within seconds). Disabling the layer style on "Paint layer 1" almost completely eliminates the slowdown. EXPECTED RESULT The .kra file takes a reasonable amount of time to load. SOFTWARE/OS VERSIONS OS: Debian 12 Stable, kernel 6.1.0-25-amd64 KDE Plasma Version: 5.27.5 KDE Frameworks Version: 5.103.0 Qt Version: 5.15.8 ADDITIONAL INFORMATION Things which seem to affect the slow loading time: - The size of the layer being cloned. - Canvas size. Simply resizing the canvas to a larger size with the offending layer structure left completely unchanged will massively increase the loading time of the .kra file. The effect is much larger than simply resizing the canvas without having the offending layer structure present. It feels like simply having a larger canvas multiplies the slowdown created by the offending layer structure. - Having other layers, filters, layer styles, etc. in the same .kra file outside of the offending layer structure. Seems to have a multiplicative effect on the slowdown. The worst case scenario is adding the offending layer structure to an existing .kra file with a large canvas size and large number of other layers. I've had it happen on a 2480x3508 image with ~100 layers. The offending part of the image was a paint layer ~600x600 in size, with an outer glow layer style. The group containing that layer was then cloned 7 times and all the clones had transform masks. This increased the loading time of the file to about 50 minutes (!). When the offending layer structure was removed, the file was back to loading in about 10 seconds. One more thing I noticed. While a file is being loaded, Krita displays a popup with a progress bar named "Waiting for image operation". When the file contains the offending layer structure, that progress bar will jump backwards several times during the loading process. Eventually the loading process "stabilizes" and from this point the progress bar stops randomly jumping backwards, although it will progress very slowly. - Before loading "stabilizes", Krita seems to use more than 1 CPU core (more than 100% CPU usage by the Krita process visible in top and CPU usage fluctuates wildly) - After loading "stabilizes", Krita only seems to use a single CPU core (constant ~100% CPU usage in top) This makes me believe there might be some sort of multithreading issue at play (I don't know the Krita codebase, this is just me speculating). Things which don't seem to have a significant effect on the loading time: - Filtering mode used on the transform mask. There seems to be some difference between e.g. using nearest neighbour vs something more expensive like Lanczos3, but it's not a major difference. - How the clones are organized. I've tried all clones + original in the same group, moving the original to a separate group, organizing the clones into several groups, even having each clone in its own dedicated group. In all cases the loading time was still horribly long. -- You are receiving this mail because: You are watching all bug changes.