Rotating light brushtips WIP

Like @Mythmaker said the brush itself doesn’t freeze anything. But it may indeed be confusing to people that it only works some of the time so probably better not to include it in the future. :slight_smile:

(If one were to finish a painting in a single session with the lightness layer still not baked - a neat thing you could do with this brush is to separate the lightness effect. Erase, copy, undo, paste. Desaturate and use Arcus Tangent blending mode (on copies or clone layers). You could then add a color tint with a gradient map or adjust the contrast.)

1 Like

That looks interesting, but i say Arcus tangent in a video and people will listen how their brain explode, mine included

5 Likes

Hi, @RamonM!

Thank you for pinging me!

On Loading the bundle

Spurious detach:

ucrtbase.dll ! memcpy
Qt5Core.dll ! QByteArray::reallocData + 0x7a - qbytearray.cpp:1840
libkritalibbrush.dll ! QByteArray::detach + 0x23 - qbytearray.h:521
libkritalibbrush.dll ! QByteArray::operator[] - qbytearray.h:627
libkritalibbrush.dll ! KisGbrBrush::init + 0xd6c - kis_gbr_brush.cpp
libkritalibbrush.dll ! KisGbrBrush::KisGbrBrush + 0xaf - kis_gbr_brush.cpp:85
libkritalibbrush.dll ! KisImagePipeBrush::initFromData + 0x418 - kis_imagepipe_brush.cpp:325
libkritalibbrush.dll ! KisImagePipeBrush::loadFromDevice + 0x22 - kis_imagepipe_brush.cpp:279
libkritaresources.dll ! KoResourceBundle::loadResource + 0x337 - KoResourceBundle.cpp:528
libkritaresources.dll ! KisBundleStorage::loadVersionedResource + 0x76d - KisBundleStorage.cpp:150
libkritaresources.dll ! KisStoragePlugin::resource + 0x1d2 - KisStoragePlugin.cpp:61
libkritaresources.dll ! KisVersionedStorageIterator::resourceImpl + 0x2a - KisResourceStorage.cpp:572
libkritaresources.dll ! KisResourceStorage::ResourceIterator::resource + 0x79 - KisResourceStorage.cpp:498
libkritaresources.dll ! KisResourceCacheDb::addResources + 0x13a - KisResourceCacheDb.cpp:1072
libkritaresources.dll ! KisResourceCacheDb::addStorage + 0x1407 - KisResourceCacheDb.cpp:1502
libkritaresources.dll ! KisResourceLocator::addStorage + 0x41e - KisResourceLocator.cpp:798
kritaresourcemanager.dll ! DlgBundleManager::addBundle + 0x815 - dlg_bundle_manager.cpp:264

Writing loaded PNG for MD5 checksum match:

libzlib.dll ! longest_match - deflate.c
libzlib.dll ! deflate_slow + 0x115 - deflate.c:2020
libzlib.dll ! deflate + 0x9fb - deflate.c:1057
Qt5Gui.dll ! png_text_compress + 0xb1 - pngwutil.c:580
Qt5Gui.dll ! png_write_iTXt + 0x140 - pngwutil.c:1690
Qt5Gui.dll ! png_write_info + 0x3a5 - pngwrite.c:300
Qt5Gui.dll ! QPNGImageWriter::writeImage + 0xb07 - qpnghandler.cpp:1093
Qt5Gui.dll ! QPNGImageWriter::writeImage + 0x1c - qpnghandler.cpp:181
Qt5Gui.dll ! write_png_image + 0x5e - qpnghandler.cpp:1215
Qt5Gui.dll ! QPngHandler::write + 0x22 - qpnghandler.cpp:1262
Qt5Gui.dll ! QImageWriter::write + 0x2b8 - qimagewriter.cpp:785
Qt5Gui.dll ! QImageData::doImageIO + 0x30 - qimage.cpp:3770
Qt5Gui.dll ! QImage::save + 0x6f - qimage.cpp:3758
libkritaresources.dll ! KisResourceCacheDb::addResource + 0xe88 - KisResourceCacheDb.cpp:1016
libkritaresources.dll ! KisResourceCacheDb::addResources + 0x4cc - KisResourceCacheDb.cpp:1078
libkritaresources.dll ! KisResourceCacheDb::addStorage + 0x1407 - KisResourceCacheDb.cpp:1502
libkritaresources.dll ! KisResourceLocator::addStorage + 0x41e - KisResourceLocator.cpp:798
kritaresourcemanager.dll ! DlgBundleManager::addBundle + 0x815 - dlg_bundle_manager.cpp:264

On Preset activation

Open the brush selector

CPU Time
1 of 2: 53.9%  (0.403s of 0.748s)

