Console Error: You are pushing more GUIClips than you are popping. No OnGUI calls in my scripts.

Clicking on a console message (in both editor and runtime) causes three errors to appear indefinitely. I see the error icon in the corner going up but the console itself goes blank while the errors are logged. This didn’t happen at the start of our workflow so it would seem like it’s not simply a bug in the Unity version (2019.1.0f2), but it also isn’t caused by anything during gameplay but simply by clicking on the console. There are no OnGUI calls in our entire solution.


Errors:

ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
System.String.Substring (System.Int32 startIndex, System.Int32 length) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
UnityEditor.ConsoleWindow.StacktraceWithHyperlinks (System.String stacktraceText) (at C:/buildslave/unity/build/Editor/Mono/ConsoleWindow.cs:823)
UnityEditor.ConsoleWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/ConsoleWindow.cs:740)
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 C:/buildslave/unity/build/Editor/Mono/HostView.cs:345)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:339)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:315)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
UnityEditor.DockArea.OldOnGUI () (at C:/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 C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:295)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:481)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:464)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:444)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/Events/IEventDispatchingStrategy.cs:64)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/Events/MouseEventDispatchingStrategy.cs:58)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:280)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:156)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:189)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:255)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)


ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
System.String.Substring (System.Int32 startIndex, System.Int32 length) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
UnityEditor.ConsoleWindow.StacktraceWithHyperlinks (System.String stacktraceText) (at C:/buildslave/unity/build/Editor/Mono/ConsoleWindow.cs:823)
UnityEditor.ConsoleWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/ConsoleWindow.cs:740)
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 C:/buildslave/unity/build/Editor/Mono/HostView.cs:345)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:339)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:315)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
UnityEditor.DockArea.OldOnGUI () (at C:/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 C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:278)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


The errors continue until I click the strip below the console, then they stop and I can see console messages again. But clicking a message still starts popping errors again.
alt text

Double clicking one of these console errors (after clicking the bottom strip to make them visible) results in this showing in inspector, but that’s all the additional information I have.
alt text

I’ve seen similar questions asked about the “pushing more GUIClips” error, that all say it’s something not ending properly when it begins. I can’t see how this would apply since

  • it only happens when clicking the console
  • We don’t have any OnGUI functions in our game other than property drawers (commenting those out doesn’t stop the error)

Clicking console messages is obviously a big part of debugging to open your scripts, and this interrupts that. It’s not causing any actual gameplay errors but I’d still like to either fix what’s wrong with something in my code or report it as a Unity bug.
Any thoughts, or should I go straight to filing a bug?

"Clicking on a console message " . Any console message? Only Exception messages? warnings? debug.logs?

Apart from that the issue seems to be most likely this line in the current reference source. This code wouldn’t execute if there is no file path info in the stacktrace of the currently viewed log entry. They expect the line info after the last colon “:” and the end delimiter should be a closing bracket “)”. However for some reason your stacktrace has a colon after the last closing bracket. This will place the start index after the end index and results in a negative length for the substring which will throw this exception. The other exceptions are just a consequence from the abnormal termination of the GUI code.

So yes it can be classified as bug as the code parsing the stacktrace is not written in a robust way. On the other hand the question is why this actually happens to you but nobody else has this issue. Is there anything special about your filenames / classnames? Have you checked the editor log for your original console errors that you actually selected in the console which produced this error?

You may want to do a few more tests and collect more data before you file a bug report.