Bug 412720 - Pattern overlay textures are replaced by black upon reopening document
Summary: Pattern overlay textures are replaced by black upon reopening document
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: layer styles (show other bugs)
Version: 4.2.7
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-08 04:27 UTC by ntjunco125
Modified: 2021-10-21 13:11 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example of the black "textures" created by this bug. (38.48 KB, image/png)
2019-10-08 04:27 UTC, ntjunco125
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ntjunco125 2019-10-08 04:27:51 UTC
Created attachment 123083 [details]
Example of the black "textures" created by this bug.

Certain textures default to black whenever a document with the "pattern overlay" layer style is reopened.

STEPS TO REPRODUCE
1. Apply the "pattern overlay" layer style to any layer, using a texture with relatively few values between black and white (happens with near certainty with textures consisting of only #000000 black and #FFFFFF white, but also occurs to textures such "Hexacol BW By Tarkan")
2. Save the .kra document and close.
3. Reopen the document.

OBSERVED RESULT
Document replaces the overlay texture with a featureless black one.
The black "texture" is added to the texture menu with the same exact path as the intended texture, and both of them exist in the menu at the same time.

EXPECTED RESULT
Document retains the correct overlay texture.
No superfluous "textures" are added to the menu.

SOFTWARE/OS VERSIONS
Windows 10 Professional

ADDITIONAL INFORMATION
This has been a problem since the 4.1.x versions, probably earlier.
Since I work extensively with aliased, pixel-perfect textures for my trade, this is of high importance to me.
Comment 1 Halla Rempt 2019-10-10 08:54:45 UTC
Hi,

Thanks for your report. I can reproduce the issue.
Comment 2 Ahab Greybeard 2019-10-10 11:35:28 UTC
There are additional related complications:

When this happens, the black texture appears in the Patterns docker and also in the patterns menu for the Brush Editor patterns parameter selector menu.
It happens with default installation textures as well as personal resource textures.
I think it may be related to transparency in the pattern because it doesn't happen with solid colour patterns.

If you Close and Quit and restart, if you'd selected a texture from the standard default installation, the full path of the texture refers to the previous /tmp/.mount-- location. This is probably because the pattern location is stored in the .kra file though it can't be correct for future sessions.

There is a similar problem (but no black patterns) if you use a default installation pattern fill on a Fill layer and then Save, Close and restart then reopen the image: the pattern is not shown.
Comment 3 Halla Rempt 2019-10-16 12:40:39 UTC
I think this has always been broken. 3.0 gives as output

krita.general: WARNING: Saved pattern doesn't have a UUID, generating...
krita.general: patternFileName = "/home/boud/.local/share/krita/patterns/hexacolBW__2.pat" pattern->name() = "Hexacol BW By Tarkan"
Comment 4 Bug Janitor Service 2021-10-11 11:19:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1089
Comment 5 Dmitry Kazakov 2021-10-11 11:30:34 UTC
The problem happens because hexacolBW__2.pat pattern has transparency support, but ASL doesn't seem to support that. Or at least our implementation of it doesn't writing Alpha into ASL.
Comment 6 Bug Janitor Service 2021-10-11 15:03:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1091
Comment 7 Dmitry Kazakov 2021-10-14 12:38:12 UTC
Git commit 87df1d81b13d1a1df7e3e1529041c0a055cb94f6 by Dmitry Kazakov.
Committed on 14/10/2021 at 12:36.
Pushed by dkazakov into branch 'master'.

Fix double-embedding of the resources into the document

Original desing of the do document-storage was supposed to store the
embedded resources in memory, while the document is loaded and unload
them from the memory, as soon as the document is unloaded. But after
July's embed-all refactoring its meaning has changed. Instead it is
used to store the resources that should be embedded into the document
separately.

Therefore, now this storage of the resources must not include the
resources that are embedded via other means, e.g. asl layer styles
or asl/psd patterns.

Right now, the only place where this storage is really used for
embedding stuff is KisPaletteEditor.

If we want to recover the idea of "a memory-only storage that
unloads the resources on document unloading", we need to make a
separate storage for such temorary data.

The commit doesn't fix the bug linked, but it removes warnings
about trying to save non-serializable resources into a persistent
storage.

M  +0    -3    libs/image/KisResourceCollectorVisitor.h
M  +3    -0    libs/ui/KisDocument.cpp
M  +1    -1    plugins/impex/libkra/kis_kra_loader.cpp
M  +1    -1    plugins/impex/psd/psd_loader.cpp

https://invent.kde.org/graphics/krita/commit/87df1d81b13d1a1df7e3e1529041c0a055cb94f6
Comment 8 Dmitry Kazakov 2021-10-14 12:38:52 UTC
Git commit eea3ff549188b6ba86fbf44303e4167add84e973 by Dmitry Kazakov.
Committed on 14/10/2021 at 12:38.
Pushed by dkazakov into branch 'krita/5.0'.

Fix double-embedding of the resources into the document

Original desing of the do document-storage was supposed to store the
embedded resources in memory, while the document is loaded and unload
them from the memory, as soon as the document is unloaded. But after
July's embed-all refactoring its meaning has changed. Instead it is
used to store the resources that should be embedded into the document
separately.

Therefore, now this storage of the resources must not include the
resources that are embedded via other means, e.g. asl layer styles
or asl/psd patterns.

Right now, the only place where this storage is really used for
embedding stuff is KisPaletteEditor.

If we want to recover the idea of "a memory-only storage that
unloads the resources on document unloading", we need to make a
separate storage for such temorary data.

The commit doesn't fix the bug linked, but it removes warnings
about trying to save non-serializable resources into a persistent
storage.

M  +0    -3    libs/image/KisResourceCollectorVisitor.h
M  +3    -0    libs/ui/KisDocument.cpp
M  +1    -1    plugins/impex/libkra/kis_kra_loader.cpp
M  +1    -1    plugins/impex/psd/psd_loader.cpp

https://invent.kde.org/graphics/krita/commit/eea3ff549188b6ba86fbf44303e4167add84e973
Comment 9 Halla Rempt 2021-10-18 10:04:24 UTC
Git commit 04e2561eefaf4822d3a5b9b02dd9210900137523 by Halla Rempt, on behalf of Dmitry Kazakov.
Committed on 18/10/2021 at 10:04.
Pushed by rempt into branch 'master'.

Fix layer styles to handle transparent patterns consistently

In general, ASL styles don't support patterns with transparency,
so we should premultiply and remove transparency from a pattern
before applying it to the layer style.

The same applies to the ASL pattern saving process.

M  +1    -1    libs/image/kis_asl_layer_style_serializer.cpp
M  +1    -1    libs/image/kis_psd_layer_style.cpp
M  +18   -0    libs/image/layerstyles/kis_layer_style_filter_environment.cpp
M  +3    -0    libs/image/layerstyles/kis_layer_style_filter_environment.h
M  +7    -1    libs/image/layerstyles/kis_ls_utils.cpp
M  +1    -1    libs/image/tests/kis_asl_layer_style_serializer_test.cpp
M  +3    -3    libs/image/tests/kis_layer_style_projection_plane_test.cpp
M  +25   -1    libs/pigment/resources/KoPattern.cpp
M  +11   -1    libs/pigment/resources/KoPattern.h
M  +2    -0    libs/psd/psd_pixel_utils.h
M  +6    -0    libs/psdutils/asl/kis_asl_patterns_writer.cpp
M  +5    -0    libs/resources/KisLocalStrokeResources.cpp
M  +1    -0    libs/resources/KisLocalStrokeResources.h

https://invent.kde.org/graphics/krita/commit/04e2561eefaf4822d3a5b9b02dd9210900137523
Comment 10 amyspark 2021-10-21 13:11:22 UTC
Git commit 2b95e676aa47ac325c356780ac3b8a849f2dd70d by L. E. Segovia.
Committed on 21/10/2021 at 13:07.
Pushed by lsegovia into branch 'master'.

Fix two typos in PSD pattern alpha premultiply

M  +0    -2    libs/psd/psd_pixel_utils.h
M  +2    -2    libs/psdutils/asl/kis_asl_patterns_writer.cpp

https://invent.kde.org/graphics/krita/commit/2b95e676aa47ac325c356780ac3b8a849f2dd70d