Bug 441583

Summary: Krita gets confused when the asl file contains layer styles with the same psd uuid
Product: [Applications] krita Reporter: Tiar <tamtamy.tymona>
Component: Resource ManagementAssignee: Tiar <tamtamy.tymona>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version First Reported In: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Mint (Ubuntu based)   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Tiar 2021-08-26 18:50:37 UTC
SUMMARY
If you load the file from bug 440962, you'll see that on subsequent runs Krita shows a lot of safe asserts.
After long triaging, the cause seems to be that multiple styles in the asl file have the same psdUuid. Since the filename is "[psdUuid]_style", they get included in the database as just style.

STEPS TO REPRODUCE
1. Put the asl file in the resource folder, or import by GUI.
2. Start Krita again (must be in debug mode, or something that would show safe asserts).

OBSERVED RESULT
Lots of safe asserts "SAFE ASSERT (krita): "result" in file /home/tymon/kritadev/krita/libs/resources/KisResourceCacheDb.cpp, line 1669"

EXPECTED RESULT
1) No safe asserts. (They should be removed from the file anyway; the resource folder is considered to be all sorts of wrong, there is no need to annoy the developer, warnKrita or some logging should be enough).
2) Krita handles the styles with the same psdUuid correctly. I'm not sure what exactly should it do - just take the first style with the psdUuid?

The asl file in the bug 440962 comes, I believe, from https://inspirationfeed.com/free-photoshop-layer-styles/, and in the second place you see "268 styles". From which I conclude that the repeated psdUuid is a mistake and PS probably shows all the 268 styles. In Krita, there is only 225 styles with unique psdUuid and in consequence, unique filename.


SOFTWARE/OS VERSIONS
Krita

 Version: 5.0.0-prealpha (git bad2b20)
 Languages: en_US, en, en_US, en, en_US, en, pl_PL, pl, pl_PL, pl
 Hidpi: true

Qt

  Version (compiled): 5.11.1
  Version (loaded): 5.11.1

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 5.3.7-050307-generic
  Pretty Productname: Linux Mint 19.3
  Product Type: linuxmint
  Product Version: 19.3
  Desktop: X-Cinnamon
Comment 1 Tiar 2021-08-28 01:37:25 UTC
Git commit 8d97c8e529755135663f94f6832c35427954165e by Agata Cacko.
Committed on 28/08/2021 at 00:39.
Pushed by tymond into branch 'master'.

Ignore layer styles that have already used uuids

Before this commit, if the user downloaded an incorrect asl
file (with non-unique uuids, belonging to repeated layer styles),
Krita would be confused on next run, because it would assume
those other layer styles are new versions of the already known ones,
and try to save new versions of them.
This commit just make Krita ignore all layer styles whose uuids has been
already used in the file which prevents the trouble.

M  +9    -0    libs/image/kis_asl_layer_style_serializer.cpp

https://invent.kde.org/graphics/krita/commit/8d97c8e529755135663f94f6832c35427954165e
Comment 2 Halla Rempt 2021-08-28 07:53:10 UTC
Git commit ab43cbb23d7c247d9377a0ff301ba0a0196eaddc by Halla Rempt, on behalf of Agata Cacko.
Committed on 28/08/2021 at 07:52.
Pushed by rempt into branch 'krita/5.0'.

Ignore layer styles that have already used uuids

Before this commit, if the user downloaded an incorrect asl
file (with non-unique uuids, belonging to repeated layer styles),
Krita would be confused on next run, because it would assume
those other layer styles are new versions of the already known ones,
and try to save new versions of them.
This commit just make Krita ignore all layer styles whose uuids has been
already used in the file which prevents the trouble.
(cherry picked from commit 8d97c8e529755135663f94f6832c35427954165e)

M  +9    -0    libs/image/kis_asl_layer_style_serializer.cpp

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