Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Constant NullReferenceException in GitHub.Unity.Window.Update() #1068

@DreadKyller

Description

@DreadKyller

Prerequisites

Trace logging is enabled, here is the log file contents:

190801-21:46:36.726  INFO [ 1] <Global>                            Initializing GitHubForUnity:'v1.4.0' Unity:'v2019.2.0f1'
190801-21:46:36.764 TRACE [150] <DownloadTask>                      Download of http://github-vs.s3.amazonaws.com/unity/latest.json to C:\Users\user\AppData\Local\GitHubUnity\latest.json Attempt 1 of 1
190801-21:46:36.910 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe --version'
190801-21:46:39.417 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git-lfs\git-lfs.exe version'
190801-21:46:39.848 TRACE [150] <DownloadTask>                      Downloading http://github-vs.s3.amazonaws.com/unity/latest.json
190801-21:46:40.071 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --local --unset merge.unityyamlmerge.cmd'
190801-21:46:41.159 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --local --unset merge.unityyamlmerge.trustExitCode'
190801-21:46:41.450 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --replace-all --local merge.unityyamlmerge.name "Unity SmartMerge (UnityYamlMerge)"'
190801-21:46:41.456 TRACE [150] <DownloadTask>                      Downloading http://github-vs.s3.amazonaws.com/unity/latest.json StatusCode:200
190801-21:46:41.579 TRACE [150] <Global>                            Skipping GitHub for Unity update v1.4.0, we already have it
190801-21:46:41.796 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --replace-all --local merge.unityyamlmerge.driver "'C:\Program Files\Unity\Hub\Editor\2019.2.0f1\Editor\Data\Tools\UnityYAMLMerge.exe' merge -h -p --force %O %B %A %A"'
190801-21:46:42.097 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --replace-all --local merge.unityyamlmerge.recursive "binary"'
190801-21:46:42.875 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe lfs install'
190801-21:46:47.308 TRACE [149] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --get --system credential.helper'
190801-21:46:47.805 TRACE [149] <RepositoryWatcher>                 Watching Path: "C:\Users\user\GameJam"
190801-21:46:47.813 TRACE [149] <IApplicationManager>               Got a repository? C:\Users\user\GameJam
190801-21:46:47.898 TRACE [ 1] <IApplicationManager>               Restarted C:\Users\user\GameJam
190801-21:46:47.906 TRACE [ 1] <GitLocksCache>                     needsInvalidation isInitialized:False timedOut:True
190801-21:46:47.918 TRACE [162] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git-lfs\git-lfs.exe locks --json'
190801-21:46:47.926 TRACE [ 1] <GitStatusCache>                    needsInvalidation isInitialized:False timedOut:True
190801-21:46:47.945 TRACE [156] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe -c i18n.logoutputencoding=utf8 -c core.quotepath=false --no-optional-locks status -b -u --porcelain'
190801-22:12:51.262 TRACE [ 1] <GitLocksCache>                     needsInvalidation isInitialized:True timedOut:True
190801-22:12:51.267 TRACE [177] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git-lfs\git-lfs.exe locks --json'
190801-22:12:51.274 TRACE [179] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git-lfs\git-lfs.exe locks --json'
190801-22:12:55.505 TRACE [ 1] <GitLogCache>                       needsInvalidation isInitialized:False timedOut:True
190801-22:12:55.516 TRACE [190] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe -c i18n.logoutputencoding=utf8 -c core.quotepath=false log --pretty=format:"%H%n%P%n%aN%n%aE%n%aI%n%cN%n%cE%n%cI%n%B---GHUBODYEND---" --name-status'
190801-22:12:55.519 TRACE [ 1] <GitAheadBehindCache>               needsInvalidation isInitialized:True timedOut:True
190801-22:12:55.530 TRACE [184] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe rev-list --left-right --count master...origin/master'
190801-22:18:25.607 TRACE [ 1] <GitUserCache>                      needsInvalidation isInitialized:False timedOut:True
190801-22:18:25.620 TRACE [202] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --get --global user.name'
190801-22:18:25.958 TRACE [213] <ProcessWrapper>                    Running 'C:\Users\user\AppData\Local\GitHubUnity\git\cmd\git.exe config --get --global user.email'

Doesn't seem to be printing anything about this error here.

Description

When the Changes tab is selected, even if the GitHub window is hidden/not actively being rendered, certain triggers cause the following error:

ArgumentException: You can only call GUI functions from inside OnGUI.
UnityEngine.GUIUtility.CheckOnGUI () (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:293)
UnityEngine.GUI.get_skin () (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:42)
GitHub.Unity.Styles.get_Label () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Utility.get_IsDarkTheme () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Styles.get_ActiveBranchIcon () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BranchesView.OnEnable () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Window.OnEnable () (at <2d57c10c727649ea8f13d21c5265f844>:0)

This error only occurs once or twice sometimes per trigger, after which the console will start getting spammed with the following error.

