NullReferenceException but

I got these errors whilst using Unity 2023.2.1f1:

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <454b8adca03e44db8a0e3ace7093e9b8>:0)
UnityEditor.SerializedObject.get_objectVersion () (at :0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingBase.GetViewHashCode () (at <62cff2935c2446f5b89d419f3e03f073>:0)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.GetDataSourceVersion (System.Object source) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.Update () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.Panel.UpdateForRepaint () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <91b38be7fe3447c2aa8de9080a0a1f98>:0)

and

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <454b8adca03e44db8a0e3ace7093e9b8>:0)
UnityEditor.SerializedObject.get_objectVersion () (at :0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingBase.GetViewHashCode () (at <62cff2935c2446f5b89d419f3e03f073>:0)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.GetDataSourceVersion (System.Object source) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.Update () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.Panel.UpdateDataBinding () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <342504bd0e804d8681580f16844e29e7>:0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <62cff2935c2446f5b89d419f3e03f073>:0)

The game is working fine, it is text based but includes various buttons. But, as I clicked on play, the errors started to gather rapidly and in a short amount of time, I wa sleft with:


the NullReferenceException errors were automatic and spammed a lot in the console.

Although I didn’t get it again, I want to know what is the cause of those errors as I can read it says sth related to binding.

We are working on a fix.

1 Like

Heya, I’m running into something similar on a similar editor version.

I’m glad to hear you’re working on a fix, but I couldn’t find any tickets related to this on the bug tracker: https://issuetracker.unity3d.com/

https://unity3d.com/search?refinement=issues&gq=UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException

Can you please provide a ticket number or additional context for this? Would love to know if it’s relevant to my case and if I can track its resolution.

Here are my very similar looking call stacks:

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj)
UnityEditor.SerializedObject.get_objectVersion ()
UnityEditor.UIElements.Bindings.SerializedObjectBindingBase.GetViewHashCode ()
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.GetDataSourceVersion (System.Object source)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.Update ()
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase)
UnityEngine.UIElements.Panel.UpdateForRepaint ()
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result)

and

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj)
UnityEditor.SerializedObject.get_objectVersion ()
UnityEditor.UIElements.Bindings.SerializedObjectBindingBase.GetViewHashCode ()
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.GetDataSourceVersion (System.Object source)
UnityEngine.UIElements.VisualTreeDataBindingsUpdater.Update ()
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase)
UnityEngine.UIElements.Panel.UpdateDataBinding ()
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers ()
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers ()
UnityEditor.RetainedMode.UpdateSchedulers ()

Here’s the case. It might some time before it’s available.

1 Like

Thanks for providing the case, much appreciated.
I’ll be following and testing once it gets resolved. Will try report back if there’s any hiccups.

The issue tracker case for this bug says it’s fixed in 2023.2.5f1, however, the bug still seems to happen for me after updating to 2023.2.5.

1 Like

@nightdriveinteractive Can you share the callstack of the exception you’re seeing please?

Here’s my callstack. I thought it was the same as above at first glance, but it does differ.

NullReferenceException: Object reference not set to an instance of an object.
  at UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) [0x00018] in C:\build\output\unity\unity\Runtime\Export\Scripting\BindingsHelpers.cs:62
  at UnityEngine.Component.get_gameObject () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Component.TryGetComponent[T] (T& component) [0x00002] in C:\build\output\unity\unity\Runtime\Export\Scripting\Component.bindings.cs:58
  at UnityEngine.Rendering.HighDefinition.HDAdditionalLightData.get_legacyLight () [0x00018] in .\Library\PackageCache\com.unity.render-pipelines.high-definition@16.0.5\Runtime\Lighting\Light\HDAdditionalLightData.cs:2182
  at UnityEngine.Rendering.HighDefinition.HDAdditionalLightData.TickLateUpdate () [0x0005b] in .\Library\PackageCache\com.unity.render-pipelines.high-definition@16.0.5\Runtime\Lighting\Light\HDAdditionalLightData.cs:2666
  at UnityEngine.Rendering.HighDefinition.LightLateUpdate.Tick () [0x00001] in .\Library\PackageCache\com.unity.render-pipelines.high-definition@16.0.5\Runtime\Lighting\Light\HDAdditionalLightData.cs:3883

Hope it helps!

Yes, that’s not a problem with UI Toolkit, looks more like a rendering/lighting problem in the scene. You can try the Graphics forums for that one : https://forum.unity.com/categories/graphics.75/

1 Like

same

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <6b66e7caaeb045048a0fbc11f111e6fa>:0)
UnityEditor.SerializedObject.get_isEditingMultipleObjects () (at <71384c30e42c4bcf9ce4acef4223ee2b>:0)
UnityEditor.UIElements.Bindings.SerializedObjectList.get_Count () (at <8329afc07d464f528b335853aabc593b>:0)
UnityEngine.UIElements.VerticalVirtualizationController`1[T].get_itemsCount () (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].IsIndexOutOfBounds (System.Int32 i) (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].CleanItemHeightCache () (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.UIElements.BaseVerticalCollectionView.RefreshItems () (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.UIElements.BaseVerticalCollectionView.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () (at <b3a32009a29947f597b3b08aa48842a8>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I want to thank you. I had this problem until now and it was very hard for me to work on my project.

Also if anyone wants to know how i fixed it:
I just deleted the global volume

I’m having what I think is a similar problem in 6000.0.32. It happens every so often when I Run. Quitting Unity and restarting fixes the problem, usually. Sometimes I have to restart twice. Sometimes it happens after just 2-3 runs, sometimes not for quite a while. Not a serious problem, mostly just annoying because of the wasted time. It is pretty annoying to have to restart Unity so frequently.

NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/BindingsHelpers.cs:62)
UnityEditor.SerializedObject.get_isEditingMultipleObjects () (at <62fab501750b4de3afc961a1c4817728>:0)
UnityEditor.UIElements.Bindings.SerializedObjectList.get_Count () (at /Users/bokken/build/output/unity/unity/Modules/UIElementsEditor/Bindings/BaseListViewSerializedObjectBinding.cs:96)
UnityEngine.UIElements.VerticalVirtualizationController`1[T].get_itemsCount () (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Collections/Virtualization/VerticalVirtualizationController.cs:27)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].IsIndexOutOfBounds (System.Int32 i) (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Collections/Virtualization/DynamicHeightVirtualizationController.cs:1151)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].CleanItemHeightCache () (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Collections/Virtualization/DynamicHeightVirtualizationController.cs:983)
UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Collections/Virtualization/DynamicHeightVirtualizationController.cs:168)
UnityEngine.UIElements.BaseVerticalCollectionView.RefreshItems () (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Controls/BaseVerticalCollectionView.cs:1286)
UnityEngine.UIElements.BaseVerticalCollectionView.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Controls/BaseVerticalCollectionView.cs:2096)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:219)

That’s what it’s been doing today, every 1 or 2 runs I have to restart Unity. This is getting pretty annoying.

Have you updated your editor version since then? 6000.0.32 is about 3 months out of date by now. Potentially this has been fixed since then, but work checking the release notes.