Bug 475745 - Crash while working on many raster layers with a transform mask each
Summary: Crash while working on many raster layers with a transform mask each
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resize/Scale Image/Layer (show other bugs)
Version: 5.2.0
Platform: Other Other
: NOR crash
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2023-10-17 14:51 UTC by Dynline
Modified: 2024-02-28 18:09 UTC (History)
1 user (show)

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


Attachments
Crash report (25.06 KB, text/plain)
2023-10-17 14:51 UTC, Dynline
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dynline 2023-10-17 14:51:36 UTC
Created attachment 162371 [details]
Crash report

SUMMARY
***


STEPS TO REPRODUCE
I repeated this steps several times quickly, I am not sure if this alone is what caused the crash.

1. have a raster layer with a trasnform mask on it, move it and scale it. 
2. duplicate both
3. click on the transform mask with transform tool and change its position
4. repeat steps 2 and 3


SOFTWARE/OS VERSIONS
Windows 10


ADDITIONAL INFORMATION
i had a group with raster layers and clipping masks hidden. I was duplicating a merged version of the group several times and moving the duplicates with a transform mask on each of them. At the time of crash I had about 8 layers with transform masks.
Comment 1 wolthera 2023-10-18 10:30:10 UTC
Assigning this to dmitry, as per his request.
Comment 2 Dmitry Kazakov 2024-01-30 14:59:23 UTC
Hi, Dynline!

Could you please check if you have a **crash** in the recent nightly builds?

https://binary-factory.kde.org/job/Krita_Nightly_Windows_Build/

I cannot reproduce the crash itself, though I can reproduce a weird offset issue caused by duplicating a layer with its mask. I'm going to fix the offset part of the issue, but for the crash I need more info.
Comment 3 Bug Janitor Service 2024-02-02 17:05:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/2064
Comment 4 Dmitry Kazakov 2024-02-02 17:51:26 UTC
Git commit c7a825451c110dd7524be053801c0af74a47f957 by Dmitry Kazakov.
Committed on 02/02/2024 at 17:10.
Pushed by dkazakov into branch 'master'.

Fix transform mask updates triggered by transform tool in-stroke

When transform mask changes the options of the transform mask
it shouldn't trigger static updates when the stroke is running,
because the cache is overridden.

M  +5    -3    libs/image/kis_transform_mask.cpp

https://invent.kde.org/graphics/krita/-/commit/c7a825451c110dd7524be053801c0af74a47f957
Comment 5 Dmitry Kazakov 2024-02-02 17:51:27 UTC
Git commit b005afc5b03c160e504116798a99e1caa7ba4cb6 by Dmitry Kazakov.
Committed on 02/02/2024 at 17:10.
Pushed by dkazakov into branch 'master'.

Fix artifacts when changing transform mask continuously

The patch implements multiple things:

1) Makes static cache storage in the transform mask thread-safe
   and encapsulated in a single structure.

2) Makes sure that KisRecalculateTransformMaskJob::run() cannot run
   twice for the same parameters. Now it is governed by
   m_mask->staticImageCacheIsValid() check in the beginnig of the
   function.

   The multiple invocations could happen due to concurrent calls to
   KisTransformMask::slotDelayedStaticUpdate() (by the timer) and
   KisTransformMask::threadSafeForceStaticImageUpdate() (by an
   undo command). That could happen in the beginning of the
   transformation stroke. Now the two calls will be compressed by
   the cache validity check.

3) InplaceTransformStrokeStrategy does a better job in maintaining
   updates for the final lod0 update of the lodN stroke.

4) Implements a unittest for testing the inplace stroke strategy. Alas
   its results are not very stable, so it is marked as broken for now.

M  +1    -0    libs/image/CMakeLists.txt
A  +10   -0    libs/image/KisTransformMaskTestingInterface.cpp     [License: GPL(v2.0+)]
A  +25   -0    libs/image/KisTransformMaskTestingInterface.h     [License: GPL(v2.0+)]
M  +8    -1    libs/image/kis_recalculate_transform_mask_job.cpp
M  +2    -1    libs/image/kis_recalculate_transform_mask_job.h
M  +197  -64   libs/image/kis_transform_mask.cpp
M  +11   -1    libs/image/kis_transform_mask.h
M  +9    -2    plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp
M  +5    -0    plugins/tools/tool_transform2/tests/CMakeLists.txt
A  +627  -0    plugins/tools/tool_transform2/tests/TransformStrokeStrategyTest.cpp     [License: GPL(v2.0+)]
A  +24   -0    plugins/tools/tool_transform2/tests/TransformStrokeStrategyTest.h     [License: GPL(v2.0+)]
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0-cancelled/inplace-lod0-cancelled_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0-continue-and-cancel/inplace-lod0-continue-and-cancel_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0/inplace-lod0_autobrush_300px.kpp_indirect_finished_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2-cancelled/inplace-lod2-cancelled_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2-continue-and-cancel/inplace-lod2-continue-and-cancel_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2/inplace-lod2_autobrush_300px.kpp_indirect_finished_internal.png
M  +23   -2    sdk/tests/stroke_testing_utils.cpp
M  +4    -0    sdk/tests/stroke_testing_utils.h