NullReferenceException: Object reference not set to an instance of an object
GitHub.Unity.Window.Update () (at <2d57c10c727649ea8f13d21c5265f844>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <a8ed250850854b439cedc18931a314fe>: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 <a8ed250850854b439cedc18931a314fe>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <a8ed250850854b439cedc18931a314fe>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:359)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:353)
UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:465)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:303)

The first error above appearently breaks something about the current instance of the GitHub window. Reloading the window by closing it and reopening from the Window -> GitHub context fixes the problem, but while the problem is active the GitHub window will cause errors on every update function, as long as it is being rendered, regardless of which tab of the GitHub window is selected, until it is closed and reopened. Why it suddenly starts trying to call rendering code from inside Update is unknown to me at this moment.

Notes about Reproducing

  1. No clue how to reproduce, it just seems to happen sometimes, I just migrated from 2019.1.12f1 to 2019.2.0f1 on a project before it started spamming the console immediately.
  2. In the past I've gotten the same error after a while, but it only effected certain tabs, this time it's effecting all tabs
  3. Closing the tab and reopening it via "Window -> GitHub" no longer was spamming my console, so whatever was causing it is reset by reopening the window or cleaned up when closing.

Edit:

I have been able to reproduce the error:

Steps:

  1. Select "Branches" tab. You may need to have a second branch other than master on local and remote, I'm not sure about this yet.
  2. Hit play on the game
  3. I get the following errors:
ArgumentException: You can only call GUI functions from inside OnGUI.
UnityEngine.GUIUtility.CheckOnGUI () (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:293)
UnityEngine.GUI.get_skin () (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:42)
GitHub.Unity.Styles.get_Label () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Utility.get_IsDarkTheme () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Styles.get_ActiveBranchIcon () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BranchesView.OnEnable () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Window.OnEnable () (at <2d57c10c727649ea8f13d21c5265f844>:0)
Exception: Style.Draw may not be called with GUIContent that is null.
UnityEngine.GUIStyle.Draw (UnityEngine.Rect position, UnityEngine.GUIContent content, System.Int32 controlId, System.Boolean isHover, System.Boolean isActive, System.Boolean on, System.Boolean hasKeyboardFocus) (at C:/buildslave/unity/build/Modules/IMGUI/GUIStyle.cs:269)
UnityEngine.GUIStyle.Draw (UnityEngine.Rect position, UnityEngine.GUIContent content, System.Boolean isHover, System.Boolean isActive, System.Boolean on, System.Boolean hasKeyboardFocus) (at C:/buildslave/unity/build/Modules/IMGUI/GUIStyle.cs:244)
GitHub.Unity.TreeNode.Render (UnityEngine.Rect rect, System.Single indentation, System.Boolean isSelected, System.Boolean treeIsBusy, UnityEngine.GUIStyle toggleStyle, UnityEngine.GUIStyle nodeStyle, UnityEngine.GUIStyle activeNodeStyle) (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Tree`2[TNode,TData].Render (UnityEngine.Rect treeDisplayRect, UnityEngine.Vector2 scroll, System.Action`1[T] singleClick, System.Action`1[T] doubleClick, System.Action`1[T] rightClick) (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BranchesView.OnTreeGUI (UnityEngine.Rect rect) (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BranchesView.Render () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BranchesView.OnGUI () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Window.DoActiveViewGUI () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.Window.OnUI () (at <2d57c10c727649ea8f13d21c5265f844>:0)
GitHub.Unity.BaseWindow.OnGUI () (at <2d57c10c727649ea8f13d21c5265f844>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <a8ed250850854b439cedc18931a314fe>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRChainBuilder.cs:238)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:66)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:54)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:72)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:637)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
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)

And after that the window will start spamming NullReferenceExceptions in GitHub.Unity.Window.Update() while the GitHub tab is displayed, until the tab is closed and reopened.

Edit 2:

More details, As long as the currently selected tab on the GitHub window is "Branches" then even if the GitHub tab isn't active the first error listed above after the first edit still prints, the one about "You can only call GUI functions inside of OnGUI". The console will them start spamming like usual once you switch to the GitHub window again.

Edit 3:

Apparently playing in the editor isn't the only thing that triggers this issue. The recompiling step when the script assets change also causes the same problem. In both cases it only happens specifically for the Branches tab, none of the others.

Edit 4:

The problematic line seems to be:

var hierarchyStyle = GUI.skin.FindStyle("PR Label");

Specifically the call to get the skin property runs CheckOnGUI which errors if not called during the OnGUI stage. Since this style information isn't needed until you actually render it's likely tht the call to get the Styles.ActiveBranchIcon could be moved somehow to the start of the rendering loop, and lazy-initialized instead of setup in the OnEnable, or a way to detect the Utility.IsDarkTheme without a call to GUI.skin

Honestly why this only causes a problem during certain processes is beyond me, from what I see this should happen any time the window is open and not just under certain cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions