[BUG|Report CASE IN-75933] Destroy a disabled particle system will cause a KeyNotFoundException

Report CASE IN-75933

WE DO:

We change the polyspatial particle rendering mode to “Baked Mesh” and make the particles children of the Cube and inactive.

Dev environment:

  • Unity 2022.3.24f1
  • Polyspatial 1.2.3
  • visionOS 1.1
  • Photon Fusion2(rc5-824)

Log:

Using photon fusion2 as a multiplayer online plug-in, the following error occurs after Shutdown:

[Diagnostics] EXCEPTION KeyNotFoundException in PolySpatialCore:
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <e307bbb467104258887a104f6151f183>:0 
  at Unity.PolySpatial.Internals.DictionaryList`2[TKey,TValue].get_Item (TKey key) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Utilities/DictionaryList.cs:29 
  at Unity.PolySpatial.Internals.UnitySceneGraph.GetEntity (Unity.PolySpatial.Internals.PolySpatialInstanceID entityId) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/UnitySceneGraph.cs:293 
  at Unity.PolySpatial.Internals.UnitySceneGraph.DestroyEntityComponent (Unity.PolySpatial.Internals.PolySpatialInstanceID id, Unity.PolySpatial.Internals.UnitySceneGraphComponent componentType) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/UnitySceneGraph.cs:340 
  at Unity.PolySpatial.Internals.PolySpatialUnityBackend.OnSendClientCommand (Unity.PolySpatial.Internals.PolySpatialCommand command, System.Int32 argCount, System.Void** args, System.Int32* argSizes) [0x00d6e] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:585 
  at Unity.PolySpatial.Internals.PolySpatialUnityBackend.HandleCommand (Unity.PolySpatial.Internals.PolySpatialCommand cmd, System.Int32 argCount, System.Void** argValues, System.Int32* argSizes) [0x0000e] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:155 
  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.OnParticleSystemsDestroyed (Unity.PolySpatial.Internals.IChangeList`1[TEngineData] changeList) [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:834 
  at Unity.PolySpatial.Internals.ParticleSystemTracker.ProcessDestroyed (Unity.PolySpatial.Internals.PolySpatialUnitySimulation unitySimulation, Unity.PolySpatial.Internals.ChangeList`1[TEngineData] data) [0x00009] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/ParticleSystemTracker.cs:283 
  at Unity.PolySpatial.Internals.UnityObjectTrackerWithTableDataAndEmptyRemovedData`3[TObject,TEngineData,TTrackingData].ProcessDestroyedInternal (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:110 
  at Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessAllDestroyedObjects () [0x00000] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:428 
  at Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessDestroyedObjects () [0x00024] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:389 
  at Unity.PolySpatial.Internals.PolySpatialUnityTracker.ProcessDestroyedObjects () [0x00010] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:244 
  at Unity.PolySpatial.Internals.PolySpatialUnityTracker.Process () [0x00035] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:231 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x000e0] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:216 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x0000a] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:143 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x000b1] in /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:669 

