Bug 451063

Summary: Projection is (often) not updated after pasting raster data
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: Layer StackAssignee: Tyson Tan <tysontanx>
Status: RESOLVED FIXED    
Severity: normal CC: acc4commissions, halla, lynx.mw+kde
Priority: NOR Keywords: regression, release_blocker
Version First Reported In: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: unspecified   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Video recording of Krita's canvas not updating
Video recording of Krita nightly (df3e78e899) not updating canvas properly

Description Tyson Tan 2022-03-03 01:51:47 UTC
SUMMARY
Pasting a selection creates an invisible pasted layer on canvas. Although the pasted layer's visibility is ON, you must toggle the layer's visibility once to make it visible.

Tested with appimages of 2022-03-03:
[AFFECTED] krita-5.1.0-prealpha-9a8840cd8e-x86_64.appimage
[UNAFFECTED] krita-5.0.2-alpha-da37c21fd2-x86_64.appimage


STEPS TO REPRODUCE
1. Create a new document
2. Fill a layer with solid color with Shift+Backspace
3. Create a selection, Ctrl+X
4. Ctrl+V, the content has been pasted into a new layer
5. You can see the pasted layer's content from the Layer docker, but nothing is shown on canvas
6. Toggle the pasted layer's visiblity once
7. Now it is visible on canvas


NOTES
The triggering condition of this bug seems elusive. Sometimes I can paste just fine, sometimes I had to paste inside of a group to trigger it. All tests were conducted on new documents and new instances of Krita. 

This bug has been around for at least a month.
Comment 1 Halla Rempt 2022-03-03 09:13:06 UTC
I could reproduce this on the first go.
Comment 2 Halla Rempt 2022-03-03 10:35:45 UTC
Git bisect is useless here: 54b694638bd2c943f467d66cab66754d1243fecf is identified as the breaking commit, but that only adds some hungarian translations...
Comment 4 Tyson Tan 2022-03-12 16:27:09 UTC
Using krita-5.1.0-prealpha-e75d194a75-x86_64.appimage

Polyline tool is also causing blocks of layer to disappear. Undo/Redo doesn't help. I think these issues are related?
Comment 5 Dmitry Kazakov 2022-03-14 12:56:45 UTC
I cannot reproduce the problem here locally. Perhaps it got fixes by my recent commit 827c03d5ddd74a4f18f55ed892f49e391ec2ecc1 ?
Comment 6 Tyson Tan 2022-03-15 02:05:25 UTC
It still happens to me with krita-5.1.0-prealpha-8f335dfa46-x86_64.appimage

Did your new document have only one Background layer, and you filled and cut on that layer? I could not trigger the bug that way either.

But I can trigger the bug by creating a new paint layer, then fill, cut, paste over it.
Comment 7 Tyson Tan 2022-03-15 02:09:22 UTC
The reason you might have one Background layer is caused by this bug: BUG431164
Comment 8 Halla Rempt 2022-03-16 09:45:14 UTC
With current master, I cannot reproduce it anymore either.
Comment 9 Halla Rempt 2022-03-16 09:45:46 UTC
(I have a background layer, one layern filled with a gradient, from which I cut & paste into a new layer)
Comment 10 Tyson Tan 2022-03-16 15:13:08 UTC
I can still reproduce this with krita-5.1.0-prealpha-8f335dfa46-x86_64.appimage exactly like what I mentioned.
Comment 11 Tyson Tan 2022-03-16 15:29:08 UTC
Created attachment 147529 [details]
Video recording of Krita's canvas not updating

This is a video of Krita's canvas not updating. Tested with krita-5.1.0-prealpha-8f335dfa46-x86_64.appimage
Comment 12 Tyson Tan 2022-03-16 17:23:30 UTC
Looks like it was fixed in krita-5.1.0-prealpha-df3e78e899-x86_64.appimage
Thank you! :)
Comment 13 Tyson Tan 2022-03-17 17:00:02 UTC
Created attachment 147562 [details]
Video recording of Krita nightly (df3e78e899) not updating canvas properly

I'm sorry but later that day the same bug happened to krita-5.1.0-prealpha-df3e78e899-x86_64.appimage

I recorded a video here.
Comment 14 Tyson Tan 2022-03-17 17:15:41 UTC
The same thing happened to today's krita-5.1.0-prealpha-dd368ef73f-x86_64.appimage too. I have restarted the computer before the testing. Nothing else was running at the same time.

krita-5.0.2-alpha-ca4f0c8d6a-x86_64.appimage still worked fine.
Comment 15 acc4commissions 2022-04-19 03:39:55 UTC
I've been having this problem too for a long time.
Comment 16 acc4commissions 2022-04-19 03:42:07 UTC
For me the canvas projection corrupts sometimes too when I'm using transform, undo, etc. But I have no idea it's related.
Comment 17 Tyson Tan 2022-04-19 06:06:16 UTC
Sometime similar to the bug description happened to Krita 5.0.6 nightly too, if just for once. I was doing:

1. Create a new text object, edited it.
2. Tried to transform it but failed because it was vector
3. Convert the vector layer to raster layer
4. Copy the rasterized text layer
5. Paste, then transform.
6. Paste again, this time nothing is shown on canvas, but after toggling layer visibility the pasted content showed up. The pasted layers might have been inside of a Group.

I could not reproduce this situation again, but it did happened, so I thought I should put it here for information.
Comment 18 Tyson Tan 2022-05-08 03:16:41 UTC
Today I found out that if I first duplicate a layer and then immediately remove it, the subsequent cut-and-paste action will not be affected by this bug. It's not really a workaround, but it might hold some clue to solve this issue?
Comment 19 Dmitry Kazakov 2022-06-03 07:25:02 UTC
Git commit 7768b6d0ca4f712de14a7ca07da72c70f67284fd by Dmitry Kazakov.
Committed on 03/06/2022 at 07:24.
Pushed by dkazakov into branch 'master'.

Fix a race condition in KisNodeJugglerCompressed's updates

It could happen that the updates would be issued **bofore** the layer
is actually added to the image. It happened because the updates were
issued by the GUI thread, but addition is executed by the stroke's
thread. Now the juggler pushes the updates into the common strokes
queue, so that they cannot be reordered.

M  +15   -2    libs/ui/kis_node_juggler_compressed.cpp

https://invent.kde.org/graphics/krita/commit/7768b6d0ca4f712de14a7ca07da72c70f67284fd
Comment 20 Tyson Tan 2022-06-03 08:37:36 UTC
Thank you, Dmitry! Now I can finally use the Krita next nightlies at production XD