Gradient Duplication & Corruption in Krita 5.2.9

Hey everyone, this post is about squashing the bug of the title. If the following bug sounds familiar to you, please weigh in with what ever information may help in strengthening this bug report.

Summary

Gradients in Krita duplicate, alter, and display incorrectly after reopening a .kra file.
This affects:
:white_check_mark: Gradient Overlay (Layer FX)
:white_check_mark: Outline Fill (Layer FX)
:white_check_mark: Vector Gradients (Fill for Vector Shapes)

Issues observed:

  • Wrong gradient thumbnails for gradients &
  • Re-selecting a gradient does not match its thumbnail

  • Colors missing or changed after reopening

  • Duplicate gradients appearing in presets


System Information

  • OS: Nobara 40 (Fedora-based Linux)
  • Krita Version: 5.2.9
  • Hardware: Intel i9-13900HX, NVIDIA RTX 4090, 31GB RAM

Steps to Reproduce

  1. Create a new document (at least 512x512 px).
  2. Zoom in after creating the document.
  3. Draw a rectangle filling the entire canvas.
  4. Apply the “GPS Eye (Blue)” gradient in one of these ways:
  • Gradient Overlay (Layer FX)
  • Outline Fill (Layer FX)
  • Vector Shape Fill Gradient
  1. Save the .kra file and close Krita.
  2. Reopen Krita and observe:
  • Colors are missing or altered.
  • Duplicate gradients appear in presets.
  • Vector gradient thumbnails are incorrect.
  • Selecting a gradient applies a different result than the preview.

Expected Behavior

  • Gradients should remain unchanged after reopening.
  • No duplicate gradients should be created.
  • Thumbnails should match actual gradients.

Actual Behavior

  • Gradients are altered on reload.
  • Duplicate gradients are created.
  • Vector gradient thumbnails are incorrect.
  • Re-selecting a gradient applies the wrong colors.

users that seem to have the same problem:

https://www.reddit.com/r/krita/comments/wx99bm/is_saving_gradient_maps_borked_or_am_i_missing/

PARTICULARLY INTERESTING TO KNOW:

Where in the source code might this be effected? It would seem to be related to how gradient presets are stored and handled.

-S

Since there hasn’t been much engagement on this post, I’d like to clarify why this issue is important—especially for concept artists transitioning from Photoshop or similar software. Ensuring that existing procedural workflows in Krita function as expected is key to making the software more viable in professional environments.

For artists working in pre-production, procedural workflows are essential. They provide the flexibility needed to iterate quickly, adjust to client feedback, and maintain efficiency in constantly evolving projects. This isn’t just a concern for technical artists—it affects any artist who needs to adapt their work dynamically. If these workflows don’t perform as anticipated, artists may find themselves switching to other software instead.

The good news is that by addressing existing features that aren’t working correctly, Krita can naturally become a more attractive option. It’s not about adding new features—it’s about ensuring the ones already present function as expected.

I discovered that this particular bug may have existed since 2021 or earlier, when it was first reported. To help move things forward, I’ve submitted a bug report with additional data, screenshots, and reproducible examples:

:link: Bug Report: 500851 – Gradients in Krita duplicate, alter, and display incorrectly after reopening a .kra file.

The most similar existing issue I found was reported in 2021:
:link: Related Bug Report: 445390 – Layer styles duplicate bundled patterns and gradients

Since this issue doesn’t appear to have been confirmed as fixed, it’s possible that others have encountered it, but opted not to report it—perhaps assuming it’s easier to switch to another program rather than troubleshoot.

If anyone else has experienced this, I encourage you to contribute to the discussion by sharing your findings or testing the issue on your setup. More data will help the developers address it more effectively.

2 Likes

Either I’m misunderstanding the steps you’re taking while trying to recreate the issue or my system doesn’t experience the problem.

  • Windows 10
  • Krita version 5.2.9
  • Intel(R) Core™ i7-7700 CPU, NVIDIA GeForce GTX 1070, 16GB RAM
1 Like

@SimonH: I wonder why you don’t confirm this bug report when you experience the same issue? You only need an account with them and can confirm it. Be aware that your email must be an existing one and that it can be seen by everyone visiting that site. But the site seems very safe, in all the years I’m registered there and have reports, comments and confirmations online, I never received any mail on the email-account only created for use with them.

