yasirkula / UnityAssetUsageDetector

Find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. list the objects that refer to them

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StackOverflowException during search

TimmermanV opened this issue · comments

I just tested version 1.7.1 and got the following exception during search:

System.Collections.Generic.List`[T].get_Count () <0x14ba4be00 + 0x00013> in <1f0c1ef1ad524c38bbc5536809c46b48>:0
AssetUsageDetectorNamespace.ReferenceNode.NodeExistsInChildrenRecursive (AssetUsageDetectorNamespace.ReferenceNode node) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:794)
AssetUsageDetectorNamespace.ReferenceNode.NodeExistsInChildrenRecursive (AssetUsageDetectorNamespace.ReferenceNode node) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:802)
AssetUsageDetectorNamespace.ReferenceNode.NodeExistsInChildrenRecursive (AssetUsageDetectorNamespace.ReferenceNode node) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:802)
AssetUsageDetectorNamespace.ReferenceNode.NodeExistsInChildrenRecursive (AssetUsageDetectorNamespace.ReferenceNode node) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:802)
etc... (removed many identical lines)
AssetUsageDetectorNamespace.ReferenceNode.NodeExistsInChildrenRecursive (AssetUsageDetectorNamespace.ReferenceNode node) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:802)
AssetUsageDetectorNamespace.Ref<message truncated>

After this exception a few more issues popped up, but they are probably the result of the first issue:

GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
ArgumentException: Getting control 21's position in a group with only 21 controls when doing repaint
Aborting
UnityEngine.GUILayoutGroup.GetNext () (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/LayoutGroup.cs:122)
UnityEngine.GUILayoutUtility.DoGetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUILayoutUtility.cs:464)
UnityEngine.GUILayoutUtility.GetRect (System.Single width, System.Single height, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUILayoutUtility.cs:441)
UnityEngine.GUILayout.Space (System.Single pixels) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUILayout.cs:219)
AssetUsageDetectorNamespace.SearchResultGroup.DrawOnGUI (AssetUsageDetectorNamespace.SearchResultDrawParameters parameters) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:653)
AssetUsageDetectorNamespace.SearchResult.DrawOnGUI (AssetUsageDetectorNamespace.SearchResultDrawParameters parameters) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:184)
AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow.OnGUI () (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:540)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:335)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:329)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:305)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:340)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:295)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:481)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:455)
UnityEngine.UIElements.UIR.ImmediateRenderer.Draw (UnityEngine.UIElements.UIR.DrawChainState dcs) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderers.cs:447)
UnityEngine.UIElements.UIR.UIRenderDevice.ContinueChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.UIElements.UIR.DrawChainState dcs, System.Boolean outerChainsWithMeshRenderer) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:865)
UnityEngine.UIElements.UIR.UIRenderDevice.DrawChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.Rect viewport, UnityEngine.Matrix4x4 projection, UnityEngine.Texture atlas) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:848)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:218)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:190)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:70)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:589)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

Wow, your project surely is capable of finding all the edge cases 😄 This one will be harder to debug though. Somehow, a cyclic graph is generated but the callStack inside AssetUsageDetector.SearchObject function is supposed to prevent it. I'm assuming that this issue didn't occur on previous versions and that it occurs when you click the "GO!" button in the AssetUsageDetector window.

  1. Could you comment out these lines and see if it changes anything:

    if( !isInPlayMode || referenceNode.nodeObject.IsAsset() )
    {
    SerializedObject so = new SerializedObject( (Object) referenceNode.nodeObject );
    SerializedProperty iterator = so.GetIterator();
    if( iterator.NextVisible( true ) )
    {
    bool enterChildren;
    do
    {
    ReferenceNode searchResult;
    switch( iterator.propertyType )
    {
    case SerializedPropertyType.ObjectReference:
    searchResult = SearchObject( iterator.objectReferenceValue );
    enterChildren = false;
    break;
    case SerializedPropertyType.ExposedReference:
    searchResult = SearchObject( iterator.exposedReferenceValue );
    enterChildren = false;
    break;
    case SerializedPropertyType.Generic:
    searchResult = null;
    enterChildren = true;
    break;
    default:
    searchResult = null;
    enterChildren = false;
    break;
    }
    if( searchResult != null )
    {
    if( searchResult != referenceNode )
    referenceNode.AddLinkTo( searchResult, "Variable: " + iterator.propertyPath );
    else
    PoolReferenceNode( searchResult );
    }
    } while( iterator.NextVisible( enterChildren ) );
    return;
    }
    }

  2. If it doesn't work, please try commenting out these lines, as well:

    if( objectsToSearchSet.Contains( prefab ) && assetsToSearchRootPrefabs.ContainsFast( prefab as GameObject ) )
    referenceNode.AddLinkTo( GetReferenceNode( prefab ), "Prefab object" );

The issue seems to occur in v1.7 and v1.7.1. Earlier versions v1.5.1 and v1.5.6 didn't have the issue.
The errors show up in the console at the end of the search when the results are presented.
I have tried commenting out both 1226-1267 and 966-967 as you suggested. That doesn't seem to make a difference.

OK this version should get rid of the StackOverflowException. As a bonus, the rendering of search results are now handled via GUI instead of GUILayout which should increase the GUI performance significantly. Could you please test the new version when you have some spare time?

How do I use that archive? Extracting the files, it looked like it might be a unitypackage file, but I tried changing the extension to unitypackage and Unity just said "Nothing to import".

There is a unitypackage inside the zip. You should first unzip the file and then import the unitypackage to your project.

Ah, for some reason when extracting the zip, my zip program (on MacOS) decided to unpack the unitypackage as well. (I guess it tried to be helpful as unitypackage is also just a zip file) I used the command line unzip which worked fine.

The stack overflow is gone, but now I get this error:

IndexOutOfRangeException: Index was outside the bounds of the array.
AssetUsageDetectorNamespace.SearchResultGroup.GenerateGUINodes (AssetUsageDetectorNamespace.SearchResultDrawParameters parameters) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:765)
AssetUsageDetectorNamespace.SearchResultGroup.DrawOnGUI (AssetUsageDetectorNamespace.SearchResultDrawParameters parameters) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:645)
AssetUsageDetectorNamespace.SearchResult.DrawOnGUI (AssetUsageDetectorNamespace.SearchResultDrawParameters parameters) (at Assets/Plugins/AssetUsageDetector/Editor/SearchResult.cs:204)
AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow.OnGUI () (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:540)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:335)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:329)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:305)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:340)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:295)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:481)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:455)
UnityEngine.UIElements.UIR.ImmediateRenderer.Draw (UnityEngine.UIElements.UIR.DrawChainState dcs) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderers.cs:447)
UnityEngine.UIElements.UIR.UIRenderDevice.ContinueChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.UIElements.UIR.DrawChainState dcs, System.Boolean outerChainsWithMeshRenderer) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:865)
UnityEngine.UIElements.UIR.UIRenderDevice.DrawChain (UnityEngine.UIElements.UIR.RendererBase head, UnityEngine.Rect viewport, UnityEngine.Matrix4x4 projection, UnityEngine.Texture atlas) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRenderer/UIRenderDevice.cs:848)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:218)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:190)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:70)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:589)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)```

Full drawing mode seems to be fine, but Shorter and Shortest produce these errors.

Yes, my mistake. Please change references.Count to guiNodes.Length at lines 764 and 772. Thanks again for your continuous support 😃

P.S. This is the latest version of the plugin; I've modified it a little bit more to get rid of some redundant references that showed up in the results.

That last version works great. And you're welcome. Thanks for the awesome software!