Bug 427199

Summary: Fill layer preview generates garbage on screen when switching filters too fast
Product: [Applications] krita Reporter: Dmitry Kazakov <dimula73>
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, tomtomtomreportingin
Priority: NOR Keywords: regression
Version: 4.4.0-beta2   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot of the problem

Description Dmitry Kazakov 2020-10-01 10:47:47 UTC
Created attachment 132044 [details]
Screenshot of the problem

STEPS TO REPRODUCE
1. Create an RGB8 image 5000x5000 (size is important, updates should be slow enough)
2. Add a fill layer, select Multigrid generator. Quickly add more gradient stops
3. Before the calculation if completed, switch to a pattern fill
4. See the canvas filled with both, pattern and some segments of the multigrid.
Comment 1 Dmitry Kazakov 2020-10-01 10:49:33 UTC
Video recording of the problem: https://yadi.sk/i/PuIN9PpNZL_ALg
Comment 2 Ahab Greybeard 2020-10-01 14:31:45 UTC
Tested with the 4.4.0-beta2 appimage.

When I do this, with a 10,000 x 10,000 image, I see the layer thumbnail spend a long time (30 seconds) showing the ongoing construction of the multigrid image and the canvas showing just a small number of updates associated with this followed by mixed 'garbage'.

The mixed 'garbage' result stays there until the OK button is pressed and the pattern is then displayed.

Maybe the fill type calculations need to be stopped/cancelled if a different fill type is selected or if the parameters of the fill type are changed at any time.
Comment 3 Dmitry Kazakov 2020-10-03 10:33:11 UTC
I'll mark it as a regression, because it happens in a feature first appeared in 4.4.0 :)
Comment 4 Halla Rempt 2020-10-04 09:59:51 UTC
*** Bug 427317 has been marked as a duplicate of this bug. ***
Comment 5 Dmitry Kazakov 2020-10-06 11:32:33 UTC
Git commit 3b19865d7a862f39dbe6b800aa6c40f421298fc6 by Dmitry Kazakov.
Committed on 06/10/2020 at 11:30.
Pushed by dkazakov into branch 'krita/4.3'.

Add barrier jobs for KisGeneratorStrokeStrategy

When preview stroke adds a set of jobs, this set should never
intersect with the previous update jobs. Otherwise there will
be crash.

M  +3    -1    libs/image/generator/kis_generator_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/3b19865d7a862f39dbe6b800aa6c40f421298fc6
Comment 6 Dmitry Kazakov 2020-10-06 11:33:03 UTC
Git commit 2090f233e74838217dfb5c8240601d15ceb29a14 by Dmitry Kazakov.
Committed on 06/10/2020 at 11:32.
Pushed by dkazakov into branch 'master'.

Add barrier jobs for KisGeneratorStrokeStrategy

When preview stroke adds a set of jobs, this set should never
intersect with the previous update jobs. Otherwise there will
be crash.

M  +3    -1    libs/image/generator/kis_generator_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/2090f233e74838217dfb5c8240601d15ceb29a14
Comment 7 Dmitry Kazakov 2020-10-06 11:37:44 UTC
Git commit 0b5b2f1d5566497993e3a7f5bdd2ffa2430edc3b by Dmitry Kazakov.
Committed on 06/10/2020 at 11:37.
Pushed by dkazakov into branch 'krita/4.4.0'.

Add barrier jobs for KisGeneratorStrokeStrategy

When preview stroke adds a set of jobs, this set should never
intersect with the previous update jobs. Otherwise there will
be crash.

M  +3    -1    libs/image/generator/kis_generator_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/0b5b2f1d5566497993e3a7f5bdd2ffa2430edc3b
Comment 8 Bug Janitor Service 2020-10-26 16:46:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/553
Comment 9 Dmitry Kazakov 2020-10-29 12:29:17 UTC
Git commit 195b02123a33ada9c8cd914144116671bd5ea978 by Dmitry Kazakov, on behalf of L. E. Segovia.
Committed on 29/10/2020 at 12:29.
Pushed by dkazakov into branch 'krita/4.3'.

Correctly add barrier jobs for KisGeneratorStrokeStrategy

The correct type of job to block Fill Layer updates is BARRIER --
update jobs cannot start unless we are sure the previous set has
been cleared and committed to the canvas.
Related: bug 428014

M  +4    -7    libs/image/generator/kis_generator_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/195b02123a33ada9c8cd914144116671bd5ea978
Comment 10 Dmitry Kazakov 2020-10-29 12:33:07 UTC
Git commit 7f68229d3bb8580930199a43c7c68921c3f704b7 by Dmitry Kazakov, on behalf of L. E. Segovia.
Committed on 29/10/2020 at 12:32.
Pushed by dkazakov into branch 'master'.

Correctly add barrier jobs for KisGeneratorStrokeStrategy

The correct type of job to block Fill Layer updates is BARRIER --
update jobs cannot start unless we are sure the previous set has
been cleared and committed to the canvas.
Related: bug 428014

M  +4    -7    libs/image/generator/kis_generator_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/7f68229d3bb8580930199a43c7c68921c3f704b7