libzlib.dll ! inflate_fast - inffast.c
libzlib.dll ! inflate + 0x1de9 - inflate.c:1067
Qt5Gui.dll ! png_inflate + 0xa4 - pngrutil.c:565
Qt5Gui.dll ! png_decompress_chunk + 0x165 - pngrutil.c:679
Qt5Gui.dll ! png_handle_iTXt + 0x249 - pngrutil.c:2815
Qt5Gui.dll ! png_read_info + 0x2d2 - pngread.c:255
Qt5Gui.dll ! QPngHandlerPrivate::readPngHeader + 0x152 - qpnghandler.cpp:604
Qt5Gui.dll ! QPngHandlerPrivate::readPngImage + 0x3f - qpnghandler.cpp:676
Qt5Gui.dll ! QImageReader::read + 0x203 - qimagereader.cpp:1290
Qt5Gui.dll ! QImageReader::read + 0x24 - qimagereader.cpp:1231
Qt5Gui.dll ! QImage::load + 0x45 - qimage.cpp:3653
libkritaresources.dll ! KisResourceQueryMapper::getThumbnailFromQuery + 0x48e - KisResourceQueryMapper.cpp:70
libkritaresources.dll ! KisResourceQueryMapper::variantFromResourceQuery + 0x232 - KisResourceQueryMapper.cpp:196
libkritaresources.dll ! KisAllResourcesModel::data + 0x9c - KisResourceModel.cpp:110
Qt5Core.dll ! QSortFilterProxyModel::data + 0x65 - qsortfilterproxymodel.cpp:2294
Qt5Core.dll ! QSortFilterProxyModel::data + 0x65 - qsortfilterproxymodel.cpp:2294
libkritaresources.dll ! QModelIndex::data + 0x22 - qabstractitemmodel.h:460
libkritaresources.dll ! KisResourceThumbnailCache::getImage + 0x2d8 - KisResourceThumbnailCache.cpp:188
libkritaui.dll ! KisPresetDelegate::paint + 0xf7 - kis_preset_chooser.cpp:88

Select “Photo B2”

The same spurious detach as on Loading

CPU Time
1 of 4: 97.3%  (1.672s of 1.719s)

ucrtbase.dll ! memcpy
Qt5Core.dll ! QByteArray::reallocData + 0x7a - qbytearray.cpp:1840
libkritalibbrush.dll ! QByteArray::detach + 0x23 - qbytearray.h:521
libkritalibbrush.dll ! QByteArray::operator[] - qbytearray.h:627
libkritalibbrush.dll ! KisGbrBrush::init + 0xd6c - kis_gbr_brush.cpp
libkritalibbrush.dll ! KisGbrBrush::KisGbrBrush + 0xaf - kis_gbr_brush.cpp:85
libkritalibbrush.dll ! KisImagePipeBrush::initFromData + 0x418 - kis_imagepipe_brush.cpp:325
libkritalibbrush.dll ! KisImagePipeBrush::loadFromDevice + 0x22 - kis_imagepipe_brush.cpp:279
libkritaresources.dll ! KoResourceBundle::loadResource + 0x337 - KoResourceBundle.cpp:528
libkritaresources.dll ! KisBundleStorage::loadVersionedResource + 0x76d - KisBundleStorage.cpp:150
libkritaresources.dll ! KisStoragePlugin::resource + 0x1d2 - KisStoragePlugin.cpp:61
libkritaresources.dll ! KisResourceStorage::resource + 0x14 - KisResourceStorage.cpp:199
libkritaresources.dll ! KisResourceLocator::resource + 0x27e - KisResourceLocator.cpp:321
libkritaresources.dll ! KisResourceLocator::resourceForId + 0x4a - KisResourceLocator.cpp:399
libkritaresources.dll ! KisAllResourcesModel::resourcesForMD5 + 0x56e - KisResourceModel.cpp:381
libkritaresources.dll ! (anonymous namespace)::GlobalResourcesSource::resourcesForMD5 + 0x10 - KisGlobalResourcesInterface.cpp:41
libkritaresources.dll ! KisResourcesInterface::ResourceSourceAdapter::bestMatch + 0x4e - KisResourcesInterface.cpp:76
libkritalibbrush.dll ! KisResourcesInterface::TypedResourceSourceAdapter<KisBrush>::bestMatch + 0x6e - KisResourcesInterface.h:132
libkritalibbrush.dll ! KisPredefinedBrushFactory::createBrushModelImpl + 0x200 - kis_predefined_brush_factory.cpp:91
libkritalibbrush.dll ! KisPredefinedBrushFactory::createBrush + 0x48 - kis_predefined_brush_factory.cpp:64
libkritalibbrush.dll ! KisBrushRegistry::createBrush + 0x107 - kis_brush_registry.cpp:64
libkritalibbrush.dll ! KisBrush::fromXMLLoadResult + 0x49 - kis_brush.cpp:464
libkritalibpaintop.dll ! KisBrushOptionProperties::prepareLinkedResourcesImpl + 0x6c - kis_brush_option.cpp:66
libkritalibpaintop.dll ! KisPaintopPropertiesCanvasResourcesBase::prepareLinkedResources<KisPinnedSharedPtr<KisPaintOpSettings>> + 0x48 - KisPaintopPropertiesBase.h:62
libkritalibpaintop.dll ! KisBrushBasedPaintOp::prepareLinkedResources + 0x87 - kis_brush_based_paintop.cpp:128
kritacolorsmudgepaintop.dll ! func@0x1800073b0 + 0x4e
kritacolorsmudgepaintop.dll ! KisSimplePaintOpFactory<KisColorSmudgeOp, KisColorSmudgeOpSettings, KisColorSmudgeOpSettingsWidget>::prepareLinkedResources + 0x50 - kis_simple_paintop_factory.h:193
libkritaimage.dll ! KisPaintOpPreset::linkedResources + 0x113 - kis_paintop_preset.cpp:529
libkritaresources.dll ! KoResource::requiredResources + 0x48 - KoResource.cpp:238
libkritaresources.dll ! KisResourceLocator::loadRequiredResources + 0x45 - KisResourceLocator.cpp:156
libkritaresources.dll ! KisResourceLocator::resource + 0x3b4 - KisResourceLocator.cpp:326
libkritaresources.dll ! KisResourceLocator::resourceForId + 0x4a - KisResourceLocator.cpp:399
libkritaresources.dll ! KisAllResourcesModel::resourceForId + 0x14 - KisResourceModel.cpp:199
libkritaresources.dll ! KisAllResourcesModel::resourceForIndex + 0xf5 - KisResourceModel.cpp:192
libkritaresources.dll ! KisAllResourcesModel::resourceForIndex + 0x10 - KisResourceModel.cpp
libkritaresources.dll ! KisResourceModel::resourceForIndex + 0x58 - KisResourceModel.cpp:754
libkritaresources.dll ! KisResourceModel::resourceForIndex + 0x18 - KisResourceModel.cpp:752
libkritaresources.dll ! KisTagFilterResourceProxyModel::resourceForIndex + 0x6c - KisTagFilterResourceProxyModel.cpp:87
libkritaresourcewidgets.dll ! KisResourceItemChooser::resourceFromModelIndex + 0x2b - KisResourceItemChooser.cpp:599
libkritaresourcewidgets.dll ! KisResourceItemChooser::activate + 0x2b - KisResourceItemChooser.cpp:509

