Bug 493593 - Undo preview generation visibly freezes krita for serveral seconds when working with large transparent images
Summary: Undo preview generation visibly freezes krita for serveral seconds when worki...
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: * Unknown (other bugs)
Version First Reported In: 5.2.5
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-24 16:56 UTC by Sebastian Parborg
Modified: 2024-09-24 16:56 UTC (History)
0 users

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


Attachments
Krita file with slow thumbnail generation (334.21 KB, application/x-7z-compressed)
2024-09-24 16:56 UTC, Sebastian Parborg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Parborg 2024-09-24 16:56:14 UTC
Created attachment 174032 [details]
Krita file with slow thumbnail generation

SUMMARY

When working with large images (7680 x 4320) with large transparent areas, the undo image thumbnail generation freezes redrawing of the Krita UI after every operation for a long time.

The reason for this is that even if the undo history docker is hidden, thumbnails is generated.
The slow code path is `m_paintDevice->exactBounds()` that was introduced in:
https://invent.kde.org/graphics/krita/-/commit/b67e2556bb2944f56c0a4ca9bd77a1f29f8e05df

Because it loops over potentially all pixels in the image to find any opaque pixels, probably best to not do this in a locking manner for the undo system. (Or perhaps generate the undo thumbnails on demand if the undo history docker is visible?

Note that I'm specifically pointing to the undo thumbnail creation here as I ran krita with a profiler (hotspot) and it showed that after each stroke it seems like all activity was in a single thread doing `exactBounds` calculations.

If I shorted out the exact bounds function to return early without doing any calculations, krita was really fast and responsive again.

STEPS TO REPRODUCE
1. Open the krita file I have attached in the .7z archive
2. Draw a stroke in the middle of the image
3. Notice that the krita UI freezes after finishing the stroke
4. Add a opaque pixel at every corner of the image
5. Notice that now drawing in the middle is really fast and responsive

OBSERVED RESULT
The krita UI freezes after every stroke when an image has large transparent areas

EXPECTED RESULT
Thumbnail creations shouldn't lockup the UI and degrade the overall performance of Krita.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo Linux
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.2