Bug 437626 - Krita crashes on save when documents are too large, and contain procedural layers
Summary: Krita crashes on save when documents are too large, and contain procedural la...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 4.4.5
Platform: Other Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-24 19:17 UTC by LKS
Modified: 2021-07-30 08:02 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
the file that crashes on autosave (3.11 MB, application/x-krita)
2021-05-24 19:17 UTC, LKS
Details
krita info for debug (2.55 KB, text/plain)
2021-05-26 16:15 UTC, LKS
Details
krita crash log (97.77 KB, text/plain)
2021-05-26 16:18 UTC, LKS
Details
one of the the wer crash reports that I believe was produced from this bug (57.35 KB, application/octet-stream)
2021-05-26 17:06 UTC, LKS
Details
crashing .kra file (3.55 MB, application/x-krita)
2021-07-14 06:26 UTC, LKS
Details
krita system information (2.57 KB, text/plain)
2021-07-14 16:42 UTC, LKS
Details
dxdiag info (130.42 KB, text/plain)
2021-07-14 16:42 UTC, LKS
Details
krita usage log (54.88 KB, text/plain)
2021-07-14 16:45 UTC, LKS
Details
dxdiag info (PC 3) (123.63 KB, text/plain)
2021-07-23 23:16 UTC, LKS
Details
Krita System Info PC 3 (2.55 KB, text/plain)
2021-07-23 23:21 UTC, LKS
Details
Krita Usage Log (10.56 KB, text/plain)
2021-07-23 23:22 UTC, LKS
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LKS 2021-05-24 19:17:50 UTC
Created attachment 138753 [details]
the file that crashes on autosave

SUMMARY
When creating 4k or 8k documents with multiple layers, Krita will often crash on save, the crash can be triggered by an autosave or a manual save. This seems to be caused by using procedural fill / filter layers -- deleting all fill layers and replacing them with paint layers filled with a solid color seems to prevent the crash.
 
I have tried turning most of the autosave / file handling settings on and off, as well as switching the autosave drive from "same as file" to user, an HDD and SSD, respectively, crash still happens. 

I am using the Steam version on a win10 machine, crashing file attached.
I would submit a dxdiag but I can only add one attachment, so I've pasted it below

STEPS TO REPRODUCE
1. open the crashing .kra
2. paint around a bit
3. save or wait for autosave

OBSERVED RESULT
crash!

EXPECTED RESULT
no crash!

SOFTWARE/OS VERSIONS
Windows: Win10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

------------------
System Information
------------------
      Time of this report: 5/24/2021, 12:10:26
             Machine name: DESKTOP-DR1O1RV
               Machine Id: {EE9A827C-2933-48B4-A69F-C13DD05CBAA7}
         Operating System: Windows 10 Pro 64-bit (10.0, Build 19041) (19041.vb_release.191206-1406)
                 Language: English (Regional Setting: English)
      System Manufacturer: System manufacturer
             System Model: System Product Name
                     BIOS: 1704 (type: UEFI)
                Processor: Intel(R) Core(TM) i7-9800X CPU @ 3.80GHz (16 CPUs), ~3.8GHz
                   Memory: 65536MB RAM
      Available OS Memory: 65206MB RAM
                Page File: 56714MB used, 27504MB available
              Windows Dir: C:\WINDOWS
          DirectX Version: DirectX 12
      DX Setup Parameters: Not found
         User DPI Setting: 96 DPI (100 percent)
       System DPI Setting: 192 DPI (200 percent)
          DWM DPI Scaling: UnKnown
                 Miracast: Available, with HDCP
Microsoft Graphics Hybrid: Not Supported
 DirectX Database Version: 1.0.8
           DxDiag Version: 10.00.19041.0928 64bit Unicode