Hiccups on painting

<to be investigated, the backtraces are not obvious>

3 Likes

Hi, @RamonM, @emilm, @Mythmaker and others!

Could you please test the packages from this MR, when they are ready?

New Link: Pipeline · Graphics / Krita · GitLab

I have fixed two performance issues when loading the V7 bundle and, specifically, “Photo B2” brush preset. Does it look better in this build?

How to test:

  1. Go to %appdata%\Krita folder (or ~/.local/share/krita)
  2. Remove (or move to a safe space the two files):
    • memileo_360light_07.bundle
    • resourcecache.sqlite
  3. Start Krita (it will rescan the resources)
  4. Try to import the bundle again → it should happen much quicker
  5. Open the brush selector → it should open much faster
  6. try to activate “Photo B2” preset → it should activate faster (but not extremely fast)

Please take it into account that removing “resourcecache.sqlite” is mandatory, since the buggy and heavy data has been written to the database, making brush selection/activation much slower.

6 Likes

Just tested out on my PC. It is probably around 3x faster importing the brush bundle (counting without a timer, its down from 22 seconds to 6 seconds) and canvas loads in a lot faster (since I have brush presets open with memileo brushes on my workspace it can be observed upon creating a canvas). Some brushes still can get a bit laggy upon clicking (Photo-A and Photo-I to name a few). A lot better overall though, thank you for this fix!

3 Likes

Hi. Tested the appimage.

Krita has encountered an internal error:

SAFE ASSERT (krita): "image.format() == QImage::Format_ARGB32" in file /builds/graphics/krita/libs/brush/KisColorfulBrush.cpp, line 69

Please report a bug to developers!

Press Ignore to try to continue.
Press Abort to see developers information (all unsaved data will be lost)
Krita has encountered an internal error:

SAFE ASSERT (krita): "data" in file /builds/graphics/krita/plugins/paintops/libpaintop/kis_brush_option_widget.cpp, line 111

Please report a bug to developers!

Press Ignore to try to continue.
Press Abort to see developers information (all unsaved data will be lost)

Debug messages for missing resources? (Same messages appear in terminal with 5.2.2 after removing resource cache.)


Import bundle:

  • MR version - ca 8s
  • 5.2.2 - ca 35s

