AcademySoftwareFoundation / MaterialX

MaterialX is an open standard for the exchange of rich material and look-development content across applications and renderers.
http://www.materialx.org/
Apache License 2.0
1.87k stars 352 forks source link

Graph Editor: crashes on `could not find a nodedef for node` #1448

Closed marwie closed 1 year ago

marwie commented 1 year ago

Hello,

I'm currently working on generating MaterialX graphs and naturally produce some invalid results.

When selecting some of those falsely produced nodes the editor crashes. Below is an example graph that produces a crash

Expected: Invalid graph nodes are marked in the graph and can be selected without crashing the editor Actual: When selecting invalid / not found graph nodes the editor crashes

<?xml version="1.0"?>
<materialx name="" version="1.38" >
    <nodegraph name="needle_shadergraph" >
        <input name="_MyColor" type="color3" value="0.8962264, 0.2494215, 0.2494215, 1.0" />
    </nodegraph>
    <standard_surface name="needle_standard_surface" type="surfaceshader" >
        <input name="SurfaceDescription.BaseColor" interfacename="_MyColor" />
        <input name="SurfaceDescription.Smoothness" type="float" value="1.0" />
        <input name="SurfaceDescription.Metallic" type="float" value="1.0" />
    </standard_surface>
    <surfacematerial name="Default" type="material" >
        <input name="surfaceshader" type="surfaceshader" nodename="needle_standard_surface" />
    </surfacematerial>
</materialx>

20230816-092012_MaterialX_Graph_Editor-needle

jstone-lucasfilm commented 1 year ago

Great catch, @marwie, and I believe that we should follow the approach in MaterialXView and display a warning dialog when this exception is caught in the Graph Editor, so that invalid input data never triggers a crash.

jstone-lucasfilm commented 1 year ago

@marwie I'm testing this in a local build of the main branch, and it looks like this issue is now resolved, where the user can select and dive into the nodes of your example material without a crash. Let us know how this works for you in your local builds.