https://invent.kde.org/graphics/krita/-/commit/b005afc5b03c160e504116798a99e1caa7ba4cb6
Comment 6 Dmitry Kazakov 2024-02-02 17:51:28 UTC
Git commit 9778839e48e0857828429b11a887dcc47d745847 by Dmitry Kazakov.
Committed on 02/02/2024 at 17:10.
Pushed by dkazakov into branch 'master'.

Fix transform masks being broken after duplication

M  +1    -0    plugins/tools/tool_transform2/KisAnimatedTransformMaskParamsHolder.cpp

https://invent.kde.org/graphics/krita/-/commit/9778839e48e0857828429b11a887dcc47d745847
Comment 7 Dmitry Kazakov 2024-02-28 18:09:34 UTC
Git commit 9ea99d4ab11f4ecd5f5d40c4d298fe4a07e1ce70 by Dmitry Kazakov.
Committed on 28/02/2024 at 12:56.
Pushed by dkazakov into branch 'kazakov/for-5.2'.

Fix artifacts when changing transform mask continuously

The patch implements multiple things:

1) Makes static cache storage in the transform mask thread-safe
   and encapsulated in a single structure.

2) Makes sure that KisRecalculateTransformMaskJob::run() cannot run
   twice for the same parameters. Now it is governed by
   m_mask->staticImageCacheIsValid() check in the beginnig of the
   function.

   The multiple invocations could happen due to concurrent calls to
   KisTransformMask::slotDelayedStaticUpdate() (by the timer) and
   KisTransformMask::threadSafeForceStaticImageUpdate() (by an
   undo command). That could happen in the beginning of the
   transformation stroke. Now the two calls will be compressed by
   the cache validity check.

3) InplaceTransformStrokeStrategy does a better job in maintaining
   updates for the final lod0 update of the lodN stroke.

4) Implements a unittest for testing the inplace stroke strategy. Alas
   its results are not very stable, so it is marked as broken for now.

M  +1    -0    libs/image/CMakeLists.txt
A  +10   -0    libs/image/KisTransformMaskTestingInterface.cpp     [License: GPL(v2.0+)]
A  +25   -0    libs/image/KisTransformMaskTestingInterface.h     [License: GPL(v2.0+)]
M  +8    -1    libs/image/kis_recalculate_transform_mask_job.cpp
M  +2    -1    libs/image/kis_recalculate_transform_mask_job.h
M  +197  -64   libs/image/kis_transform_mask.cpp
M  +11   -1    libs/image/kis_transform_mask.h
M  +9    -2    plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp
M  +5    -0    plugins/tools/tool_transform2/tests/CMakeLists.txt
A  +627  -0    plugins/tools/tool_transform2/tests/TransformStrokeStrategyTest.cpp     [License: GPL(v2.0+)]
A  +24   -0    plugins/tools/tool_transform2/tests/TransformStrokeStrategyTest.h     [License: GPL(v2.0+)]
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0-cancelled/inplace-lod0-cancelled_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0-continue-and-cancel/inplace-lod0-continue-and-cancel_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod0/inplace-lod0_autobrush_300px.kpp_indirect_finished_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2-cancelled/inplace-lod2-cancelled_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2-continue-and-cancel/inplace-lod2-continue-and-cancel_autobrush_300px.kpp_indirect_cancelled_internal.png
A  +-    --    plugins/tools/tool_transform2/tests/data/inplace-lod2/inplace-lod2_autobrush_300px.kpp_indirect_finished_internal.png
M  +23   -2    sdk/tests/stroke_testing_utils.cpp
M  +4    -0    sdk/tests/stroke_testing_utils.h

https://invent.kde.org/graphics/krita/-/commit/9ea99d4ab11f4ecd5f5d40c4d298fe4a07e1ce70
Comment 8 Dmitry Kazakov 2024-02-28 18:09:50 UTC
Git commit 1aed1cd5b4233324acc71bc6aaf8ef2c890c5621 by Dmitry Kazakov.
Committed on 28/02/2024 at 12:56.
Pushed by dkazakov into branch 'kazakov/for-5.2'.

Fix transform mask updates triggered by transform tool in-stroke

When transform mask changes the options of the transform mask
it shouldn't trigger static updates when the stroke is running,
because the cache is overridden.

M  +5    -3    libs/image/kis_transform_mask.cpp

https://invent.kde.org/graphics/krita/-/commit/1aed1cd5b4233324acc71bc6aaf8ef2c890c5621
Comment 9 Dmitry Kazakov 2024-02-28 18:09:56 UTC
Git commit bd8fdd243a3ba864f2c0d1d99ffc8b4d7afc0ff6 by Dmitry Kazakov.
Committed on 28/02/2024 at 12:56.
Pushed by dkazakov into branch 'kazakov/for-5.2'.

Fix transform masks being broken after duplication

M  +1    -0    plugins/tools/tool_transform2/KisAnimatedTransformMaskParamsHolder.cpp

https://invent.kde.org/graphics/krita/-/commit/bd8fdd243a3ba864f2c0d1d99ffc8b4d7afc0ff6