Bug 440962 - Gradients do not load from ASL file
Summary: Gradients do not load from ASL file
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: layer styles (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2021-08-14 12:28 UTC by wolthera
Modified: 2021-11-15 17:32 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Asl file with pattern inside (1.84 MB, application/octet-stream)
2021-08-26 19:05 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wolthera 2021-08-14 12:28:20 UTC
SUMMARY
Downloaded a set of free layer styles. Selecting the layers

STEPS TO REPRODUCE
1. Download https://www.brusheezy.com/styles/21109-free-freakshow-modern-styles
2. Import into krita, and select a style for the layer (the first entry shows this bug fine).
3. Compare the style with it's preview included in the zip.
4. Look at the gradient overlay options, toggle gradient overlay off and on.

OBSERVED RESULT

Style does not match the preview, probably due gradient being loaded incorrectly.

Gradient and pattern overlay stop working when enabled from a pre-stored style.

EXPECTED RESULT

Style matches preview. Gradient and pattern overlay work.
Comment 1 Tiar 2021-08-26 19:05:51 UTC
Created attachment 141073 [details]
Asl file with pattern inside

Pattern overlay does seem to work on other asl file I have (attached). So it's only patterns.

(However with the asl file you included I get a *lot* of of safe asserts because Krita gets super confused, because some of the styles have the same psdUuid... I reported it here: bug 441583).

About the difference in patterns and gradients:
- patterns are in the KisAslStorage, just like layer styles. (see KisAslStoragre, and how asl serializer adds them to the list when reading them)
- gradients are considered "embedded resources", I guess, and they seem to be added to the memory storage on the fly and it seems to not work (see QVector<KoResourceSP> KisAslLayerStyleSerializer::fetchEmbeddedResources(const KisPSDLayerStyle *style)).

When I was writing KisAslStorage, it made sense to me to add patterns there; and now you can easily use the pattern from the asl storage in some other place. (Not that it has only benefits: what if the user uses it for a brush preset?).
I seem to have forgotten about gradients. I guess Halla added them, but she did it in a different way than I did...

Note: in Krita 4, gradients were added to the list of possible gradients. Now they don't (probably because Krita can't seem to be able to add them to the memory storage).
Comment 2 Halla Rempt 2021-09-22 11:19:38 UTC
When I select some styles, I get a crash -- like Pogo.
Comment 3 Halla Rempt 2021-09-22 12:58:20 UTC
Update...

Actually, the gradients load and are added to the memory storage. They are also set correctly on the gradient selector in the layer style dialog. Retrieving the gradient from the gradient selector seems to be broken: that return 0.

I'm not sure yet what's up, will be working on this some more.
Comment 4 wolthera 2021-09-30 16:01:02 UTC
FWIW, these layer styles can crash due the gradients being weird:


