bnpr / Malt

Render framework for NPR.
https://malt3d.com
Other
952 stars 75 forks source link

Nasty Crash correlated with a Malt Node Tree #560

Open dibli-goost opened 1 month ago

dibli-goost commented 1 month ago

Malt version

Node Groups

Blender version

Blender 4.1.1

OS

Windows 10

Hardware info

AMD Ryzen Threadripper 1920x 12-Core Processor, 3950 Mhz, 24 Logical Processors | 32GB RAM | NVIDIA GeForce GTX 1080 Ti

Issue description and reproduction steps

I'm not 100% positive that this crash is being caused due to Malt, I can reproduce via this file with factory defaults as well. The node tree was appended out of a project that was crashing on load, I was trying to figure out what was causing the crash and then I happened upon this node tree.

There's some bad nodes in there, I don't think they're the source of the issue, but I couldn't delete them because that'll cause blender to immediately crash.

To reproduce, all you should have to do is open the file and then open a new or different file. Blender should immediately crash.

Attachments

malt 2024-06-10(01-28).log

nodetree bug.crash.txt

nodetree bug.zip


Here's the crash from the character file, maybe it's the same thing.

Corsi Vinifera.crash.txt

dibli-goost commented 4 weeks ago

This is a much more cut-down version of the blend. Same reproduction steps, just need to open the file and then attempt to open another one. It'll immediately crash.

nodetree.zip

I got back the progress I had made on that character file, redoing a bunch of stuff from the past couple of days, and I wound up running into the same crash on load again. Only started to happen once I started making changes to that node tree.

I'm guessing the node tree is corrupted, so I'm just going to rebuild the node tree from scratch in that character project and hope it doesn't happen again.

pragma37 commented 3 weeks ago

The issue seems to happen specifically with the Line Width property of the MAIN PIXEL SHADER Output node in Skin Node Tree. The internal Blender property seemingly has become corrupted. But this is not something that Malt or any other addon should be able to cause, no matter what. I don't think there's any way to work around this issue from the Python/addon side. I'll ask if it's ok to open a report for this on the Blender bug tracker.

ksami commented 2 weeks ago

I think I'm running into a similar corruption issue, seems to happen when I try to undo something like adding an image node though I haven't been able to reliably reproduce it. It also affects previous autosaves and incremental saves where they crash immediately when opening Blender.

Since it's a Blender bug I guess there's no choice but to wait. In the meantime, does this mean it would be safer to use code based materials for now?

For anyone else trying to recover their work, here are the steps I took:

  1. Start a new blend file
  2. File > Append... and select the scene from the crashed file
  3. From the outliner, switch the Display Mode from View Layer to Blender File, delete the material linked to the affected node group (deleting the node group directly causes a crash)
  4. File > Cleanup > Unused Data-Blocks and the affected node group should now be deleted with no issues
dibli-goost commented 2 weeks ago

I got back the progress I had made on that character file, redoing a bunch of stuff from the past couple of days, and I wound up running into the same crash on load again. Only started to happen once I started making changes to that node tree.

It's back 😢 I was working on the same character project file for a bit, it seemed fine. Then I tried to load it about an hour ago and it's crashing on load.

It seems to have started occurring in a different node tree. I've appended it out and isolated as before. Blender crashes on trying to load a project after loading this one. I can also crash blender by just simply trying to delete either of the two remaining nodes in the node tree. I was able to get rid of every other node just fine.

Are these crashes still being caused by the Line Width Property? I haven't even touched it since starting these projects. But the last thing I did before the crashes started up again was plug that combine node into the main pass out.

x1.zip

For anyone else trying to recover their work, here are the steps I took:

Unfortunately, this isn't working for me. Blender crashes upon using the clean up operator.


Edit: If I delete the input props on the main pass, I can delete the node, but attempting to delete the combine will still crash. So it looks like it's corrupted too.

ksami commented 2 weeks ago

