Bug 441350

Summary: Brushes works wrong, after selecting another pattern and reselecting the original one, they works like the should
Product: [Applications] krita Reporter: anno2300
Component: Brush enginesAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, halla, hgmestre, raincolee, ss93078, tamtamy.tymona, tomtomtomreportingin, uenvironments
Priority: NOR Keywords: regression, release_blocker
Version: 5.0.0-beta2   
Target Milestone: ---   
Platform: Other   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Image to see the diffenece how the brushes works afer installation and after reselect the pattern
attachment-20155-0.html

Description anno2300 2021-08-22 08:56:22 UTC
Created attachment 140932 [details]
Image to see the diffenece how the brushes works afer installation and after reselect the pattern

Some brush presets don't work correct like they should for the default resources and also in some other bundles.

To make it work, you have to select another pattern in the brush editor and then go back to the right pattern before. This changes the behavior of the whole brush:
j) WaterC Spread (for this brush this is very weird, cause it uses no pattern! you have to enable a pattern, select one, deactivate it, and it is fixed)
j) WaterC Spread pattern
j) Waterpaint Hard Edges

Presets from external bundles:
Crayons_V1: h) Crayon 10 Blend-Smear
Charcoal_KA: h) Charcoal 10 Willow BlockGrainy

There are many people in the Forum that has the same problem for exactly the same brushes. I attach some images with before/after brushstrokes.

In addition in the default resources: 
y) Texture Reptile: doesn’t work, the pattern is not selected: 22_texture_reptile.png. But it is available in Krita 5. Easy to fix, but better it works from installation for all people.

In the Impression_v3:
v) Texture Impressionism Wet Blend-Big: looks weird, maybe cause in the smudge engine it set to „Color Image“ activated by default now, and this was not in Krita 4. Maybe for the same effect in Krita 4 „Alpha Mask“ is required? If brushes from Krita 4 that uses the smudge engine and a capable brush tip for RGBA now have all RGBA activated in Krita 5 as standard, tis might be a bitter problem for other bundle creators. I hope you understand what i mean.

Software: macOS Big Sur 11.5.1
Comment 1 Halla Rempt 2021-08-24 07:53:42 UTC
*** Bug 441437 has been marked as a duplicate of this bug. ***
Comment 2 Halla Rempt 2021-08-27 13:26:45 UTC
Looks like there's something weird with determining whather a brush is has a masking brush.
Comment 3 Halla Rempt 2021-08-28 11:30:31 UTC
Okay, preliminary conclusions:

* There are two brush tips with the same md5sum, cf1bc7415af3103afcd82f58a2e6fe18.
* But they have two different filenames: square_rough.png (krita4 bundle) and 3_texture.png (krita 3 bundle).
* At some point, because we select the first resource with the correct md5sum, 3_texture.png gets added to the thread local resource snapshot. However, the paintop option still only selects by filename, and so looks for square_rough.png, which isn't in there.

Two options: 

* return all resources with the right type and filename in KisAllResourceModel::resourceByName/FileName/MD5, and add them to the local snapshot
* change the paintop options to add the relevant keys for md5sum to the option's settings object, and select from the local resource shapshot by md5sum.
Comment 4 anno2300 2021-08-28 12:05:11 UTC
About your Comment 3, is it not related to https://bugs.kde.org/show_bug.cgi?id=441347 ? Or is there the same problem? Cause in the bug 441347 i tell which bugs are deactivated in Krita 4 Bundle cause it is in Krita 3, but this are also deactivated and not avaiable in the library. There are a bunch of overlapping brushes in Krita 4 and 3 Resources and all from the Krita 4 Bundle are deactivated cause the md5sum checks the Krita 3 bundle first, right?
Comment 5 anno2300 2021-08-28 12:08:46 UTC
I'm sorry, i mean "which brushes are deactivated in Krita 4 Bundle", and not "bugs". Don't know how to edit a comment ;-)
Comment 6 Halla Rempt 2021-08-28 13:07:58 UTC
When looking for dependent resources -- i.e. brush tips that paintop preset needs -- we don't care whether the resource we find is active or not. Inactive resources aren't shown in the resource selectors, but they can be loaded and used.

When loading a bundle, we load all resources, even if there is already a resource with the same md5sum in the database, because resources are considered for md5sum + storage.

So, the query for resource by md5sum can return either resource, but returns the first one in the database. The problem is that we're still in places are looking for resources by filename as well.

In any case, I think I'm making progress, and I'm just documenting my ongoing progress :-)
Comment 7 IForce73 2021-08-28 16:40:02 UTC
Created attachment 141106 [details]
attachment-20155-0.html

