Bug 476495

Summary: Incorrect flattening of animated layers with filter masks
Product: [Applications] krita Reporter: paleh <paleh21669>
Component: AnimationAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73
Priority: NOR Keywords: regression, release_blocker
Version: 5.2.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: frame 3 after flattening on frame 1

Description paleh 2023-11-03 02:55:11 UTC
Created attachment 162833 [details]
frame 3 after flattening on frame 1

STEPS TO REPRODUCE
1. Create an empty paint layer.
2. Create several (at least 3) frames on this layer. Draw something on these frames such that the bounding boxes of the frames intersect but don't entirely cover each other.
3. Add a filter mask for this layer, for example HSV/HSL Adjustment.
4. Switch to the first frame.
5. Flatten the animated layer.

OBSERVED RESULT
Switching to other frames, we can see that they contain elements of other frames. In the attached screenshot, each frame originally contained only one number, but after flattening frame 3 now contains parts of all 3 of them.

EXPECTED RESULT
Flattening keeps all the frames consistent with their projection before flattening.

SOFTWARE/OS VERSIONS
Linux: Ubuntu 22.04
Qt Version: 5.15.7
Appimage

ADDITIONAL INFORMATION
Bug is present in 5.2.0 and 5.3.0-7258fce19ce but is not present in 5.1.5
Comment 1 Dmitry Kazakov 2023-11-03 08:31:29 UTC
Hi, paleh!

Thank you for your report. I can confirm the bug.
Comment 2 Dmitry Kazakov 2023-11-03 09:56:58 UTC
Okay, the regression is caused by the following commit:

commit 59d7555716f0f276c1aae5a1a9605650a7643890
Author: Dmitry Kazakov <dimula73@gmail.com>, Fri Jan 20 12:39:01 2023 +0300 (10 months ago)
Committer: Dmitry Kazakov <dimula73@gmail.com>, Fri Jan 20 12:39:17 2023 +0300 (10 months ago)
Branches: <Expand>
Precedes: 5.2.0-beta1
Follows: v5.2.0-prealpha

Fix double extension of the update rect when flattening transform masks

BUG:463788
Comment 3 Dmitry Kazakov 2023-11-03 11:59:44 UTC
Git commit 8a2e4c8b0e2c260dae591553603ddac177c59c23 by Dmitry Kazakov.
Committed on 03/11/2023 at 12:59.
Pushed by dkazakov into branch 'krita/5.2'.

Make sure that the image is properly updated on frame switch on merge

Sometimes the bounding rect of the layer is changed when switching
frames, in such a case we should actually update more than its new
rect. Hence we add the entire image bounds to the update rect (like
we do on the normal frame switch).

M  +32   -6    libs/image/kis_layer_utils.cpp

https://invent.kde.org/graphics/krita/-/commit/8a2e4c8b0e2c260dae591553603ddac177c59c23
Comment 4 Dmitry Kazakov 2023-11-03 12:01:09 UTC
Git commit c3574772c9edefd6e3a70fb94f3b2e18dad0a186 by Dmitry Kazakov.
Committed on 03/11/2023 at 13:01.
Pushed by dkazakov into branch 'master'.

Make sure that the image is properly updated on frame switch on merge

Sometimes the bounding rect of the layer is changed when switching
frames, in such a case we should actually update more than its new
rect. Hence we add the entire image bounds to the update rect (like
we do on the normal frame switch).

M  +32   -6    libs/image/kis_layer_utils.cpp

https://invent.kde.org/graphics/krita/-/commit/c3574772c9edefd6e3a70fb94f3b2e18dad0a186
Comment 5 Dmitry Kazakov 2023-11-03 12:02:27 UTC
Hi, paleh!

I think I have fixed the issue, please check these builds when they are finished:

https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/2040/
https://binary-factory.kde.org/job/Krita_Stable_Windows_Build/2034/
Comment 6 paleh 2023-11-03 15:12:42 UTC
I tried the linux build and couldn't find anything wrong. While trying to break it, I did discover a couple of other animation bugs , but they weren't caused by neither this commit nor the introduction of the new merging method.
Comment 7 Dmitry Kazakov 2023-11-03 15:55:24 UTC
*** Bug 476511 has been marked as a duplicate of this bug. ***