I don't think it's only caused by Line Width, I've had it happen with Image and Color Gradient in node trees where Line Width is not connected.

Did you ever undo anything in the node tree? My theory is undo-ing causes something between Blender and Malt to go out of sync, at least from what I understand from one of my Malt crash logs while trying to reproduce the crash by deleting and undo-ing an Image node.

Malt > INIT PIPELINE: C:\Users\...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderMalt\.MaltPath\Malt\Pipelines\NPR_Pipeline\NPR_Pipeline.py
Blender > Blender 4.1.1 b'blender-v4.1-release' b'e1743a0317bc'
Blender > Traceback (most recent call last):

Blender >
Blender >   File "C:\Users\...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderMalt\MaltNodes\MaltNodeTree.py", line 306, in update_ext
    source = self.get_generated_source(force_update=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Blender >
Blender >   File "C:\Users\...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderMalt\MaltNodes\MaltNodeTree.py", line 237, in get_generated_source
    shader[output.io_type] = get_source(output)
                             ^^^^^^^^^^^^^^^^^^

Blender >
Blender >   File "C:\Users\...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderMalt\MaltNodes\MaltNodeTree.py", line 231, in get_source
    code += node.get_source_code(transpiler) + '\n'
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Blender >
Blender >   File "C:\Users\...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderMalt\MaltNodes\Nodes\MaltFunctionNode.py", line 199, in get_source_code
    socket = self.inputs[parameter['name']]
             ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^

Blender >
Blender > KeyError: 'bpy_prop_collection[key]: key "base_color" not found'

Blender >

malt 2024-06-15(22-03).log blender-crash-240615.txt

Unfortunately, this isn't working for me. Blender crashes upon using the clean up operator.

Try saving the file before running the clean up operation, I had one attempt where though it crashed when running clean up, re-opening the file after the crash showed that the node was deleted.

pragma37 commented 1 week ago

I don't think it's only caused by Line Width, I've had it happen with Image and Color Gradient in node trees where Line Width is not connected.

I didn't mean to say it can only happen with Line Width, this is about Blender Python properties somehow getting corrupted. But in the linked file the corrupted property was Line Width. Also, being connected or not has nothing to do with it.


I've been looking deeper into this and I found a workaround to prevent the crash, but it requires patching Blender itself, and I doubt a workaround like that would be accepted without knowing what causes the corruption in the first place, so I'll have to look further into it.

ksami commented 1 week ago

👍 Thanks for looking into it!

pragma37 commented 4 days ago

I can't figure out the reason why this happens, so this is the best I can do for now:

Here's a custom build of Blender 4.1 that should allow you to load corrupted files without crashes https://drive.google.com/file/d/1wqRVISdip_eMbBMnM_pooBW1CEF6utHD/view?usp=sharing Once you have saved your file with this version, it should work again on the regular Blender release.

This version also prints the name of the corrupted property. For example: IDPROP ERROR: read_ui_data: U_0_main_pass_pixel_shader_output1_0_Line_Width (8) I'd appreciate it if you could post here your IDPROP ERROR messages, so we can (hopefully) find a pattern. Also, if you figure out a somewhat reliable way to generate a corrupted file, that would be massively useful.

I've also updated the Development and Node Groups versions of Malt to fully remove the use of the old Blender's _RNA_UI system. I have the suspicion that the issue might be related to this, but I can't say for sure.

So, long story short:

ksami commented 4 days ago

I had to run the patched Blender from Powershell to see the output, this is what I got from 2 separate corrupted files though still haven't found a reliable way to reproduce it IDPROP ERROR: read_ui_data: U_0_vector_4d1_0_a (8) IDPROP ERROR: read_ui_data: U_0_color_gradient1_0_Coord (8)

Will feedback on the new Malt version later

ksami commented 1 day ago

So I tried the latest Node Group version, no problems so far. In fact, I don't know if it's my imagination or not, but it seems a little smoother/faster now.