Comment 1 Halla Rempt 2021-05-25 08:22:03 UTC
This file isn't big or complicated. I don't get a crash when trying to save it. Could you open help->show information for bug reports and add the contents here? It would also be useful if you could find the kritacrash.log file and add it.
Comment 2 LKS 2021-05-26 16:15:59 UTC
Created attachment 138811 [details]
krita info for debug
Comment 3 LKS 2021-05-26 16:18:50 UTC
Created attachment 138812 [details]
krita crash log
Comment 4 LKS 2021-05-26 16:20:52 UTC
(In reply to Halla Rempt from comment #1)
> This file isn't big or complicated. I don't get a crash when trying to save
> it. Could you open help->show information for bug reports and add the
> contents here? It would also be useful if you could find the kritacrash.log
> file and add it.

Thanks for the quick reply! I've uploaded the additional files, also, it looks like there is a WER report for krita every time the crash happens, is this useful to have?
Comment 5 Halla Rempt 2021-05-26 16:42:36 UTC
Yes, that probably would be useful as well. The crash log seems to be outdated, the latest crash is from February 28, 2021. Not sure what's up there...
Comment 6 LKS 2021-05-26 17:06:02 UTC
Created attachment 138813 [details]
one of the the wer crash reports that I believe was produced from this bug
Comment 7 Bug Janitor Service 2021-05-27 04:33:49 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 8 Halla Rempt 2021-05-27 09:28:44 UTC
Hm, that doesn't say much either. Could you 


* make sure there are no krita related files in %LOCALAPPDATA% -- make a backup of those, then remove them
* try to reproduce the issue with the portable nightly stable build: https://binary-factory.kde.org/job/Krita_Stable_Windows_Build/ with debug symbols

Just unzip the krita zip file, then copy the contents of the dbg.zip file into the unzipped krita folder and try to reproduce.
Comment 9 LKS 2021-05-29 19:40:35 UTC
(In reply to Halla Rempt from comment #8)
> Hm, that doesn't say much either. Could you 
> 
> 
> * make sure there are no krita related files in %LOCALAPPDATA% -- make a
> backup of those, then remove them
> * try to reproduce the issue with the portable nightly stable build:
> https://binary-factory.kde.org/job/Krita_Stable_Windows_Build/ with debug
> symbols
> 
> Just unzip the krita zip file, then copy the contents of the dbg.zip file
> into the unzipped krita folder and try to reproduce.

Sure sure, sorry about the delay, I'll do that right now :)
Comment 10 Bug Janitor Service 2021-05-30 04:33:40 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 11 LKS 2021-05-30 17:54:40 UTC
quite irritatingly, I'm having trouble reproing the issue myself after a restart and a windows update :| which is weird because previously I could open this doc, wait a few minutes for an autosave, and it would crash every time. Also this has happened in the past with other documents, it crops up once every couple weeks or so, only when I'm making large documents with procedural layers.

Is it ok if I keep trying to repro this over the next few days or should the bug be closed down until I can make it happen and get the debug data?
Comment 12 Tiar 2021-05-31 00:03:51 UTC
I'm closing it as "worksforme" but you can reopen it when it happens again.
Comment 13 LKS 2021-07-14 06:10:11 UTC
ah ha! I finally caught this sucker on video!

https://youtu.be/iLNDUwyANtk
Comment 14 LKS 2021-07-14 06:11:51 UTC
(In reply to LKS from comment #13)
> ah ha! I finally caught this sucker on video!
> 
> https://youtu.be/iLNDUwyANtk

Also I'm on entirely new hardware this time, a pretty beefy machine. Same issue, largeish doc (2k) fill layers + filter layers
Comment 15 LKS 2021-07-14 06:26:23 UTC
Created attachment 140040 [details]
crashing .kra file

And the file. I can crash my krita by opening the file, making a few brush strokes, and attempting to save it
Comment 16 Halla Rempt 2021-07-14 08:59:01 UTC
Ah, well... I still cannot reproduce this -- and it's still not a big document, it only takes ~170mb of memory.

In the meantime, the video is private, so I cannot watch it. If this is different hardware could you again attach the crash log, system info and krita log files?
Comment 17 Halla Rempt 2021-07-14 08:59:28 UTC
Oh, and _where_ are you saving? Local disk, google drive, onedrive, dropbox or shared network drive?
Comment 18 LKS 2021-07-14 16:33:14 UTC
Thanks a bunch for the reply! I've set the previous to unlisted instead of private, Here's another vid demonstrating the same thing that includes opening the file:

https://youtu.be/YRvcMOZxSyw

system specs etc incoming shortly
Comment 19 LKS 2021-07-14 16:42:35 UTC
Created attachment 140057 [details]
krita system information
Comment 20 LKS 2021-07-14 16:42:54 UTC
Created attachment 140058 [details]
dxdiag info
Comment 21 LKS 2021-07-14 16:45:24 UTC
Created attachment 140059 [details]
krita usage log
Comment 22 LKS 2021-07-14 16:47:45 UTC
more info for context: 
- kritacrash file doesn't exist or get updated after this kind of crash, on this machine there is no kritacrash log because it has never crashed another way so far

- saving the file to a local SSD resilio sync folder C:/BTS/Work date/ which doesn't lock files or anything but I can save it to a different folder to eliminate that variable if we want
Comment 23 Halla Rempt 2021-07-15 09:14:54 UTC
Could you please update to 4.4.5 and check whether that still happens? I see a lot of asserts in the log, and that's rather scary.
Comment 24 LKS 2021-07-23 23:14:40 UTC
New hardware, bigger doc (8k x 4k) same crash, will post all the info again
Comment 25 LKS 2021-07-23 23:16:59 UTC
Created attachment 140291 [details]
dxdiag info (PC 3)
Comment 26 LKS 2021-07-23 23:21:53 UTC
Created attachment 140292 [details]
Krita System Info PC 3
Comment 27 LKS 2021-07-23 23:22:22 UTC
Created attachment 140293 [details]
Krita Usage Log
Comment 28 LKS 2021-07-23 23:28:56 UTC
I'm currently on 4.4.5 as well, I'll try it out with a fresh portable install
Comment 29 LKS 2021-07-23 23:42:56 UTC
I was able to repro the crash repeatedly until I nuked my prefs, now the saving seems quite stable. Will keep trying
Comment 30 LKS 2021-07-24 01:02:09 UTC
Did a bunch of testing. Using all my regular kritarc prefs but disabling "compress krita files", "zip64", and "trim files" prevented crash. will try messing around with each setting on its own
Comment 31 Dmitry Kazakov 2021-07-30 05:38:37 UTC
Hi, LKS!

Thank you for all your info! I think I can reproduce the problem now. It happens because getLodCapableDevices() sometimes returns non-unique items, so race conditions happen.
Comment 32 Dmitry Kazakov 2021-07-30 05:47:36 UTC
Git commit d148fafb3c4b68ef9347b59ec624a1b8e0797b7e by Dmitry Kazakov.
Committed on 30/07/2021 at 05:47.
Pushed by dkazakov into branch 'master'.

Fix crash when saving the image with trimming

We should avoid concurrent write access to paint devices...

M  +4    -0    libs/image/kis_image.cc

https://invent.kde.org/graphics/krita/commit/d148fafb3c4b68ef9347b59ec624a1b8e0797b7e
Comment 33 Dmitry Kazakov 2021-07-30 05:48:36 UTC
Git commit a9da310311c98974b78e0cf26b95f342d48c53e1 by Dmitry Kazakov.
Committed on 30/07/2021 at 05:48.
Pushed by dkazakov into branch 'krita/4.3'.

Fix crash when saving the image with trimming

We should avoid concurrent write access to paint devices...

M  +4    -0    libs/image/kis_image.cc

https://invent.kde.org/graphics/krita/commit/a9da310311c98974b78e0cf26b95f342d48c53e1
Comment 34 Dmitry Kazakov 2021-07-30 05:50:44 UTC
I'm not sure we are able to release Krita 4.x update with this fix. If you are using Krita 4.x and face this bug, please disable "Trim files before saving" option in Krita preferences.
Comment 35 LKS 2021-07-30 08:02:42 UTC
Yey! Thanks for the fix, I have disabled trimming for now. Super happy to have found out what it was!