Getting a null-reference exception in some entity-graphics code when the world is being disposed:
NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <b5bf0c891ea345fe93688f835df32fdc>:0)
UnityEngine.Rendering.BatchRendererGroup.UnregisterMaterial (UnityEngine.Rendering.BatchMaterialID material) (at <b5bf0c891ea345fe93688f835df32fdc>:0)
Unity.Rendering.EntitiesGraphicsSystem.UnregisterMaterial (UnityEngine.Rendering.BatchMaterialID material) (at ./Library/PackageCache/com.unity.entities.graphics/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:2575)
Unity.Rendering.RegisterMaterialsAndMeshesSystem.UnregisterMaterialsMeshes (Unity.Rendering.BRGRenderMeshArray& brgRenderArray) (at ./Library/PackageCache/com.unity.entities.graphics/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:403)
Unity.Rendering.RegisterMaterialsAndMeshesSystem.OnDestroy () (at ./Library/PackageCache/com.unity.entities.graphics/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:391)
Unity.Entities.ComponentSystemBase.OnDestroy_Internal () (at Library/PackageCache/com.unity.entities/Unity.Entities/ComponentSystemBase.cs:305)
Unity.Entities.World.DestroyAllSystemsAndLogException (System.Boolean& loggedException) (at Library/PackageCache/com.unity.entities/Unity.Entities/World.cs:1141)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities/Unity.Entities/Stubs/Unity/Debug.cs:17)
Unity.Entities.World:DestroyAllSystemsAndLogException(Boolean&) (at Library/PackageCache/com.unity.entities/Unity.Entities/World.cs:1151)
Unity.Entities.World:Dispose()
(...)
I'm not sure how the material is becoming null, as I don't think we're destroying any materials on entities anywhere? Anyone know how I could potentially go about debugging this, since I'm not even sure where the materials are stored.