Skip to content

ClippingPrimitive bug in 2.8.0 #10626

@JakobAnarkyLabs

Description

@JakobAnarkyLabs

Describe the bug

ClippingPrimitive has functionality to automatically remove renderers that have been destroyed (renderer == null), but when doing so, it will have an unhandled MissingReferenceException in 2.8.0.

To reproduce

Steps to reproduce the behavior:

  1. Add a ClippingPrimitive (ClippingSphere, ClippingBox or ClippingPlane) to a GameObject in your scene.
  2. Add the Renderer of another GameObject to the 'Renderers' list on your ClippingPrimitive.
  3. Enter play mode
  4. Delete the GameObject with the Renderer assigned to your ClippingPrimitive
  5. Move ClippingPrimitive Transform a bit (will set IsDirty = true)

Expected behavior

The ClippingPrimitive will remove the destroyed Renderer from its registry without throwing a MissingReferenceException.

My setup

  • Unity Version 2021.2.13f1
  • MRTK Version 2.8.0

Target platform

  • HoloLens 2

Additional context

Currently, the code that is checking whether renderer == null (line 374 in ClippingPriimitive.cs) will trigger the RemoveRenderer() method call which will in turn call the AquireMaterials() method - and the AquireMaterials() method assumes that the renderer has not been destroyed. So in essence: if the renderer is destroyed, we will call some code that requires that the renderer is not destroyed.

Alternatively it could be argued that it is the user's responsibility to always manually remove any registered Renderers from the ClippingPrimitive by calling RemoveRenderer() before a GameObject with a registered Renderer is being destroyed. But then, we should probably remove the code that tries to automatically handle the case where renderer == null.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions