#Getting an exception when disposing a world

1 messages · Page 1 of 1 (latest)

stiff nacelle
#

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.

#

The erroring code in question in BatchRendererGroup:

    public void UnregisterMaterial(BatchMaterialID material)
    {
      IntPtr native = BatchRendererGroup.BindingsMarshaller.ConvertToNative(this);
      if (native == IntPtr.Zero)
        ThrowHelper.ThrowNullReferenceException((object) this);
      BatchRendererGroup.UnregisterMaterial_Injected(native, ref material);
    }

Unity v6000.0.28f1, Entities Graphics 1.3.2, Entities 1.3.8, URP 17.0.3

cold canopy
#

If you enter/exit play mode, do you get this every time?

#

Or 50% of the time

stiff nacelle