That's quite interesting. I really love to read about the progress :-)


Halla Rempt <bugzilla_noreply@kde.org> schrieb am Sa., 28. Aug. 2021, 15:08:

> https://bugs.kde.org/show_bug.cgi?id=441350
>
> --- Comment #6 from Halla Rempt <halla@valdyas.org> ---
> When looking for dependent resources -- i.e. brush tips that paintop preset
> needs -- we don't care whether the resource we find is active or not.
> Inactive
> resources aren't shown in the resource selectors, but they can be loaded
> and
> used.
>
> When loading a bundle, we load all resources, even if there is already a
> resource with the same md5sum in the database, because resources are
> considered
> for md5sum + storage.
>
> So, the query for resource by md5sum can return either resource, but
> returns
> the first one in the database. The problem is that we're still in places
> are
> looking for resources by filename as well.
>
> In any case, I think I'm making progress, and I'm just documenting my
> ongoing
> progress :-)
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 8 Halla Rempt 2021-09-02 13:59:46 UTC
Git commit 91bbbd5ffd64c918cb882815f71c097c8c220bf9 by Halla Rempt.
Committed on 02/09/2021 at 13:59.
Pushed by rempt into branch 'master'.

Fix loading legacy brush masks

If there are two resources in two storages that have the same
md5sum (square_rough.png and texture_3.png), we need to make
sure that the one with the filename stored in the preset can
be found, so now resources(md5, filename, name) returns all
matching resources.
Related: bug 441347

M  +17   -6    libs/brush/kis_predefined_brush_factory.cpp
M  +25   -22   libs/image/brushengine/kis_paintop_preset.cpp
M  +3    -0    libs/image/brushengine/kis_paintop_settings.cpp
M  +1    -1    libs/image/kis_properties_configuration.cc
M  +3    -3    libs/psdutils/psd.h
M  +7    -6    libs/resources/KisGlobalResourcesInterface.cpp
M  +3    -4    libs/resources/KisLinkedResourceWrapper.h
M  +36   -32   libs/resources/KisLocalStrokeResources.cpp
M  +1    -0    libs/resources/KisRequiredResourcesOperators.h
M  +33   -13   libs/resources/KisResourceModel.cpp
M  +3    -3    libs/resources/KisResourceModel.h
M  +63   -23   libs/resources/KisResourcesInterface.h
M  +19   -5    libs/resources/KoResourceServer.h
M  +0    -1    libs/resourcewidgets/dbexplorer/DlgDbExplorer.cpp
M  +4    -1    libs/ui/utils/KisDitherUtil.cpp
M  +12   -4    libs/ui/widgets/KisDitherWidget.cpp
M  +0    -1    libs/ui/widgets/kis_preset_chooser.cpp
M  +12   -3    libs/ui/widgets/kis_workspace_chooser.cpp
M  +11   -2    plugins/filters/gradientmap/KisGradientMapFilterConfiguration.cpp
M  +9    -1    plugins/filters/palettize/palettize.cpp
M  +7    -2    plugins/generators/pattern/kis_wdg_pattern.cpp
M  +5    -1    plugins/generators/pattern/patterngenerator.cpp
M  +1    -0    plugins/paintops/libpaintop/KisMaskingBrushOption.cpp
M  +2    -3    plugins/paintops/libpaintop/KisTextureMaskInfo.cpp
M  +0    -2    plugins/paintops/libpaintop/kis_brush_option.cpp
M  +15   -4    plugins/paintops/libpaintop/kis_linked_pattern_manager.cpp
M  +9    -6    plugins/paintops/libpaintop/kis_texture_option.cpp

https://invent.kde.org/graphics/krita/commit/91bbbd5ffd64c918cb882815f71c097c8c220bf9
Comment 9 Halla Rempt 2021-09-07 09:16:45 UTC
Git commit 8628fd22c755584ef3606732bf3dbe6af8e2b904 by Halla Rempt.
Committed on 07/09/2021 at 09:02.
Pushed by rempt into branch 'krita/5.0'.

Fix loading legacy brush masks

If there are two resources in two storages that have the same
md5sum (square_rough.png and texture_3.png), we need to make
sure that the one with the filename stored in the preset can
be found, so now resources(md5, filename, name) returns all
matching resources.
Related: bug 441347
(cherry picked from commit 91bbbd5ffd64c918cb882815f71c097c8c220bf9)

