Bug 438768 - Animated transform masks regenerate on every time change unconditionally
Summary: Animated transform masks regenerate on every time change unconditionally
Status: RESOLVED INTENTIONAL
Alias: None
Product: krita
Classification: Applications
Component: Animation (other bugs)
Version First Reported In: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-16 20:02 UTC by grum999
Modified: 2024-09-13 08:52 UTC (History)
2 users (show)

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


Attachments
example with activity on transform mask even when cache is generated (383.16 KB, video/webm)
2021-06-16 20:02 UTC, grum999
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grum999 2021-06-16 20:02:04 UTC
Created attachment 139412 [details]
example with activity on transform mask even when cache is generated

SUMMARY


Even if cache is rendered, when going to another frame, transformation mask is calculated.
On simple animation, it's not really a problem, but on complex animation with many animated transform mask...

STEPS TO REPRODUCE
1. Create a document with a paint layer and an animated transform mask
2. click "Play" to render cache
3. Stop playing
4. Go manually to other frames

OBSERVED RESULT
Even if cache is rendered, calculation are computed.
We can see activity on transform layer mask


EXPECTED RESULT
If frame is in cache, no calculation should be computed


SOFTWARE/OS VERSIONS
krita-5.0.0-prealpha-949e869-x86_64.appimage

ADDITIONAL INFORMATION
Occurs when cache is in memory or on-disk
Occurs is region of interest is active or not
Comment 1 Emmet O'Neill 2021-06-17 01:39:04 UTC
Confirmed. Thanks.

(Note: May or may not be related to this https://bugs.kde.org/show_bug.cgi?id=438768)
Comment 2 Emmet O'Neill 2021-06-17 01:40:46 UTC
(Whoops... I meant may be related to THIS: https://bugs.kde.org/show_bug.cgi?id=438538 Krita is doing some calculations on hidden layers)
Comment 3 Eoin O'Neill 2021-07-07 20:47:13 UTC
There's a small issue with this -- that the recalculate mask job can't get information about the cache state of the animation system (since caching happens on the GUI level.)

For now, recalculate mask no longer occurs when dealing with animated transform masks so they no longer update on a timer. This should help iron out other issues with the transform mask not fully rendering the whole desired "region".
Comment 4 Dmitry Kazakov 2023-10-16 14:53:38 UTC
The problem happens due to two weird reasons:

1) On the end of animation playback we call switchCurrentTimeAsync() with forced image regeneration, instead of just just repopulating the openGL textures.

2) On every time change we force image regeneration in KisRegenerateFrameStrokeStrategy::doStrokeCallback, which, in turn causes transformation mask to be regenerated with FILTHY position, which causes the mask's cache to be reset, even when the layer and mask don't actually change.
Comment 5 Dmitry Kazakov 2024-09-13 08:52:15 UTC
Hi, Grum!

I have a feeling that this bug is actually an expected behavior. The animation cache that you see on the timeline is only the GUI cache. It has nothing related to the cache in a transformation mask. In your example, when you change the time, you do actually change the content of the layer (and its mask), so the mask must be recalcualted to show the correct result.

There is a small missed optimization opportunity when a non-animated transformation mask is situated on a non-animated layer, and even in this case, the mask is still regenerated on the time change. That is just how the system is designed to work right now (we have no way of distinguishing the source and destination time points of the update). 

Speaking truly, I have a feeling that it would be better to rewirte transform masks to use GPU instead of just trying to cut off a few extra updates.

I will close the bug right now (as it waits for the GPU-transform masks rewrite). If you think that your bug is different or critical, please reopen the bug.