Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Strange Code Execution when Building

Discussion in '2017.3 Beta' started by Sluggy, Nov 29, 2017.

  1. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    983
    I've made quite a few changes since installing 2017.3.11b today so it's hard for me to tell if things have always been this way and I've just never noticed or if something is really wrong.

    When trying to make a build of my project I'm getting a NullReference exception. The really odd thing is that the root of the execution appears to happen from a script's OnEnable() method. On top of that, the function that is throwing the exception is encapsulated within an #if UNITY_EDITOR conditional block. I know that Unity has a nasty habit of calling OnEnable() and OnDisable() at seemingly odd times but I've never noticed it before during a build. Is this a bug or something that has always happened and I've just now stumbled upon it?
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi Sluggy,
    Could you please submit a bug report with a minimal reproduction case and reply in here with the case #?
     
  3. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    983
    Unfortunately, or perhaps fortunately depending on how you view it, once I commented out the offending code and got things to compile, restoring the code no longer throws the exception.

    I did investigate a little more and at this point I'm going to chalk this up to some very strange interactions between a newly integrated asset and some of my own code - everything from asset linking to code emittance is involved in the process and this was likely just a fluke in the system that caused some random object to be temporarily instantiated at an invalid point during the build.

    If something does pop up again, I'll see if I can't track it down.
     
    charlesb_rm and LeonhardP like this.
  4. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    983
    I'm still having no luck reproducing this issue in a repo project or even reliably in my actual project. But now that it has happened again I did at least have the presence of mind to copy the stack trace log. It is occurring specifically with code in the NodeCanvas asset available on the asset store.

    The stack trace indicates that a partial class 'Graph.cs' deriving from scriptable object is having its OnEnable method executed during the BuildAndRun operation. From there, it eventually gets to a portion of code that is wrapped in a UNITY_EDITOR conditional compilation block and is attempting to get an icon from and editor folder at which point it poops out the null reference error due to the lack of the icon.

    NullReferenceException: Object reference not set to an instance of an object
    ParadoxNotion.Design.UserTypePrefs.GetTypeIcon (System.Type type, Boolean fallbackToDefault) (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/_Commons/Design/PartialEditor/UserTypePrefs.cs:255)
    FlowCanvas.Port.CacheGUIContent () (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Ports.cs:46)
    FlowCanvas.Port..ctor (FlowCanvas.FlowNode parent, System.String name, System.String ID) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Ports.cs:22)
    FlowCanvas.ValueInput..ctor (FlowCanvas.FlowNode parent, System.String name, System.String ID) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Ports.cs:237)
    FlowCanvas.ValueInput`1[System.Boolean]..ctor (FlowCanvas.FlowNode parent, System.String name, System.String ID) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Ports.cs:266)
    FlowCanvas.FlowNode.AddValueInput[Boolean] (System.String name, System.String ID) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/FlowNode.cs:280)
    FlowCanvas.Nodes.UniversalDelegateParam`1[System.Boolean].RegisterAsInput (FlowCanvas.FlowNode node) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Nodes/Functions/Reflected/Internal/BaseTypes/UniversalDelegateParam.cs:48)
    FlowCanvas.Nodes.JitMethodNode.RegisterPorts (FlowCanvas.FlowNode node, ReflectedMethodRegistrationOptions options) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Nodes/Functions/Reflected/Internal/Method/JitMethodNode.cs:202)
    FlowCanvas.Nodes.ReflectedMethodNodeWrapper.RegisterPorts () (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/Nodes/Functions/Reflected/ReflectedMethodNodeWrapper.cs:117)
    FlowCanvas.FlowNode.GatherPorts () (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/FlowNode.cs:198)
    FlowCanvas.FlowNode.OnValidate (NodeCanvas.Framework.Graph flowGraph) (at Assets/Standard Assets/ParadoxNotion/FlowCanvas/Module/FlowNode.cs:76)
    NodeCanvas.Framework.Graph.Validate () (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/Runtime/Graphs/Graph.cs:230)
    UnityEngine.Logger:LogException(Exception)
    ParadoxNotion.Services.Logger:ForwardToUnity(LogType, Object, String, Object) (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/_Commons/Runtime/Services/Logger.cs:90)
    ParadoxNotion.Services.Logger:Internal_Log(LogType, Object, String, Object) (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/_Commons/Runtime/Services/Logger.cs:84)
    ParadoxNotion.Services.Logger:LogException(Exception, String, Object) (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/_Commons/Runtime/Services/Logger.cs:47)
    NodeCanvas.Framework.Graph:Validate() (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/Runtime/Graphs/Graph.cs:231)
    NodeCanvas.Framework.Graph:OnEnable() (at Assets/Standard Assets/ParadoxNotion/NodeCanvas/Framework/Runtime/Graphs/Graph.cs:79)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()