0
Under review

ShaderForge Editor Glitch

OnlyFals 8 years ago updated by Wenceslao Villanueva Jr 7 years ago 9

ShaderForge cannot render it's GUI or something and gives the follow error:


Image 683


NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SF_PassSettings.OnLocalGUI (Int32 yOffset, Int32 in_maxWidth)
ShaderForge.SF_Editor.DrawPreviewPanel (Rect r)
ShaderForge.SF_Editor.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Yeah no clue how to help you sorry, the choice to release this as a DLL means you can't debug it but by looking at your source I would take a wild guess and say this.ps used in this.ps.OnLocalGUI(yOffset2, (int)r.get_width()); on line #80 in SF_Editor.cs is null or something but without the source code to properly debug it I will never know.

Normally I would go into the source and fix broken assets like ProCore but because you don't want people knowing how awefully designed your code is I will expect you to fix it.


// ShaderForge.SF_Editor
public void DrawPreviewPanel(Rect r)
{
    Rect rect = new Rect(r);
    rect.set_y(rect.get_y() + 4f);
    rect.set_x(rect.get_x() + 2f);
    int num = 8;
    rect.set_height(17f);
    rect.set_width(rect.get_width() / 4f);
    rect.set_width(rect.get_width() + (float)num);
    GUIStyle miniButton = EditorStyles.get_miniButton();
    if (GUI.Button(rect, "Return to menu", miniButton))
    {
        this.OnPressBackToMenuButton();
    }
    rect.set_x(rect.get_x() + rect.get_width());
    rect.set_xMax(rect.get_xMax() - (float)(num * 2));
    rect.set_width(rect.get_width() * 0.75f);
    this.displaySettings = GUI.Toggle(rect, this.displaySettings, "Settings", miniButton);
    rect.set_x(rect.get_x() + rect.get_width());
    rect.set_width(rect.get_width() * 2f);
    GUI.set_color(SF_GUI.outdatedStateColors[(int)this.ShaderOutdated]);
    if (GUI.Button(rect, "Compile shader", miniButton))
    {
        if (this.nodeView.treeStatus.CheckCanCompile())
        {
            this.shaderEvaluator.Evaluate();
        }
    }
    GUI.set_color(Color.get_white());
    this.nodeView.DrawRecompileTimer(rect);
    rect.set_x(rect.get_x() + rect.get_width());
    rect.set_width(rect.get_width() * 0.5f);
    SF_Settings.autoCompile = GUI.Toggle(rect, SF_Settings.autoCompile, "Auto");
    rect.set_y(rect.get_y() + 4f);
    if (this.displaySettings)
    {
        rect.set_y(rect.get_y() + rect.get_height());
        rect.set_x(r.get_x() - 4f);
        rect.set_width(r.get_width() / 4f);
        rect.set_x(rect.get_x() + rect.get_width());
        rect.set_width(rect.get_width() * 2.55f);
        if (SF_Settings.nodeRenderMode == NodeRenderMode.Viewport)
        {
            EditorGUI.BeginDisabledGroup(true);
            GUI.Toggle(rect, true, "Real-time node rendering");
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            EditorGUI.BeginChangeCheck();
            SF_Settings.realtimeNodePreviews = GUI.Toggle(rect, SF_Settings.realtimeNodePreviews, "Real-time node rendering");
            if (EditorGUI.EndChangeCheck())
            {
                this.RegenerateNodeBaseData();
            }
        }
        rect = rect.MovedDown(1);
        SF_Settings.quickPickScrollWheel = GUI.Toggle(rect, SF_Settings.quickPickScrollWheel, "Use scroll in the quickpicker");
        rect = rect.MovedDown(1);
        SF_Settings.showVariableSettings = GUI.Toggle(rect, SF_Settings.showVariableSettings, "Show variable name & precision");
        rect = rect.MovedDown(1);
        SF_Settings.showNodeSidebar = GUI.Toggle(rect, SF_Settings.showNodeSidebar, "Show node browser panel");
        rect = rect.MovedDown(1);
        if (SF_GUI.HoldingControl())
        {
            EditorGUI.BeginDisabledGroup(true);
            GUI.Toggle(rect, !SF_Settings.hierarchalNodeMove, "Hierarchal Node Move");
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            SF_Settings.hierarchalNodeMove = GUI.Toggle(rect, SF_Settings.hierarchalNodeMove, "Hierarchal Node Move");
        }
        rect.set_y(rect.get_y() + 4f);
    }
    this.previewButtonHeightOffset = (int)rect.get_yMax() + 24;
    int yOffset = this.preview.OnGUI((int)rect.get_yMax(), (int)r.get_width());
    int yOffset2 = this.statusBox.OnGUI(yOffset, (int)r.get_width());
    this.ps.OnLocalGUI(yOffset2, (int)r.get_width());    // <-- Broken code here??
    if (SF_Debug.nodes)
    {
        GUILayout.Label("Node count: " + this.nodes.Count, new GUILayoutOption[0]);
    }
}
+3
Under review
Telling me I made a bad decision and calling my code awfully designed won't help. Telling me which Unity and SF version you were using, and when/how you triggered it, will though.
-4

