github-for-unity / Unity

GitHub for Unity
https://unity.github.com/
MIT License
3.02k stars 448 forks source link

Repeating nullref that we can't get rid of (to do with AssetGraph package) - unlocked everything, restarted unity, etc #1110

Closed pt-paulrahme closed 4 years ago

pt-paulrahme commented 4 years ago

Prerequisites

log file contents:

200603-16:14:01.198  INFO [ 1] <Global>                            Initializing GitHubForUnity:'v1.4.0' Unity:'v2019.2.21f1'
200603-16:14:26.394  INFO [ 1] <Global>                            Initializing GitHubForUnity:'v1.4.0' Unity:'v2019.2.21f1'
200603-16:41:24.181  INFO [ 1] <Global>                            Initializing GitHubForUnity:'v1.4.0' Unity:'v2019.2.21f1'
4:45
github-unity.log

(Note this is after unlocking everything and restarting Unity, but it hasn't stopped the exception occuring)

Description

One of our team is having the following error repeatedly spitting out to his console:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.AssetGraph.AssetGraphPostprocessor.HandleAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Library/PackageCache/com.unity.assetgraph@1.6.0-preview/Editor/System/Core/AssetGraphPostprocessor.cs:109)
UnityEngine.AssetGraph.AssetGraphPostprocessor.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Library/PackageCache/com.unity.assetgraph@1.6.0-preview/Editor/System/Core/AssetGraphPostprocessor.cs:95)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>: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 <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <567df3e0919241ba98db88bec4c6696f>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:662)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:146)
UnityEditor.AssetDatabase:SaveAssets()
GitHub.Unity.ExtensionLoader:Initialize() (at Assets/Plugins/GitHub/Editor/ExtensionLoader.cs:57)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions() (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:303)

He has unlocked all assets he had locked, committed everything, and tried closing & reopening the GitHub panel multiple times, as well as quitting and restarting Unity multiple times.

Edit: He even deleted the entire Assets/Plugins/GitHub/ folder (the error went away), but then re-adding it made the error come back again. Seems to be something saved for this project/repo?

Steps to Reproduce

It just started happening for him, and it's not stopping. There didn't appear to be a specific action that caused it.

The rest of us have not seen this error.

Additional Information

The project is using Unity 2019.2.21f1, he is on Windows, and had locked one Scene, one Prefab, and a few .cs files. Our project does include the AssetGraph package, which is what seems to be throwing the exception (when triggered (rom GitHub.UnityExtensionLoader.Initialize).

shana commented 4 years ago

@pt-paulrahme

This is an error being thrown when AssetDatabase.SaveAssets() is called. That's a really common call that scripts make to flush dirty assets to disk. In this case, GitHub for Unity is changing a flag in the meta files for the DLLs, so it won't load DLLs that are not appropriate for your project, and that causes a save to disk, I don't know why that would cause these errors. You can try commenting out line 57 of Assets/Plugins/GitHub/Editor/ExtensionLoader.cs and see if that makes it happier.

pt-paulrahme commented 4 years ago

Hi Shana, Thanks for the information. My colleague commented out that line and the error did go away. The main thing I'd be concerned about, is if it's still reliable for us to use across the team without that line in the code? Or could it cause it to eg. not refresh when assets update? Thanks

shana commented 4 years ago

@pt-paulrahme You might want to try the Unity fork over at https://github.com/Unity-Technologies/Git-for-Unity instead, it doesn't do any of this flag stuff because it's a source package, and I'm not likely to do fixes here. From the release page, download the first tgz on the asset list, com.unity.git-X.X.X-preview.tgz, and in the Unity Package Manager window, click on the top left + and select Add package from tarball to install the package.

pt-paulrahme commented 4 years ago

Thanks @shana - will check it out!