Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug NullReferenceException: SerializedObject of SerializedProperty has been Disposed

Discussion in 'Editor & General Support' started by jessee03, Jun 2, 2023.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    I am getting this error randomly after updating to the latest version of unity ( 2022.2.21f1 ) NullReferenceException: SerializedObject of SerializedProperty has been Disposed. I am unable to figure out what is causing this issue, error log wont take me to the code that is the issue. If I restart unity it goes away. If i enter playmode and then exit the error will start again. I get thousands of these errors.

    EDIT: I found that this issue happens when selecting any object in the editor. If I deselect all objects so I have nothing selected I do not get this error

    EDIT: Restarting unity, deleting library folder, resetting ui. Fixes the issue for a few minutes then the error returns.

    EDIT: Upgraded to 2022.3.0f1 and am running into the issue less but seems to occur when messing with array lists in the inspector, also still happening when selection any object in the scene view

    Code (CSharp):
    1. NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
    2. UnityEditor.SerializedProperty.get_objectReferenceInstanceIDValue () (at <a445319feeee47ac85466210448edf2f>:0)
    3. UnityEditor.EditorGUIUtility.ObjectContent (UnityEngine.Object obj, System.Type type, UnityEditor.SerializedProperty property, UnityEditor.EditorGUI+ObjectFieldValidator validator) (at <a445319feeee47ac85466210448edf2f>:0)
    4. UnityEditor.UIElements.ObjectField+ObjectFieldDisplay.Update () (at <a445319feeee47ac85466210448edf2f>:0)
    5. UnityEditor.UIElements.ObjectField.UpdateDisplay () (at <a445319feeee47ac85466210448edf2f>:0)
    6. UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at <618b8429084e4d328aacffdfa23cfc2d>:0)
    7. UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at <618b8429084e4d328aacffdfa23cfc2d>:0)
    8. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <618b8429084e4d328aacffdfa23cfc2d>:0)
    9. UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <618b8429084e4d328aacffdfa23cfc2d>:0)
    10. UnityEditor.RetainedMode.UpdateSchedulers () (at <a7717f1c634f4059922ea89761126092>:0)
     
    Last edited: Jun 2, 2023
  2. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    We're having this bug too since upgrading to 2022.3.6f1. We're also thinking it's related to arrays
     
  3. Paul1379

    Paul1379

    Joined:
    Apr 20, 2022
    Posts:
    1
    J’ai le même problème avec deux tableaux justement qui ne s’affichent plus dans l’inspecteur..
     
  4. alanbrambila

    alanbrambila

    Joined:
    Jun 22, 2023
    Posts:
    1
    Having the same issue. Started this week after a complex logic implementation using a array of struct and a few <int,int> dictionarys (declared inside the scope of the method) in a MonoBehaviour class.

    This public array of struct already existed before and was consumed by simpler methods in this and other classes, so I believe it is not related to its existence in the serialization of this class fields.

    I'm using Unity 2022.3.7f1

    EDIT:
    Useful information: happens mostly when attached to Visual Studio for debug.
    After exiting play mode the exception continues to throw until closing the Editor.


    Code (CSharp):
    1. NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
    2. UnityEditor.SerializedProperty.Verify (UnityEditor.SerializedProperty+VerifyFlags verifyFlags) (at <97436df440ca462884c5332c1d8ebbe7>:0)
    3. UnityEditor.SerializedProperty.get_objectReferenceInstanceIDValue () (at <97436df440ca462884c5332c1d8ebbe7>:0)
    4. UnityEditor.EditorGUIUtility.ObjectContent (UnityEngine.Object obj, System.Type type, UnityEditor.SerializedProperty property, UnityEditor.EditorGUI+ObjectFieldValidator validator) (at <97436df440ca462884c5332c1d8ebbe7>:0)
    5. UnityEditor.UIElements.ObjectField+ObjectFieldDisplay.Update () (at <97436df440ca462884c5332c1d8ebbe7>:0)
    6. UnityEditor.UIElements.ObjectField.UpdateDisplay () (at <97436df440ca462884c5332c1d8ebbe7>:0)
    7. UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at <9d7fc877145d4138982bf12cdd3484c6>:0)
    8. UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at <9d7fc877145d4138982bf12cdd3484c6>:0)
    9. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <9d7fc877145d4138982bf12cdd3484c6>:0)
    10. UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <9d7fc877145d4138982bf12cdd3484c6>:0)
    11. UnityEditor.RetainedMode.UpdateSchedulers () (at <f90f2d9cb28d4393afc1338e6af635e0>:0)
     
  5. RyanDavidson417

    RyanDavidson417

    Joined:
    Sep 15, 2022
    Posts:
    4
    I've also been getting this error. I believe that it, along with another error has to do with when a public or serialized variable "disappears" while the editor is trying to present it. In particular I'm noticing it with a list I'm using, which is filled up on game start. When I exit play mode with the object containing this list open in the inspector, it seems like the list empties. This causes the error to be spammed in my console until I switch to inspect a different object in my hierarchy.

    I believe my other issue, an occasional error reading "ObjectDisposedException: SerializedProperty Tasks.Array.data[1] has disappeared!" is also related to this. it comes up when I remove an item from the list during gameplay while I have the game object open in the inspector. My suspicion is that since the serialized list changed, the unity inspector is just running into difficulty with presenting this change.

    Both of these issues seem to have been resolved by refactoring my list to be private. I'll post back on this forum if I run into either of them again. But in the meantime it seems like these issues aren't especially destructive towards internal gameplay (just the editor), and might be able to be fixed by deserializing them or making them private

    tl;dr: I've found this issue (along with another) tends to occur while serialized data structures (in my case a List) have items removed while visible in the inspector
     
  6. Bernardolv

    Bernardolv

    Joined:
    Jan 26, 2018
    Posts:
    7
    Same Problem on 2022.3.10f1

    How to replicate:


    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [Serializable]
    6. public class Data
    7. {
    8.     public int number;
    9. }
    10. public class BugTest : MonoBehaviour
    11. {
    12.     [SerializeField] List<Data> data;
    13. }
    14.  
    Stick this into a gameobject. Press Play, Select gameobject, Add a Data Element, while still selecting the game object, stop the playmode.

    Script in editor ends up looking like first image while it should look like second image

    happens with both Data[] and List<Data> as well as with Data being a struct.
     

    Attached Files:

    Last edited: Oct 29, 2023
  7. Bernardolv

    Bernardolv

    Joined:
    Jan 26, 2018
    Posts:
    7
    pasting the error


    Code (CSharp):
    1. NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
    2. UnityEditor.SerializedProperty.get_intValue () (at /Users/bokken/build/output/unity/unity/Editor/Mono/SerializedProperty.bindings.cs:996)
    3. UnityEditor.UIElements.Bindings.ListViewSerializedObjectBinding.UnbindListViewItem (UnityEngine.UIElements.VisualElement ve, System.Int32 index) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/ListViewBindings.cs:201)
    4. UnityEngine.UIElements.ListViewController.UnbindItem (UnityEngine.UIElements.VisualElement element, System.Int32 index) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Controllers/ListViewController.cs:47)
    5. UnityEngine.UIElements.CollectionViewController.InvokeUnbindItem (UnityEngine.UIElements.ReusableCollectionItem reusableItem, System.Int32 index) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Controllers/CollectionViewController.cs:174)
    6. UnityEngine.UIElements.VerticalVirtualizationController`1[T].ReleaseItem (System.Int32 activeItemsIndex) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Virtualization/VerticalVirtualizationController.cs:382)
    7. UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].ReleaseItem (System.Int32 activeItemsIndex) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Virtualization/DynamicHeightVirtualizationController.cs:994)
    8. UnityEngine.UIElements.VerticalVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Virtualization/VerticalVirtualizationController.cs:105)
    9. UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Virtualization/DynamicHeightVirtualizationController.cs:162)
    10. UnityEngine.UIElements.BaseVerticalCollectionView.RefreshItems () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Controls/BaseVerticalCollectionView.cs:900)
    11. UnityEngine.UIElements.CollectionViewController.set_itemsSource (System.Collections.IList value) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Collections/Controllers/CollectionViewController.cs:44)
    12. UnityEngine.UIElements.BaseVerticalCollectionView.set_itemsSource (System.Collections.IList value) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Controls/BaseVerticalCollectionView.cs:253)
    13. UnityEditor.UIElements.Bindings.ListViewSerializedObjectBinding.ClearListView () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/ListViewBindings.cs:132)
    14. UnityEditor.UIElements.Bindings.ListViewSerializedObjectBinding.Release () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/ListViewBindings.cs:292)
    15. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.RemoveBinding (UnityEngine.UIElements.IBindable bindable, System.Boolean forceRemove) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:468)
    16. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.Unbind (UnityEngine.UIElements.VisualElement element) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:70)
    17. UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation.UnbindTree (UnityEngine.UIElements.VisualElement element) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:838)
    18. UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation.Unbind (UnityEngine.UIElements.VisualElement element) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:822)
    19. UnityEditor.UIElements.BindingExtensions.Unbind (UnityEngine.UIElements.VisualElement element) (at /Users/bokken/build/output/unity/unity/Editor/Mono/UIElements/Bindings/BindingsInterface.cs:65)
    20. UnityEditor.UIElements.PropertyField.Reset (UnityEditor.SerializedProperty newProperty) (at /Users/bokken/build/output/unity/unity/Editor/Mono/UIElements/Controls/PropertyField.cs:244)
    21. UnityEditor.UIElements.PropertyField.Reset (UnityEditor.UIElements.SerializedPropertyBindEvent evt) (at /Users/bokken/build/output/unity/unity/Editor/Mono/UIElements/Controls/PropertyField.cs:347)
    22. UnityEditor.UIElements.PropertyField.ExecuteDefaultActionAtTarget (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/Editor/Mono/UIElements/Controls/PropertyField.cs:182)
    23. UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:281)
    24. UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at
     
  8. ClawbearGames

    ClawbearGames

    Joined:
    Dec 13, 2018
    Posts:
    13