Undo fails in embedded nested graphs

Rimevel 2 months ago • updated by Lazlo Bonin (Lead Developer) 3 weeks ago 16

I was working on a small state machine with two flows and deleted a couple units that I actually needed. So out of habit I pressed ctrl + z and the whole state machine and everything inside the states got corrupted.

After Corruption

NullReferenceException: Object reference not set to an instance of an object
Bolt.State.get_incomingTransitions () <IL 0x00006, 0x00065>
Bolt.StateDescriptor`1<Bolt.FlowState>.IsEntered (Bolt.IState,Ludiq.Recursion) <0x00137>
Bolt.StateDescriptor`1.IsEntered () <0x000ce>
(wrapper dynamic-method) System.Runtime.CompilerServices.ExecutionScope.lambda_method (System.Runtime.CompilerServices.ExecutionScope,Bolt.StateDescriptor`1<Bolt.FlowState>) <IL 0x00006, 0x0006c>
Ludiq.InstanceFunctionInvoker`2<Bolt.StateDescriptor`1<Bolt.FlowState>, bool>.InvokeUnsafe (object) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/InstanceFunctionInvoker_0.cs:50)
Ludiq.InstanceFunctionInvoker`2<Bolt.StateDescriptor`1<Bolt.FlowState>, bool>.Invoke (object) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/InstanceFunctionInvoker_0.cs:31)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Ludiq.InstanceFunctionInvoker`2<Bolt.StateDescriptor`1<Bolt.FlowState>, bool>.Invoke (object) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/InstanceFunctionInvoker_0.cs:39)
Ludiq.Member.Invoke () (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/Member.cs:809)
Ludiq.DescriptionAssignment._Run (Ludiq.IDescriptor,Ludiq.IDescription) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Editor/Descriptors/DescriptionAssignment.cs:69)
Ludiq.DescriptionAssignment.Run (Ludiq.IDescriptor,Ludiq.IDescription) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Editor/Descriptors/DescriptionAssignment.cs:42)
Ludiq.Descriptor`2.Describe () <0x0019b>
Ludiq.DescriptorProvider.GetDecorator (Ludiq.IDescribable) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Editor/Descriptors/DescriptorProvider.cs:31)
Ludiq.XDescriptorProvider.Descriptor (Ludiq.IDescribable) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Editor/Descriptors/DescriptorProvider.cs:61)
Ludiq.XDescriptorProvider.Description (Ludiq.IDescribable) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Editor/Descriptors/DescriptorProvider.cs:71)
Ludiq.GraphDescriptor`2.Title () <0x00124>
(wrapper dynamic-method) System.Runtime.CompilerServices.ExecutionScope.lambda_method (System.Runtime.CompilerServices.ExecutionScope,Ludiq.GraphDescriptor`2<Bolt.FlowGraph, Ludiq.GraphDescription>) <IL 0x00006, 0x0006a>
Ludiq.InstanceFunctionInvoker`2<Ludiq.GraphDescriptor`2<Bolt.FlowGraph, Ludiq.GraphDescription>, string>.InvokeUnsafe (object) <0x0009b>
Ludiq.InstanceFunctionInvoker`2<Ludiq.GraphDescriptor`2<Bolt.FlowGraph, Ludiq.GraphDescription>, string>.Invoke (object) <0x000ca>
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
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:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:232)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Hi Rimevel, welcome to the community!

I'm sorry you're experiencing this issue.

Undo issues are hard to debug because I can't reproduce them from your project.

Can you be more specific as to what you were doing and where you were?

Were you in a flow graph of a state when you started undoing, or were you in the root state?

If you restart Unity, can you access the graph without the error?

I was inside the one of the in my state flows and pressed ctrl + z right after having deleted multiple units at once. Can't really explain it in more detail :/ All the units disappeared and when I backed out to the root level it looked like the picture I linked.

I redid the graph though so I can't really test if it was temporary or not. I will inform you in this topic if it happens again!

I have the same problem. After pressing CTRL+Z .. the State Graph window is becoming blank and I see the error: 

NullReferenceException: Object reference not set to an instance of an object
Bolt.State.get_incomingTransitions () (at C:/Users/Lazlo/Projects/Ludiq/Bolt.State/Runtime/State.cs:68)

I can easily reset the window by select another object with Flow machine and returned back.

I'm having trouble reproducing this.

Can you please pay attention to *what* you are undoing when the error pops?


Does Bolt even support Ctrl-Z to  undo in a graph? I assume so based on this thread.

Under Review

Yes, Bolt supports undo everywhere. This is a bug.

Ahh. Since I did not see it listed in http://support.ludiq.io/topics/129-windows-shortcuts/ I never even consideted trying it. 

Have not had this issue yet, fingers crossed. I just finished a whole inventory system and no issues.

Today I will play around with some states and see if I get the Ctrl Z bug.

Been able to isolate and reproduce.

This only happens on embedded nested graphs (e.g. flow states, super units, state units, super states, etc.).

Depending on the case it can either throw an error or fail silently (while leaving you working on a ghost graph!).

It's an issue with object persistence across serialization and won't be easy to fix, but it's a major bug and I'll get started immediately.

In the mean time, if it ever happens to you, you can click on the root graph in the breadcrumbs and work your way back down.


Glad to see you have been able to reproduce it :)
In the meantime I have made it a habit to just rebuild stuff instead of undoing when working in nested graphs.


Update on this: it wasn't easy, but I have a fix in place!

I'll spend some more time testing tomorrow to ensure that everything is robust.