M  +17   -6    libs/brush/kis_predefined_brush_factory.cpp
M  +25   -22   libs/image/brushengine/kis_paintop_preset.cpp
M  +3    -0    libs/image/brushengine/kis_paintop_settings.cpp
M  +1    -1    libs/image/kis_properties_configuration.cc
M  +3    -3    libs/psd/psd.h
M  +7    -6    libs/resources/KisGlobalResourcesInterface.cpp
M  +3    -4    libs/resources/KisLinkedResourceWrapper.h
M  +36   -33   libs/resources/KisLocalStrokeResources.cpp
M  +1    -0    libs/resources/KisRequiredResourcesOperators.h
M  +33   -13   libs/resources/KisResourceModel.cpp
M  +3    -3    libs/resources/KisResourceModel.h
M  +63   -23   libs/resources/KisResourcesInterface.h
M  +19   -5    libs/resources/KoResourceServer.h
M  +0    -1    libs/resourcewidgets/dbexplorer/DlgDbExplorer.cpp
M  +4    -1    libs/ui/utils/KisDitherUtil.cpp
M  +12   -4    libs/ui/widgets/KisDitherWidget.cpp
M  +0    -1    libs/ui/widgets/kis_preset_chooser.cpp
M  +12   -3    libs/ui/widgets/kis_workspace_chooser.cpp
M  +11   -2    plugins/filters/gradientmap/KisGradientMapFilterConfiguration.cpp
M  +9    -1    plugins/filters/palettize/palettize.cpp
M  +7    -2    plugins/generators/pattern/kis_wdg_pattern.cpp
M  +5    -1    plugins/generators/pattern/patterngenerator.cpp
M  +1    -0    plugins/paintops/libpaintop/KisMaskingBrushOption.cpp
M  +2    -3    plugins/paintops/libpaintop/KisTextureMaskInfo.cpp
M  +0    -2    plugins/paintops/libpaintop/kis_brush_option.cpp
M  +15   -4    plugins/paintops/libpaintop/kis_linked_pattern_manager.cpp
M  +9    -6    plugins/paintops/libpaintop/kis_texture_option.cpp

https://invent.kde.org/graphics/krita/commit/8628fd22c755584ef3606732bf3dbe6af8e2b904
Comment 10 tomtomtomreportingin 2021-10-11 06:01:15 UTC
I'm sorry, but patterns are still buggy in some way with at least some included brushes and with certain bundled resources.

Some of these buggy behaviors could probably pertain to at least three different currently closed bug reports, but I'm reopening just this one as it's probably the most general one.

Here's the situation:

5.0 beta 2:
h) Chalk Details - No pattern until changing any setting.
g) Dry Brushing - No pattern until changing any setting.
i) Wet Textured Soft - No pattern until changing any setting.
k) Blender Textured Soft - No pattern until changing any setting, but wrongly loads 01_canvas after.
y) Texture Wood Fiber - No pattern until changing any setting, but wrongly loads 01_canvas after.
Moo Zip brushes (download the Moo Ink bundle from https://saeger.art/mojo-moo/bundles by clicking the orange BUNDLE button): Fine until changing settings, then wrongly loads 01_canvas after.

master 45ea106:
h) Chalk Details - No pattern until changing any setting, but wrongly loads 01_canvas after.
g) Dry Brushing - No pattern until changing any setting, but wrongly loads 01_canvas after.
i) Wet Textured Soft - No pattern until changing any setting, but wrongly loads 01_canvas after.
k) Blender Textured Soft - No pattern until changing any setting, but wrongly loads 01_canvas after.
y) Texture Wood Fiber - No pattern until changing any setting, but wrongly loads 01_canvas after.
Moo Zip brushes: Fine until changing settings, then wrongly loads 01_canvas after.
Comment 11 anno2300 2021-10-12 08:53:23 UTC
This is the same for me, many brushes are broken now. It looks like embeeded patterns in brushtips still aren't loaded correctly for the beta2?

To add some other brushes that are broken and don't have a pattern now:
g) Dry Textured Creases
g) Dry Brushing
g) Dry Roller
and more...

If you reselect the pattern in the Library, the pattern works.
Comment 12 Yu-Hsuan Lai 2021-12-01 01:49:04 UTC
Buggy for me too. 5.0.0-beta2 (git a642eb0).

Video demo for the bug: https://krita-artists.org/t/color-smudge-brushs-ratio-setting-bug-with-video-evidence/32580/4
Comment 13 wolthera 2021-12-04 12:16:07 UTC
*** Bug 446470 has been marked as a duplicate of this bug. ***
Comment 14 Dmitry Kazakov 2021-12-06 11:29:38 UTC
As far as I can tell the following happens:

1) The pattern itself is loaded into the brush correctly
2) But the pattern selector doesn't see this resource (probably because it is marked as temporary)
Comment 15 Bug Janitor Service 2021-12-06 13:50:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1202
Comment 16 Dmitry Kazakov 2021-12-06 15:16:20 UTC
Git commit 783e051031e4ddac279960d2332225a57ac7a408 by Dmitry Kazakov.
Committed on 06/12/2021 at 13:48.
Pushed by dkazakov into branch 'krita/5.0'.

Fix embedded resources to appear in the resource model

All the code that manipuilates resources in Krita is expected to do that
via KisResourceModel. It guarantees that the internal model indexes are
valid and up-to-date.

Though we have one notable exception, that is, embedded resources. They
are loaded by KisResourceLocator internally, when some uncached resource
is loaded. In such a case the model should be notified to update its
query.

M  +3    -0    libs/resources/KisResourceLocator.cpp
M  +6    -0    libs/resources/KisResourceLocator.h
M  +18   -0    libs/resources/KisResourceModel.cpp
M  +17   -0    libs/resources/KisResourceModel.h

https://invent.kde.org/graphics/krita/commit/783e051031e4ddac279960d2332225a57ac7a408
Comment 17 Dmitry Kazakov 2021-12-06 15:16:42 UTC
Git commit d1d9e8f54f874316709497e20a7f56994f20c9d5 by Dmitry Kazakov.
Committed on 06/12/2021 at 15:16.
Pushed by dkazakov into branch 'master'.

Fix embedded resources to appear in the resource model

All the code that manipuilates resources in Krita is expected to do that
via KisResourceModel. It guarantees that the internal model indexes are
valid and up-to-date.

Though we have one notable exception, that is, embedded resources. They
are loaded by KisResourceLocator internally, when some uncached resource
is loaded. In such a case the model should be notified to update its
query.

M  +3    -0    libs/resources/KisResourceLocator.cpp
M  +6    -0    libs/resources/KisResourceLocator.h
M  +18   -0    libs/resources/KisResourceModel.cpp
M  +17   -0    libs/resources/KisResourceModel.h

https://invent.kde.org/graphics/krita/commit/d1d9e8f54f874316709497e20a7f56994f20c9d5
Comment 18 Protoniv 2021-12-07 01:32:49 UTC
Hi, just tested 5.0.0-beta5-783e051031 on win10, and looked up the bugged brushes listed here, now their pattern can be found correctly.
However some brushes still not apply their pattern until changing any setting.
f) Dry Roller
g) Dry Brushing
g) Dry Textured Creases
h) Chalk Details
i) Wet Textured Soft
i)Wet Paint
Comment 19 Bug Janitor Service 2021-12-07 09:03:03 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1206
Comment 20 Dmitry Kazakov 2021-12-07 09:07:10 UTC
Git commit 156f614b4d1f40b56dad3ff62a127483f2aa4c0c by Dmitry Kazakov.
Committed on 07/12/2021 at 09:05.
Pushed by dkazakov into branch 'master'.

Fix loading texture patterns in presets with empty PatternMD5 field

Some old Deevad's presets have empty PatternMD5 field set, we shouldn't
skip them from loading, because they still have both, the filename and
the (embedded) pattern itself.

M  +3    -1    plugins/paintops/libpaintop/kis_texture_option.cpp

https://invent.kde.org/graphics/krita/commit/156f614b4d1f40b56dad3ff62a127483f2aa4c0c
Comment 21 Dmitry Kazakov 2021-12-07 09:19:48 UTC
Git commit 5b6b0401d634cb3307e10c6791d681f0cd02e31a by Dmitry Kazakov.
Committed on 07/12/2021 at 09:19.
Pushed by dkazakov into branch 'krita/5.0'.

Fix loading texture patterns in presets with empty PatternMD5 field

Some old Deevad's presets have empty PatternMD5 field set, we shouldn't
skip them from loading, because they still have both, the filename and
the (embedded) pattern itself.
(cherry picked from commit 156f614b4d1f40b56dad3ff62a127483f2aa4c0c)

M  +3    -1    plugins/paintops/libpaintop/kis_texture_option.cpp

https://invent.kde.org/graphics/krita/commit/5b6b0401d634cb3307e10c6791d681f0cd02e31a
Comment 22 Dmitry Kazakov 2021-12-07 10:36:35 UTC
Hi, Protoniv!

This build (when it completes) will contain the fix for the latest bug you reported: 

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

Please test it when the build is ready :)
Comment 23 Protoniv 2021-12-07 12:09:21 UTC
Hi, Dmitry!
Just tested the patched build with these default brushes and it works great! Thank you very much!
Comment 24 Dmitry Kazakov 2021-12-08 11:05:02 UTC
You are welcome! :)