Selecting PHOTO B 2 for the first time after Krita startup

  • MR version - ca 1-3s
  • 5.2.2 - ca 4s
    or pretty much instant if started with a rgba brush selected and painted with on previous run for both versions.

And also Krita starts so much faster than I’m used to on second run. (15-20s compared to about 1min25s in 5.2.2) :slight_smile: Cheers!

2 Likes

Do you have any idea, what brush preset could cause this error? It usually happens when indexed image is used for the brush tip.

(if not, it is not a problem, I will try to investigate using the provided log)

I found it happens with these resources:
Wet_Brush_Pack_v0.13.bundle 🖌 Digital Wet Brush — Bundle —

FT_Gradient_01.png
From here TheFlow's Mixer / Concept Brushes - v1.1 - WORK IN PROGRESS! (Krita 5)
When it’s inside the bundle there’s no safe assert though.


This is a new system isn´t it? i remember @dkazakov was using DKX where X is a number.
I need help for testing or do you have enough feedback @dkazakov and @emilm ?

Here is the Linux build:
https://invent.kde.org/graphics/krita/-/jobs/1722500/artifacts/download

And here is the one for Windows:
https://invent.kde.org/graphics/krita/-/jobs/1722502/artifacts/download

At least if I’m not mistaken.
After @emilm’s hint, I searched again and corrected the links above.
The new system is not so simple as the former was, sorry.

Michelist

1 Like

@RamonM I downloaded the one ending with -build if that’s what you meant?

@Michelist Are these the same as Dmitry linked to or regular nightlies? They’ve got a different commit string at the end.

1 Like

Thank you for the heads-up, the links above are the corrected links.

Michelist

2 Likes

HI, all!

I have merged that speedup patch into master and krita/5.2, so the builds will also be available tomorrow in the nightly builds:

Index of /ci-builds/graphics/krita

Theoretically, we could improve speed even further by not embedding the brush tips into the presets, when they are saved in bundles, but it will need a bit of quite dangerous redesign, so it cannot be done in 5.2 branch anyway.

The main reason for the slowdown is the usage of piped GBR brushes with about 600 embedded brushes. The problem is that GBR format is not compressed by specification, hence, when we embed that into a .kpp preset, it takes too much time to compress/uncompress it.

The temporary workarounds would be:

  1. Decrease the number of embedded GBR brushes (I’m not sure if it is a good idea)

  2. Manually strip embedded resources from the brush preset. It will have the following consequences though:

    • you will not be able to manually extract this .kpp preset from the bundle’s zip file without breaking the preset (I’m not sure anyone actually cares about that)
    • When editing an existing preset it may skip the linked resources. I don’t actually know why this code exists there, but it may cause an issue.

PS:
I can try making a testing and really hackish version of Krita that would skip saving the linked resources based on an environment variable. It will not handle issues gracefully though, so one would have to test the bundles before publishing manually.

8 Likes

brilliant & useful

Nice! :slight_smile:

If one makes a tweak and saves as a new brush preset, would they then get embedded again?

Do you think these workarounds would also get rid of the occasional freezes/hiccups when painting with these heavy brush tips?
Otherwise is there a certain .gih file size or number of brush images one should aim to keep under when creating an animated brush tip?

The loading definitely seemed faster on the test build (on linux). The main issue I’m having is these brushes are quickly saturating the available memory. That seems to happen on both the stable and test builds.

When I first tested them a couple of days ago, I started painting and all seemed to be working well - the strokes laid out smoothly with decent performance. Then my system suddenly ground to a halt; not like a crash, but effectively frozen. I ended up doing a hard reset to get out of it.

Later I tried again with the system monitor open. I found that ram use jumped with each stroke until it was completely saturated, then spilled over into swap and saturated that - which locked up my system again.

I should note though - My system is pretty old now and only 8gb ram so I had limited scope to observe the rise before it maxed out.

I don’t think it’s the presets or the file size of the brushes; I tested my own largest brush which is also a .gih with lightness, and very large at 42mb in size. I didn’t see the same incremental rise in memory use. That brush only has about 5 or 6 instances though; So I’m wondering if it’s related to the number of layers in the tube? :thinking:

2 Likes

Do you think these workarounds would also get rid of the occasional freezes/hiccups when painting with these heavy brush tips?

I can make you a test build with instructions how to check that if you promize not to publish the resulting bundle anywhere (otherwise we’ll have to support this king of “broken” bundles officially) :slight_smile:

Did you test that before Krita 5.0 or after that?

Haha okay. :slight_smile: (I’ll make sure to delete the bundle after testing.)

I meant in the current stable 5.2.2

I did a few different tests to try and narrow things down, but I specifically tested that brush with one of emilm’s presets; I didn’t see an incremental rise in memory use when I used that combination, even though it’s a similarly huge file size and the same format.