EXCEPTION MissingReferenceException in PolySpatialCore

Recently we upgraded our project from PolySpatial 1.0.3 to 1.1.4 (along with PolySpatial visionOS, PolySpatial XR, Apple visionOS XR Plugin, all to 1.1.4 as well).

Since doing that, we get a series of errors in the editor to do with box colliders:

[Diagnostics] EXCEPTION MissingReferenceException in PolySpatialCore:
  at (wrapper managed-to-native) UnityEngine.Collider.set_enabled(UnityEngine.Collider,bool)
  at Unity.PolySpatial.Internals.PolySpatialCompoundCollider.GetOrAddBackingCollider[T] (System.Int32 id) [0x00014] in ./Library/PackageCache/com.unity.polyspatial@1.1.4/Runtime/Public/PolySpatialCompoundCollider.cs:149 
  at Unity.PolySpatial.Internals.PolySpatialCompoundCollider.SetPolySpatialColliderData (Unity.PolySpatial.Internals.PolySpatialCompoundCollider+PolySpatialTrackingFlags trackingFlags, Unity.PolySpatial.Internals.PolySpatialCompoundCollider+UnityColliderInfo colliderInfo) [0x000a7] in ./Library/PackageCache/com.unity.polyspatial@1.1.4/Runtime/Public/PolySpatialCompoundCollider.cs:98 
  at Unity.PolySpatial.Internals.UnitySceneGraph.SetEntityColliderInfo (Unity.PolySpatial.Internals.PolySpatialInstanceID id, Unity.PolySpatial.Internals.PolySpatialTrackingFlags trackingFlags, Unity.PolySpatial.Internals.PolySpatialColliderData* colliderInfo) [0x000aa] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/UnitySceneGraph.cs:842 
  at Unity.PolySpatial.Internals.PolySpatialUnityBackend.OnSendClientCommand (Unity.PolySpatial.Internals.PolySpatialCommand command, System.Int32 argCount, System.Void** args, System.Int32* argSizes) [0x00847] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:434 
  at Unity.PolySpatial.Internals.PolySpatialUnityBackend.HandleCommand (Unity.PolySpatial.Internals.PolySpatialCommand cmd, System.Int32 argCount, System.Void** argValues, System.Int32* argSizes) [0x00011] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:156 
  at Unity.PolySpatial.Internals.PolySpatialNativeExtensions.Command[T1] (Unity.PolySpatial.Internals.IPolySpatialCommandHandler handler, Unity.PolySpatial.Internals.PolySpatialCommand command, System.ReadOnlySpan`1[T] arg1) [0x00019] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/PolySpatialNativeExtensions.cs:127 
  at Unity.PolySpatial.Internals.PolySpatialNativeExtensions.SerializedChangeListCommand[T] (Unity.PolySpatial.Internals.IPolySpatialCommandHandler handler, Unity.PolySpatial.Internals.PolySpatialCommand command, Unity.PolySpatial.Internals.IChangeList`1[TEngineData] changes) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/PolySpatialNativeExtensions.cs:299 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.OnCollidersChanged (Unity.PolySpatial.Internals.IChangeList`1[TEngineData] colliderDatas) [0x00012] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:775 
  at Unity.PolySpatial.Internals.ColliderTracker.ProcessChanged (Unity.PolySpatial.Internals.PolySpatialUnitySimulation unitySimulation, Unity.PolySpatial.Internals.ChangeList`1[TEngineData] data) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/ColliderTracker.cs:25 
  at Unity.PolySpatial.Internals.UnityObjectTrackerWithStructDataBase`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessChangedInternal (Unity.PolySpatial.Internals.PolySpatialUnitySimulation unitySimulation, Unity.PolySpatial.Internals.IChangeList`1[TEngineData] data) [0x0000e] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:156 
  at Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessAllNewAndModifiedObjects () [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:370 
  at Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessNewAndModifiedObjects () [0x00017] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:339 
  at Unity.PolySpatial.Internals.PolySpatialUnityTracker.ProcessNewAndModifiedObjects () [0x00004] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:230 
  at Unity.PolySpatial.Internals.PolySpatialUnityTracker.Process () [0x0002f] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:209 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x000b6] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:187 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x0000a] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:136 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x000ce] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:694

I’ve setup a simple test project to demonstrate the issue. Just select the visionOS platform, open the Application scene and press play, you should see the errors straight away.

This is with Unity 2022.3.20.

Any suggestions on what might be causing the issue would be greatly appreciated. Thanks!

Just a note to let you know that I’ve reprod this and we are actively working on it. I don’t have an eta for release of the fix for this, though.

And thank you for the small repro project.

Hey joejo - did you manage to find a fix for this? Any local work arounds we could try out?

So the root issue is that you are applying a Box Collider to your UI component directly. What is happening is that we are mistakenly removing that backing collider that maps to that implicit collider while someone else is still actively tracking it. There is a fix for the next minor release (1.2?) that will resolve the crash.

That said, the resolution is that we have to disable that box collider on the back end, which means that having it on the UGUI object AND having it being actively clipped are mutually exclusive operations. We will disable the box collider on the backend, which means it’s ineffective as long as you are masking/clipping as well. The quick fix on your end would be to remove/disable the box collider.

Alternatively, you could change the collider to a non-Box collider and that would stop the crash as well. Unfortunately that would also invalidate clipping as your collider would still register hits even though the hit area may be outside of the clipped area.

Thanks for the detailed reply - we will see if we can rework the UI to not use box colliders. Do you know roughly when the fix you mentioned will be released?

@joejo do you know when this fix will be released?

Unfortunately no, I don’t have an ETA at this time.