How to reproduce:
1. Open up any project
2. Create a UI Document in Hierarchy and Project Browser
3. Drag and drop UI Document from Project Browser into the Source Asset slot of UI Document in Hierarchy
4. Double click UI Document in Project Browser
5. Add any element to the UI
6. Close and save the UI Builder tab
7. Open the source Asset again
Expected result: No errors are logged in Console
Actual result: NullReferenceException errors thrown in Console
Reproducible with: 2022.2.0a15, 2022.2.0b4, 2023.1.0a5
Not reproducible with: 2021.3.8f1, 2022.1.13f1, 2022.2.0a14
Couldn't test with: 2020.3.37f1 (No UI builder by default)
Tested on: Windows 11
Notes:
1. Exceptions are thrown whenever any objects are added to the UI, when opening up UI Builder window
2. Reproduction might be inconsistent, if so, try closing UI Builder and opening up the Source Asset again
Error messages:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.UIElements.EditorPanel.OnUpdateMaterial (UnityEngine.Material mat) (at <e45af29d3071404fb85246d308473d3a>:0)
UnityEngine.UIElements.BaseVisualElementPanel.InvokeUpdateMaterial (UnityEngine.Material mat) (at <8c4c0c3614e7457984f7ec0d5dc10278>:0)
UnityEngine.UIElements.UIR.RenderChain.Render () (at <8c4c0c3614e7457984f7ec0d5dc10278>:0)
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UIElements.UIRRepaintUpdater.InitRenderChain () (at <8c4c0c3614e7457984f7ec0d5dc10278>:0)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at <8c4c0c3614e7457984f7ec0d5dc10278>:0)