Loop when selecting ConnectionGUI

Issue #71 resolved
Giordano D'Obici created an issue

Selecting a connection between nodes in the graph, causes a loop in the Editor (Unity 2017.1.1f1) due to

// ConnectionGUIEditor.cs line 15
private GroupViewController m_groupViewController;

not being Serializable, thus losing its state every time the selection changes. In particular, its m_group field always happen to be null when the method

// GroupViewController.cs line 82
public void SetGroups(Dictionary<string, List<AssetReference>> g) {
    if (m_groups != g) {
        m_groups = g;
        m_filteredGroups = ApplyFilter ();
        ReloadAndSelect ();
    }
}

gets called. Since m_groups is always null, ReloadAndSelect is called every update, and a new GroupViewController is created every time.

For now, I solved this by making the field static so it keeps it's state but I don't know if this is stable.

// ConnectionGUIEditor.cs line 15
private static GroupViewController m_groupViewController;

If I don't do this, the tool is completely unusable because it stalls the Editor due to the loop.

Thank you for this invaluable tool, anyway. I started using it some time ago and it just made it possible to work with AssetBundles when it wasn't possible otherwise.

Comments (6)

  1. Hiroki Omae

    @dogiordano Hi, can you confirm if this still happens in 1.4/release? I am having hard time reproducing this issue. Can you also confirm if this issue happen in newer version of Unity (2017.1.2f1, 2017.2.x...). Also please test with vanilla unity project without other editor extensions.

  2. Giordano D'Obici reporter

    I re-tested version 1.3 in a clean project and the loop didn't happen. I went back to the other project removing my temporary fix and I noticed in the title bar of Unity Editor, it was looping between all the scenes I have in the project (and apparently it doesn't stop until I select something else in the editor).

    Scenes being opened in background could be what's causing the GroupViewController to lose its state (since Unity probably serializes the Editor before loading a different scene).

    I added a script logging something every time it's enabled (even in edit mode) so I was able to see the following stack trace that maybe explains why scenes are being opened on their own:

    ...
    0x000000002B457E27 (Mono JIT Code) MyClass:OnEnable () 
    0x000000000AC469E2 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    0x00007FF99D785EDF (mono) [mini.c:4937] mono_jit_runtime_invoke 
    0x00007FF99D6D8731 (mono) [object.c:2623] mono_runtime_invoke 
    0x000000014140BF25 (Unity) scripting_method_invoke
    0x0000000141403FE1 (Unity) ScriptingInvocation::Invoke
    0x000000014115B37B (Unity) MonoBehaviour::CallMethodIfAvailable
    0x0000000141173E43 (Unity) MonoBehaviour::AddToManager
    0x000000014115C422 (Unity) MonoBehaviour::AwakeFromLoad
    0x0000000141428F21 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
    0x0000000141431C49 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
    0x00000001413C9607 (Unity) LoadSceneOperation::CompleteAwakeSequence
    0x00000001413C9AEA (Unity) LoadSceneOperation::CompletePreloadManagerLoadSceneEditor
    0x00000001413CE2F3 (Unity) LoadSceneOperation::IntegrateMainThread
    0x00000001413CD198 (Unity) PreloadManager::UpdatePreloadingSingleStep
    0x00000001413CD338 (Unity) PreloadManager::WaitForAllAsyncOperationsToComplete
    0x00000001406EA045 (Unity) EditorSceneManager::RestoreSceneBackups
    0x00000001406F00DA (Unity) EditorSceneManager::OpenSceneLoaded
    0x00000001406F1064 (Unity) EditorSceneManager::OpenScene
    0x000000014177609A (Unity) EditorSceneManager_CUSTOM_INTERNAL_CALL_OpenScene
    0x000000002B449C2B (Mono JIT Code) (wrapper managed-to-native) UnityEditor.SceneManagement.EditorSceneManager:INTERNAL_CALL_OpenScene (string,UnityEditor.SceneManagement.OpenSceneMode,UnityEngine.SceneManagement.Scene&)
    0x000000002B449A95 (Mono JIT Code) [EditorSceneManagerBindings.gen.cs:40] UnityEditor.SceneManagement.EditorSceneManager:OpenScene (string) 
    0x000000002B4496BE (Mono JIT Code) [AssetReference.cs:223] UnityEngine.AssetBundles.GraphTool.AssetReference:get_allData () 
    0x000000002B449207 (Mono JIT Code) [AssetReference.cs:267] UnityEngine.AssetBundles.GraphTool.AssetReference:GetRuntimeMemorySize () 
    0x000000002B448216 (Mono JIT Code) [GroupListTree.cs:74] UnityEngine.AssetBundles.GraphTool.GroupTreeViewItem:Reload () 
    0x000000002B447EAC (Mono JIT Code) [GroupListTree.cs:53] UnityEngine.AssetBundles.GraphTool.GroupTreeViewItem:get_fileSize () 
    0x000000002B4478CC (Mono JIT Code) [GroupListTree.cs:170] UnityEngine.AssetBundles.GraphTool.GroupListTree:CellGUI (UnityEngine.Rect,UnityEditor.IMGUI.Controls.TreeViewItem,int,UnityEditor.IMGUI.Controls.TreeView/RowGUIArgs&) 
    0x000000002B446A32 (Mono JIT Code) [GroupListTree.cs:150] UnityEngine.AssetBundles.GraphTool.GroupListTree:RowGUI (UnityEditor.IMGUI.Controls.TreeView/RowGUIArgs) 
    0x000000002B4463D0 (Mono JIT Code) [TreeViewControlGUI.cs:136] UnityEditor.IMGUI.Controls.TreeView/TreeViewControlGUI:OnContentGUI (UnityEngine.Rect,int,UnityEditor.IMGUI.Controls.TreeViewItem,string,bool,bool,bool,bool) 
    0x000000002B2E6D7F (Mono JIT Code) [TreeViewGUI.cs:290] UnityEditor.IMGUI.Controls.TreeViewGUI:DoItemGUI (UnityEngine.Rect,int,UnityEditor.IMGUI.Controls.TreeViewItem,bool,bool,bool) 
    0x000000002B2E21A4 (Mono JIT Code) [TreeViewGUI.cs:222] UnityEditor.IMGUI.Controls.TreeViewGUI:OnRowGUI (UnityEngine.Rect,UnityEditor.IMGUI.Controls.TreeViewItem,int,bool,bool) 
    0x000000002B2E17E6 (Mono JIT Code) [TreeViewController.cs:462] UnityEditor.IMGUI.Controls.TreeViewController:DoItemGUI (UnityEditor.IMGUI.Controls.TreeViewItem,int,single,bool) 
    0x000000002B2E0AA3 (Mono JIT Code) [TreeViewController.cs:621] UnityEditor.IMGUI.Controls.TreeViewController:IterateVisibleItems (int,int,single,bool) 
    0x000000002B2DDBAC (Mono JIT Code) [TreeViewController.cs:552] UnityEditor.IMGUI.Controls.TreeViewController:OnGUI (UnityEngine.Rect,int) 
    0x000000002B43C284 (Mono JIT Code) [TreeViewControl.cs:421] UnityEditor.IMGUI.Controls.TreeView:TreeViewWithMultiColumnHeader (UnityEngine.Rect) 
    0x000000002B43A3C3 (Mono JIT Code) [TreeViewControl.cs:395] UnityEditor.IMGUI.Controls.TreeView:OnGUI (UnityEngine.Rect) 
    0x000000002B439EBE (Mono JIT Code) [GroupListTree.cs:218] UnityEngine.AssetBundles.GraphTool.GroupListTree:OnGUI (UnityEngine.Rect) 
    0x000000002B4396A5 (Mono JIT Code) [GroupViewController.cs:138] UnityEngine.AssetBundles.GraphTool.GroupViewController:OnGroupViewGUI () 
    0x000000002B4307D8 (Mono JIT Code) [ConnectionGUIEditor.cs:54] UnityEngine.AssetBundles.GraphTool.ConnectionGUIEditor:OnInspectorGUI () 
    0x000000002B3571F6 (Mono JIT Code) [InspectorWindow.cs:1240] UnityEditor.InspectorWindow:DrawEditor (UnityEditor.Editor[],int,bool,bool&,UnityEngine.Rect&) 
    0x000000002B353C86 (Mono JIT Code) [InspectorWindow.cs:1021] UnityEditor.InspectorWindow:DrawEditors (UnityEditor.Editor[]) 
    0x000000002B350245 (Mono JIT Code) [InspectorWindow.cs:362] UnityEditor.InspectorWindow:OnGUI () 
    0x000000000AC469E2 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    0x00007FF99D785EDF (mono) [mini.c:4937] mono_jit_runtime_invoke 
    0x00007FF99D6D8731 (mono) [object.c:2623] mono_runtime_invoke 
    0x00007FF99D6DEC3F (mono) [object.c:3838] mono_runtime_invoke_array 
    0x00007FF99D69D0F7 (mono) [icall.c:2750] ves_icall_InternalInvoke 
    0x000000000AC10257 (Mono JIT Code) (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
    0x000000000AC0E3B2 (Mono JIT Code) [MonoMethod.cs:222] System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) 
    0x000000002AE6A25F (Mono JIT Code) [MethodBase.cs:115] System.Reflection.MethodBase:Invoke (object,object[]) 
    0x000000002AEDD155 (Mono JIT Code) [HostView.cs:272] UnityEditor.HostView:Invoke (string,object) 
    0x000000002AEDCFFA (Mono JIT Code) [HostView.cs:265] UnityEditor.HostView:Invoke (string) 
    0x000000002B23A803 (Mono JIT Code) [HostView.cs:232] UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect) 
    0x000000002B22EE47 (Mono JIT Code) [DockArea.cs:407] UnityEditor.DockArea:OldOnGUI () 
    0x000000002B2287BF (Mono JIT Code) [IMGUIContainer.cs:115] UnityEngine.Experimental.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event) 
    0x000000002B227BE4 (Mono JIT Code) [IMGUIContainer.cs:188] UnityEngine.Experimental.UIElements.IMGUIContainer:HandleEvent (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement) 
    0x000000002B227527 (Mono JIT Code) [IMGUIContainer.cs:38] UnityEngine.Experimental.UIElements.IMGUIContainer:DoRepaint (UnityEngine.IStylePainter) 
    0x000000002B1E73D2 (Mono JIT Code) [Panel.cs:425] UnityEngine.Experimental.UIElements.Panel:PaintSubTree (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement,UnityEngine.Matrix4x4,UnityEngine.Rect) 
    0x000000002B1E771C (Mono JIT Code) [Panel.cs:435] UnityEngine.Experimental.UIElements.Panel:PaintSubTree (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement,UnityEngine.Matrix4x4,UnityEngine.Rect) 
    0x000000002B1D9E68 (Mono JIT Code) [Panel.cs:450] UnityEngine.Experimental.UIElements.Panel:Repaint (UnityEngine.Event) 
    0x000000002B1D97AF (Mono JIT Code) [UIElementsUtility.cs:178] UnityEngine.Experimental.UIElements.UIElementsUtility:DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel) 
    0x000000002B1D948B (Mono JIT Code) [UIElementsUtility.cs:71] UnityEngine.Experimental.UIElements.UIElementsUtility:ProcessEvent (int,intptr) 
    0x000000002B1D8FAD (Mono JIT Code) [GUIUtility.cs:186] UnityEngine.GUIUtility:ProcessEvent (int,intptr) 
    0x000000002B1D916E (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_bool_int_intptr (object,intptr,intptr,intptr)
    0x00007FF99D785EDF (mono) [mini.c:4937] mono_jit_runtime_invoke 
    0x00007FF99D6D8731 (mono) [object.c:2623] mono_runtime_invoke 
    0x000000014140BF25 (Unity) scripting_method_invoke
    0x0000000141403FE1 (Unity) ScriptingInvocation::Invoke
    0x00000001401BEAAB (Unity) GUIView::ProcessRetainedMode
    0x0000000140029EC5 (Unity) GUIView::OnInputEvent
    0x00000001401B1753 (Unity) GUIView::ProcessInputEvent
    0x0000000140006EE6 (Unity) GUIView::DoPaint
    0x0000000140013660 (Unity) GUIView::RepaintAll
    0x00000001401093B7 (Unity) Application::UpdateScene
    0x000000014010D54F (Unity) Application::UpdateSceneIfNeeded
    0x00000001401318BF (Unity) Application::TickTimer
    0x0000000141A8A84D (Unity) MainMessageLoop
    

    I didn't manage to understand, what's causing the different behaviour between my project and a clean one, though.

  3. Hiroki Omae

    Thanks @dogiordano this callstack gives me idea why causing issue.

    0x000000002B4496BE (Mono JIT Code) [AssetReference.cs:223] UnityEngine.AssetBundles.GraphTool.AssetReference:get_allData () 0x000000002B449207 (Mono JIT Code) [AssetReference.cs:267] UnityEngine.AssetBundles.GraphTool.AssetReference:GetRuntimeMemorySize ()

    These two lines are the source of problem which causes scene data to be loaded (which should not happen). I have fixed this issue a while ago in 1.4 and just pushed fix to 1.3.

  4. Log in to comment