Bug 438607 - Fill tool + Color Label filter + Animation is slow (VERY slow)
Summary: Fill tool + Color Label filter + Animation is slow (VERY slow)
Status: ASSIGNED
Alias: None
Product: krita
Classification: Applications
Component: Tools (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2021-06-14 11:20 UTC by grum999
Modified: 2021-09-09 13:12 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
example file ready to use (342.95 KB, application/x-krita)
2021-06-14 11:20 UTC, grum999
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grum999 2021-06-14 11:20:20 UTC
Created attachment 139304 [details]
example file ready to use

SUMMARY

Working on an animation, it takes age to fill an area...


STEPS TO REPRODUCE
1. Create a document (1920x1080)

2. Create the following layers (or download attached file provided as example)

[root]
 +-- Group1                                <color label=red>
 |    +-- Paint Layer 1                    <color label=red>
 |    +-- Clone layer (Paint Layer 1)      <color label=red>
 |    |    +-- Transform mask 1 
 |    +-- Paint Layer 2                    
 +-- Paint Layer (Background)

3. Animate "Paint layer 1" (15 keyframes, basics rectangles for example)

4. Apply a rotation on "Transform mask 1" (30° for example)
   => no need to animate

5. Select FILL tool, and define options:
   - Sample: Color labeled layers
   - Labels used: red

6. Select "Paint layer 2"

7. Fill a shape


OBSERVED RESULT
On my side, it took 35s to fill area; having multiple area to fill on multiple keyframes, it's unusable.

If I use sample "All layers", fill action is instantaneous (so that's a workaround... temporary hide all layers except colored layers and use "all layers" sample to apply fill)



EXPECTED RESULT
Fill action should be instantaneous with 'color labeled' sample, like it is for 'all layers' sample.


SOFTWARE/OS VERSIONS
Tested krita-5.0.0-prealpha-4f029a8-x86_64.appimage on a AMD Ryzen 9 3900X 12-Core Processor 3800MHz


ADDITIONAL INFORMATION
Chaning the color of label (red, green, blue, ...) doesn't change anything :)
Comment 1 Eoin O'Neill 2021-06-15 01:35:05 UTC
This isn't unique to animation so I'm categorizing it under tools. The color labels, in this circumstance, are actually layer labels, not frame labels.
Comment 2 Tiar 2021-06-15 15:03:59 UTC
I think it might be actually caused, partially, by animation: in the code, Krita merges all the color labeled layers together in a temporary image and then use the projection. I guess what happens is that it still keeps track of the other frames until the very end, which makes it much slower than in a non-animated image with the same structure and size of layers etc.

The relevant code is in KisMergeLabeledLayersCommand, it's quite easy, what needs to be done is to check if the layer is animated and flatten the layer before it is added to the temporary image in the `mergeLabeledLayers()` function. That should make it faster, I think.
Comment 3 grum999 2021-06-16 12:06:38 UTC
"""
This isn't unique to animation so I'm categorizing it under tools.
"""
The problem only occurs with animated frames.

No frames=instantaneous fill
Frames=takes time (and the more keyframes you have, longer time it takes) 

According to @tiar explanation about the internal temporary merge of layers, problem could be a consequence of https://bugs.kde.org/show_bug.cgi?id=435716 


Grum999
Comment 4 Tiar 2021-06-16 14:53:48 UTC
@Grumm, no, I'm pretty sure it's not related, because the mechanism is different. The Fill Tool has its own code that doesn't have any special behaviour for animation, which means it doesn't have any good optimization to just use the current frame instead of using whole timeline and only focus on the current frame at the very end of the action.

But the code should be easy to fix. I'll add it to the "easy bugs" list. If anyone wants to work on that and don't know where to do, they can ask me for details/help.

@Grumm to confirm it's not related - can you please for example merge the clone layer with the transform mask (maybe add an empty layer to the mix too, to make sure that in the end you get an animated layer with every frame you need). And then try again. If it still doesn't work/lags a lot, then it's the Fill Tool issue, as I suspect...
Comment 5 grum999 2021-06-16 15:15:49 UTC
"""
@Grumm to confirm it's not related - can you please for example merge the clone layer with the transform mask (maybe add an empty layer to the mix too, to make sure that in the end you get an animated layer with every frame you need). And then try again. If it still doesn't work/lags a lot, then it's the Fill Tool issue, as I suspect...
"""
Additional test: on clone layer, animate transform mask and then merge clone layer with transform mask.
=> it generate keyframes

Now, doing fill taking in account all keyframes: took around 1s instead of 35s
Doing fill with all layer (no color labeled filter): instantaneous


So the problem is still here, just less noticeable because there's no more transformation mask to apply 



Grum999
Comment 6 wolthera 2021-09-09 13:12:21 UTC
OK, setting this to assigned given all the interest :|