Michelist

1 Like

Hi Michelist,

I’m confused, do you mean for me to switch my ticket status to ‘confirmed’ from ‘reported’?

I thought only the KDE team could do that?

As for how safe it is, probably very safe considering I used it to report the bug :slight_smile:

Someonesane,

Thanks for confirming that you’re not experiencing this on windows. So potentially this is a Linux problem to do with file handling.

-S

1 Like

Thank you for the heads-up!
Oh, no, I wasn’t paying enough attention, of course you shouldn’t confirm your own bug report yourself. Somehow, when I skimmed the text, I took it to mean that you were surprised that someone else’s report remained unconfirmed for so long. Maybe I shouldn’t have been doing so many things at the same time this afternoon, but there were so many things I was supposed to be doing that I overlooked it. :upside_down_face:

Michelist

2 Likes

All good, no harm done!

I notice you helping a lot of people on the forums. It’s good having you either way :slight_smile:

-S

2 Likes

I made some test with Krita 5.2.9 on Windows 10 / 11.

I have not seen the “gradient duplication” but there is an issue with respect to vector vs. bitmap layers.

I hope the screenshots explain it:

EDIT:
I have confirmed the bug report, even though my findings are not exactly the same like yours @SimonH
But I think, they have the same root cause.

EDIT2:
The gradient preview is also affected by the opacity values:

3 Likes

Wow this is a twist… so other windows users have reported that they cannot reproduce the issue but you have proven that some windows users are also experiencing a similar issue.

I really appreciate how thorough you were in grabbing these screenshots and these labels. Very well organised and it reads well. Thank-you for your work.

Makes me wonder if this is possibly be a hardware related issue. Something to do with how memory is stored. I guess it’s not impossible at this point, since others are struggling to reproduce this across platforms.

-S

1 Like

Thanks for your kind words.

One more detail. It seems, it is the “Segmented Gradient” type that is affected and only if vectors are used. Contrary to what I thought first, it is not related to the opacity but to left color vs. right color in general, even if they are set to 100% opacity.
These are very specific conditions which could get missed in testing.

@SimonH can you confirm this for your Linux system?

My guess; it is not related to hardware but differences in the algorythms used for vector and bitmap objects.

2 Likes

You’re welcome.

This is what I’m getting in Nobara 40 Linux:

I notice my gradient is blending differently to yours and I’m not sure why.

Then after reloading Krita and that file, we have missing nodes and altered hues:

-S

Ah, we have different layers.

I have on the left a pure bitmap paint layer and assign the gradient to a selection.
You have on the left a vector object and assign the gradient by layer fx.
On the right we both have a vector renctangle with a gradient fill.

If I use your set of layers I get the same result like you but without the differences in colors.

2 Likes

I can confirm now that this also effects Android builds.

(5.2.10 pre-alpha)

While initially working on the file:

After quitting and re-opening:

So far these issues seem to be confirmed for people using Linux, Android and windows.

-S

Here’s what I can reproduce (on macOS, it’s nothing platform-specific):

  • Saving a document with a gradient layer style and reopening it shows a duplicate gradient (with its location shown as some (memory?) hash). That duplication might be expected, since layer style resources are intentionally saved into the document. The duplicate only appears when opening the document.
  • The duplicate gradient has two-colored stops wrongly converted to a single color (that’s what’s happening with GPS Eye (Blue)).
  • If the original gradient is used as a vector fill, it will show the incorrect gradient. I’m guessing it’s getting them confused as they are the “same”. Attempting to edit the original gradient shows it is correct.

Possibly relevant code: KisPSDLayerStyle::cloneWithResourcesSnapshot in libs/image/kis_psd_layer_style.cpp

4 Likes

I have run a quick code analysis on this and confirmed it as a likely area for a programmer to go and check out in case it’s causing this issue.

So yeah,

KisPSDLayerStyle::cloneWithResourcesSnapshot located in the libs/image/kis_psd_layer_style.cpp file.

If there’s a discrepancy in there for how gradients are cloned or referenced during the saving and loading processes, it could lead to duplication or corruption, right?

I’m out of my depth on this subject, any programmers who know this better than I do, feel free to weigh in.

EDIT:

Krita’s resource system relies on consistent UUIDs and reference tracking… right? Aren’t we just re-adding gradients without preserving their original references often causes duplication bugs? Is the fix just to modify how gradients are stored and linked? Seems like only a few lines can be changed to test if it’s better to ensure existing references are updated instead of removing and re-adding.

Can we just modify the bakeGradient() function?

localResourcesSnapshot->removeResource(gradient);
localResourcesSnapshot->addResource(clonedGradient);

To:

gradient = clonedGradient;

So that instead of removing and re-adding it’s directly updating the gradient to avoid associated duplication bugs?

Could be just speculation. If anyone can test this, or knows another probably culprit, I’m keen to know :slight_smile:

-S

1 Like

I am new to Krita but I’ve had a similar issue with one of my files in 5.2.9 Two different times, now, the gradients have been completely different colors upon opening the file, in spite of the thumbnail displaying correctly, and regardless of how many times I shut down and reopened Krita. The only workaround I have is to paint over the layer in question with a different layer, but this seems a bit excessive.

There is a work around is for now. Try using vector with a svg based gradient fill. That worked for me in place of layer FX fills.

I guess someone will look into this when they have time. Although I’m not going to be sad if Freya focuses entirely on QT6 since that’s our key to better features and optimised performance.

-S

1 Like

Unfortunately I don’t know what any of that means, but I will keep trying to salvage my files. Thank-you for your quick reply.

Understood, don’t feel bad, sometimes there can be a lot to learn about what Krita is capable of.
But this is actually a really worthwhile lesson because it’s really cool stuff similar to illustrator, affinity designer or Inkscape. Photoshop users would also find this handy.

I’m going to use a visual guide to explain how it’s set up:

Use this tool, and just single click some points on your canvas and hit enter. Bam - That’s a vector layer (SVG) - Scalable Vector Graphics. That’s GOOD because It’s non-destructive, can be scaled up and down without losing detail. You could make a logo with this.

Next:


Use the select shapes tool to select the shape you just made.

We use this to change the shape’s settings. (Pictured on the right hand side of the screenshot)

In the ‘Stroke’ (It’s a diagonal line button) tab on the right, you can click the little white box with the red arrow if you don’t want an outline.

Adjusted the fill of the gradient now but clicking the little Paintbucket icon, inside that is the ‘Fill’ section, and simply by clicking the little square that looks like a gradient; you can set up a gradient fill for your shape.

Done.

Tutorial over, congrats… that’s the work around in all it’s detailed glory :slight_smile:
Super simple. Try playing around with the gradient gizmo in the centre. I think you’ll like it when you see how useful it is.

That handle we stay in place and you can adjust it later as needed.
And all of this is compatible with other vector software!

NOTE:

While this won’t fix the preset problem, this method is more robust for keeping things looking the same because the gradient won’t change when you re-open the file as it’s not directly dependant on non-svg data.

-S

2 Likes

I think I may have run into this issue on Linux Mint. I added a gradient overlay and stroke with gradient to a text layer and the next time I opened the file the color was different because it saved 2 gradients with the same name, one being the latest edit, and the other being a previous edit.

I feel like the biggest issue here is that these gradient presets appear to be GLOBAL.

You can modify a gradient preset while working in one file and then all files that use that preset will be silently modified since Krita uses the global resource to render them.

That makes absolutely no sense and will obviously lead to data loss sooner or later. The way I expected it to work is that each layer style stores the values of the gradient it uses and if you click on a preset it simply sets those values from the preset.

Even if you wanted to dynamically reference a preset, that preset should be stored in the .kra file itself instead of in the user’s system.

There already exists a separate bug in which setting the gradient value to 0 (FG → BG), the gradient changes every time you open the dialog. I feel like gradients in Krita are unexpectedly fragile.

Update: Ok, I see the problem now. Krita does save the gradient to the .kra file, but it automatically reloads the gradient from the preset without user interaction. On fill layers and filter layers there is a gradient editor GUI and a separate preset selector but for some reason on layer styles there is only a preset selector, there is no way to edit the gradient without creating a preset, and once a preset is created Krita automatically copies the values every time you open the dialog. You can test this by opening a second file and editing a preset you made in the second file, when you go back to the first file the preset won’t update, but if you open the layer style dialog (or close and re-open the file) the gradient stops are reloaded from the associated preset, potentially leading to data loss.

1 Like