StylesSelector::selectStyle "Faiis Blue" "Faiis Blue"
Thread 1 (Thread 0x7f6723172f80 (LWP 3296)):
[KCrash Handler]
#4  psd_layer_effects_shadow_base::setGradient(QSharedPointer<KoAbstractGradient>) (value=..., this=0x55ca853dff40) at /home/wolthera/krita/src/libs/psd/psd.h:432
#5  GradientOverlay::fetchGradientOverlay(psd_layer_effects_gradient_overlay*) const (this=<error reading variable: Cannot access memory at address 0x7ffe035f9708>, config=0x55ca853dff40) at /home/wolthera/krita/src/libs/ui/dialogs/kis_dlg_layer_style.cpp:1136
#6  0x00007f672a8db45b in KisDlgLayerStyle::style() const (this=<error reading variable: Cannot access memory at address 0x7ffe035f9d98>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:307
#7  0x00007f672a9b877c in updateLayerStyles(KisSharedPtr<KisLayer>, KisDlgLayerStyle*) (layer=Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 0x7ffe035f9e90: 
#8  0x00007f672a9c303a in std::__invoke_impl<void, void (*&)(KisSharedPtr<KisLayer>, KisDlgLayerStyle*), KisSharedPtr<KisLayer>&, KisDlgLayerStyle*&>(std::__invoke_other, void (*&)(KisSharedPtr<KisLayer>, KisDlgLayerStyle*), KisSharedPtr<KisLayer>&, KisDlgLayerStyle*&) (__f=<optimized out>) at /usr/include/c++/9/bits/atomic_base.h:318
#9  std::__invoke<void (*&)(KisSharedPtr<KisLayer>, KisDlgLayerStyle*), KisSharedPtr<KisLayer>&, KisDlgLayerStyle*&>(void (*&)(KisSharedPtr<KisLayer>, KisDlgLayerStyle*), KisSharedPtr<KisLayer>&, KisDlgLayerStyle*&) (__fn=<optimized out>) at /usr/include/c++/9/bits/invoke.h:95
#10 std::_Bind<void (*(KisSharedPtr<KisLayer>, KisDlgLayerStyle*))(KisSharedPtr<KisLayer>, KisDlgLayerStyle*)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) (__args=..., this=<optimized out>) at /usr/include/c++/9/functional:400
#11 std::_Bind<void (*(KisSharedPtr<KisLayer>, KisDlgLayerStyle*))(KisSharedPtr<KisLayer>, KisDlgLayerStyle*)>::operator()<, void>() (this=<optimized out>) at /usr/include/c++/9/functional:484
#12 std::_Function_handler<void (), std::_Bind<void (*(KisSharedPtr<KisLayer>, KisDlgLayerStyle*))(KisSharedPtr<KisLayer>, KisDlgLayerStyle*)> >::_M_invoke(std::_Any_data const&) (__functor=...) at /usr/include/c++/9/bits/std_function.h:300
#13 0x00007f6728afddd0 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007f672a7f770b in KisDlgLayerStyle::configChanged() (this=<optimized out>) at /home/wolthera/krita/build/libs/ui/kritaui_autogen/2NRMJ5X7RK/moc_kis_dlg_layer_style.cpp:1487
#15 KisDlgLayerStyle::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /home/wolthera/krita/build/libs/ui/kritaui_autogen/2NRMJ5X7RK/moc_kis_dlg_layer_style.cpp:1417
#16 0x00007f6728afddd0 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
[Inferior 1 (process 3296) detached]
Comment 5 Halla Rempt 2021-10-01 11:16:11 UTC
I managed to find the cause for the issue, but haven't got a fix yet: the md5sum for the custom.ggr gradients is different once it's been added to the memory storage.
Comment 6 Dmitry Kazakov 2021-10-12 05:28:46 UTC
It might be that this MR will fix the issue (though it needs testing):

https://invent.kde.org/graphics/krita/-/merge_requests/1089


I had the same problem with patterns, which were somehow not loaded due to double embedding. Perhaps this problem is related...
Comment 7 Dmitry Kazakov 2021-10-12 05:55:46 UTC
No, the MR I mentioned doesn't fix the crash. Gradient chooser still has null-pointer resource selected.
Comment 8 Bug Janitor Service 2021-10-22 20:16:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1121
Comment 9 amyspark 2021-11-15 16:27:49 UTC
Git commit a90ebb74ff8ed31d1b7b23e4a556f8b049a7490f by L. E. Segovia.
Committed on 15/11/2021 at 16:25.
Pushed by lsegovia into branch 'master'.

Do not set the gradient if there's none available

M  +3    -1    libs/ui/dialogs/kis_dlg_layer_style.cpp

https://invent.kde.org/graphics/krita/commit/a90ebb74ff8ed31d1b7b23e4a556f8b049a7490f
Comment 10 amyspark 2021-11-15 16:27:57 UTC
Git commit a1620990f5d089e76d097285e638635bf9c9fa5a by L. E. Segovia.
Committed on 15/11/2021 at 16:25.
Pushed by lsegovia into branch 'master'.

ASL: reasign UUID for resources that share one

M  +26   -8    libs/image/kis_asl_layer_style_serializer.cpp

https://invent.kde.org/graphics/krita/commit/a1620990f5d089e76d097285e638635bf9c9fa5a
Comment 11 amyspark 2021-11-15 17:31:54 UTC
Git commit fd399d7a20f02a13a593fbf5fcd949d57be70e2d by L. E. Segovia.
Committed on 15/11/2021 at 17:29.
Pushed by lsegovia into branch 'krita/5.0'.

ASL: reasign UUID for resources that share one
(cherry picked from commit a1620990f5d089e76d097285e638635bf9c9fa5a)

M  +26   -8    libs/image/kis_asl_layer_style_serializer.cpp

https://invent.kde.org/graphics/krita/commit/fd399d7a20f02a13a593fbf5fcd949d57be70e2d
Comment 12 amyspark 2021-11-15 17:32:03 UTC
Git commit e7c35c1b3df3982eab56dc300f819ef7c78987ea by L. E. Segovia.
Committed on 15/11/2021 at 17:29.
Pushed by lsegovia into branch 'krita/5.0'.

Do not set the gradient if there's none available
(cherry picked from commit a90ebb74ff8ed31d1b7b23e4a556f8b049a7490f)

M  +3    -1    libs/ui/dialogs/kis_dlg_layer_style.cpp

https://invent.kde.org/graphics/krita/commit/e7c35c1b3df3982eab56dc300f819ef7c78987ea