Yeah whatever, I'm an angry old man so the sooner we deal with this the sooner you can get rid of me and I can update my review to 5 stars again.

My Unity version is:

Version 5.4.0f3 (a6d8d714de6f) Personal
Tue, 26 Jul 2016 22:13:57 GMT
Branch: 5.4/release

With SourceForge version: v1.28

+2

What did you do when it happened / do you have a repro case?

That's the thing, I just open the ShaderForge editor and if it doesn't hang Unity (which needs Task manager to terminate Unity) it does that instead.
When it is working though this will mostly happens as I press play button in the editor.

I uploaded a video of me demonstrating the bug in it's natural environment.


The video OP posted looks like a slightly different issue to what is visible in the screenshot he posted above. I wanted to chime in and say I am alsoe experiencing an issue that puts my shader forge in to a similar state to the screenshot he posted.


There are shader forge editor related errors in the console, the SF editor window is completely unresponsive and i can't Close the window. (mind you, the editor is still responsive). To correct the issue I have to restart Unity or alternatively kill the SF editor window by restoring the editor layout to default.


I'm not in the office right now but I'll try and remember to post repo steps when I get in to the office on Monday.


It is a very annoying bug and happens in between game start/stop. (For me anyway). Its really killing productivity, because I can't make changes, run the game, make more changes, stop the game, continue tweaking the shader, etc. It really breaks the workflow. Every time I want to change the play state I have to close the editor window for SF to make sure it doesn't break.


Again sorry I don't have note details right now. Will get back to you on Monday.

The tricky thing is that this is a very common symptom of a wide array of things that can happen. Essentially, this is the behavior of any null ref happening there. I'm unable to reproduce this, which is why I'll need a more clear repro case. I suspect it might have something to do with some specific nodes or specific settings that cause this to happen when pressing play.

I posted here as well with a similar crash: https://forum.unity3d.com/threads/shader-forge-a-visual-node-based-shader-editor.222049/page-109#post-2808284


OS X El Capitan on an iMac. I've tried Unity 5.3, 5.4 and various version of 5.4. I've reimported my project, reset all my layout settings.


So it looks like the reproduction steps are:

  1. Open Shader Forge
  2. Open a Shader
  3. Press Play
  4. Stop Play once your game is running
  5. Press Play again
  6. Stop Play
then Shader Forge window ceases to fully render and:


NullReferenceException: Object reference not set to an instance of an object

ShaderForge.SF_PassSettings.OnLocalGUI (Int32 yOffset, Int32 in_maxWidth)
ShaderForge.SF_Editor.DrawPreviewPanel (Rect r)
ShaderForge.SF_Editor.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)