KeyNotFoundException: The given key '-9634' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <e307bbb467104258887a104f6151f183>:0)
Unity.PolySpatial.Internals.DictionaryList`2[TKey,TValue].get_Item (TKey key) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Utilities/DictionaryList.cs:29)
Unity.PolySpatial.Internals.UnitySceneGraph.GetEntity (Unity.PolySpatial.Internals.PolySpatialInstanceID entityId) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/UnitySceneGraph.cs:293)
Unity.PolySpatial.Internals.UnitySceneGraph.DestroyEntityComponent (Unity.PolySpatial.Internals.PolySpatialInstanceID id, Unity.PolySpatial.Internals.UnitySceneGraphComponent componentType) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/UnitySceneGraph.cs:340)
Unity.PolySpatial.Internals.PolySpatialUnityBackend.OnSendClientCommand (Unity.PolySpatial.Internals.PolySpatialCommand command, System.Int32 argCount, System.Void** args, System.Int32* argSizes) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:585)
Unity.PolySpatial.Internals.PolySpatialUnityBackend.HandleCommand (Unity.PolySpatial.Internals.PolySpatialCommand cmd, System.Int32 argCount, System.Void** argValues, System.Int32* argSizes) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/Unity/PolySpatialUnityBackend.cs:155)
Unity.PolySpatial.Internals.PolySpatialNativeExtensions.Command[T1] (Unity.PolySpatial.Internals.IPolySpatialCommandHandler handler, Unity.PolySpatial.Internals.PolySpatialCommand command, System.ReadOnlySpan`1[T] arg1) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/PolySpatialNativeExtensions.cs:127)
Unity.PolySpatial.Internals.PolySpatialNativeExtensions.SerializedChangeListCommand[T] (Unity.PolySpatial.Internals.IPolySpatialCommandHandler handler, Unity.PolySpatial.Internals.PolySpatialCommand command, Unity.PolySpatial.Internals.IChangeList`1[TEngineData] changes) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Platforms/PolySpatialNativeExtensions.cs:299)
Unity.PolySpatial.Internals.PolySpatialUnitySimulation.OnParticleSystemsDestroyed (Unity.PolySpatial.Internals.IChangeList`1[TEngineData] changeList) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:834)
Unity.PolySpatial.Internals.ParticleSystemTracker.ProcessDestroyed (Unity.PolySpatial.Internals.PolySpatialUnitySimulation unitySimulation, Unity.PolySpatial.Internals.ChangeList`1[TEngineData] data) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/ParticleSystemTracker.cs:283)
Unity.PolySpatial.Internals.UnityObjectTrackerWithTableDataAndEmptyRemovedData`3[TObject,TEngineData,TTrackingData].ProcessDestroyedInternal (Unity.PolySpatial.Internals.PolySpatialUnitySimulation unitySimulation, Unity.PolySpatial.Internals.IChangeList`1[TEngineData] data) (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:110)
Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessAllDestroyedObjects () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:428)
Unity.PolySpatial.Internals.UnityObjectTracker`4[TObject,TEngineData,TRemovedData,TTrackingData].ProcessDestroyedObjects () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/UnityObjectTracker.cs:389)
Unity.PolySpatial.Internals.PolySpatialUnityTracker.ProcessDestroyedObjects () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:244)
Unity.PolySpatial.Internals.PolySpatialUnityTracker.Process () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnityTracker.cs:231)
Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:216)
Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:143)
Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:669)
UnityEngine.Debug:LogException(Exception)
Unity.PolySpatial.Internals.PolySpatialCore:PolySpatialAfterLateUpdate() (at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:676)

A tick for fix this bug:

private async void OnGUI()
{
    if (GUILayout.Button("Disconnect"))
    {
        var tmp_Particles = FindObjectsByType<ParticleSystem>(FindObjectsInactive.Include,FindObjectsSortMode.None);
        foreach (ParticleSystem tmp_Particle in tmp_Particles)
        {
            tmp_Particle.gameObject.SetActive(true);
            tmp_Particle.Stop(true);
        }

        await Task.Delay(100);
        
       PhotonServerAPI.GetInstance.DisconnectAsync(0);
    }
}

I’m seeing the same issue. It seems to happen when a disabled particle system is destroyed.

Return to v1.1.6, it’s work perfect for me.

This is also the case for us, causing the app to freeze on the device. It is fixed when I activate particles before destroying them.

This is the latest log I received:

[Platform] Entity -232 not found
PolySpatialRealityKit/PolySpatialImplUtils.swift:52: Fatal error: Entity -232 not found
  • Unity 2022.3.20f1
  • Polyspatial 1.2.3
  • visionOS 1.1

UPDATE: Tried 2022.3.29f1 BUG still exists.

This is a bug in the PolySpatial package (1.2.3/2.0.0-pre.3), rather than one in core Unity. I can see why it’s happening, and we’ll fix it in an upcoming version of PolySpatial.

1 Like