Crash in PolySpatialRealityKit.GenerateParts on 0.7.1

We’ve updated our project to 0.7.1, and we are seeing a crash, somewhat randomly, but very close to the start of running the game.

#0	0x000000010058251c in Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value [inlined] ()
#1	0x000000010058251c in specialized closure #6 in PolySpatialRealityKit.GenerateParts(_:_:_:) at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialRealityKit/MessageHandlers/PolySpatialImplMesh.swift:215
#2	0x00000001005825a8 in closure #6 in PolySpatialRealityKit.GenerateParts(_:_:_:) [inlined] ()
#3	0x000000010058258c in specialized Array.init(_unsafeUninitializedCapacity:initializingWith:) ()
#4	0x0000000100586294 in specialized Array.init(_unsafeUninitializedCapacity:initializingWith:) [inlined] ()
#5	0x0000000100586278 in specialized PolySpatialRealityKit.GenerateParts(_:_:_:) ()
#6	0x00000001005b748c in specialized PolySpatialRealityKit.GenerateParts(_:_:_:) [inlined] ()
#7	0x00000001005b7478 in implicit closure #1 in PolySpatialRealityKit.CreateOrUpdateMeshAsset2(_:_:) [inlined] at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialExtra/PolySpatialRealityKitOverrides.swift:135
#8	0x00000001005b7478 in PolySpatialRealityKit.CreateOrUpdateMeshAsset2(_:_:) at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialExtra/PolySpatialRealityKitOverrides.swift:135
#9	0x00000001005be0a8 in specialized PolySpatialRealityKit.OnSendClientCommandOverrides(_:_:_:_:) at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialExtra/PolySpatialRealityKitOverrides.swift:36
#10	0x00000001005b7314 in PolySpatialRealityKit.OnSendClientCommandOverrides(_:_:_:_:) [inlined] ()
#11	0x00000001005b7300 in closure #1 in static PolySpatialRealityKit.overrideApi(_:_:) [inlined] at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialExtra/PolySpatialRealityKitOverrides.swift:20
#12	0x00000001005b7300 in @objc closure #1 in static PolySpatialRealityKit.overrideApi(_:_:) at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/<compiler-generated>:20
#13	0x000000012be147f0 in SendClientCommandCallback_Invoke_m070CD1B34785553533C4634FEB2190104A16092B_inline(SendClientCommandCallback_t5D0BBD9E6240CD41CEA460757F2C2F04050378ED*, unsigned int, int, void**, int*, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.RealityKit.cpp:2316
#14	0x000000012be147e0 in ::RealityKitBackend_HandleCommand_m07BAB65A44D47B9784D403ADFA74C7BF17667F14(RealityKitBackend_tF43CE85FF67B38B8A4B3E263BC448D6341C2580C *, uint32_t, int32_t, void **, int32_t *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.RealityKit.cpp:1350
#15	0x0000000123f087fc in InterfaceActionInvoker4<unsigned int, int, void**, int*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, unsigned int, int, void**, int*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/GenericMethods__41.cpp:157
#16	0x0000000123f0878c in ::PolySpatialNativeExtensions_Command_TisPolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2_TisByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3_mB0F4925191ADF6DF2A27575BB265D2446FADE796_gshared(RuntimeObject *, uint32_t, PolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2 *, Span_1_tDADAC65069DFE6B57C458109115ECD795ED39305, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/GenericMethods__41.cpp:17127
#17	0x0000000123f0d26c in PolySpatialNativeExtensions_Command_TisPolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2_TisByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3_mB0F4925191ADF6DF2A27575BB265D2446FADE796(Il2CppObject*, unsigned int, PolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2*, Span_1_tDADAC65069DFE6B57C458109115ECD795ED39305, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/GenericMethods__41.cpp:12641
#18	0x0000000123f0d25c in ::PolySpatialNativeExtensions_SerializedAssetCommand_TisRuntimeObject_mF0EA56E3E7D4FB6E88BD887F00B29C308FEA2783_gshared(RuntimeObject *, uint32_t, PolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2, RuntimeObject *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/GenericMethods__41.cpp:19056
#19	0x000000012bdd9784 in PolySpatialNativeExtensions_SerializedAssetCommand_TisPolySpatialMesh_t3DB234071C722BF9330CC3EAD68CB12E7BE3C8CF_m2E272D1335EE39691B00DF6E0791531973239B00(Il2CppObject*, unsigned int, PolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2, PolySpatialMesh_t3DB234071C722BF9330CC3EAD68CB12E7BE3C8CF*, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__6.cpp:13912
#20	0x000000012bdd9770 in ::PolySpatialUnitySimulation_OnMeshAssetChanged_m239AFC618D3D2D04AD7AA9AD9BC890D90B98FBE5(PolySpatialUnitySimulation_t534909DD7A251F36F5473F74CD49AEC27D12B25C *, PolySpatialAssetID_t79244AAC1AF76734D94D54472AF2A706DAC638B2, PolySpatialMesh_t3DB234071C722BF9330CC3EAD68CB12E7BE3C8CF *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__6.cpp:22344
#21	0x000000012bce08cc in ::U3CU3Ec_U3CProcessChangedAssetU3Eb__72_0_m3F54C89DA486518CF684FDAF97C510030EAF4014(U3CU3Ec_tF4AFEE12EFAB390A2D7C76347228B9DD40879A7B *, AssetRepresentation_tB81FBEEEAE385CE700B6E7CF40922D09E9421727 *, PolySpatialMesh_t3DB234071C722BF9330CC3EAD68CB12E7BE3C8CF *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__2.cpp:24168
#22	0x000000012bdaf858 in Action_2_Invoke_m7BFCE0BBCF67689D263059B56A8D79161B698587_gshared_inline(Action_2_t156C43F079E7E68155FCDCD12DC77DD11AEF7E3C*, Il2CppObject*, Il2CppObject*, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__5.cpp:40711
#23	0x000000012bdaf840 in Action_2_Invoke_mFC6E7BF204D99507C87EBB3E06D8BA104FF302E2_inline(Action_2_t0240535398566C07C5E117752F0BCF3D8B747CFD*, AssetRepresentation_tB81FBEEEAE385CE700B6E7CF40922D09E9421727*, PolySpatialMesh_t3DB234071C722BF9330CC3EAD68CB12E7BE3C8CF*, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__5.cpp:11206
#24	0x000000012bdaf840 in ::MeshConversionHelpers_ConvertMeshAssetToPolySpatialMesh_m1447074FBCE261E263DEB308D0524DC3E2746134(AssetRepresentation_tB81FBEEEAE385CE700B6E7CF40922D09E9421727 *, Action_2_t0240535398566C07C5E117752F0BCF3D8B747CFD *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__5.cpp:28494
#25	0x000000012bcddef4 in ::LocalAssetManager_ProcessChangedAsset_m7953C92685073DE7EBDAF5553925D84D87AFE6FA(LocalAssetManager_t12CF3A3700E103AF50F84D3F3F557A1C93744C76 *, AssetRepresentation_tB81FBEEEAE385CE700B6E7CF40922D09E9421727 *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__2.cpp:23886
#26	0x000000012bcdfd50 in ::LocalAssetManager_FetchAssetChangesCallback_m5E00E37EF95562EA3D8B4E5FE592FFA801920F6C(LocalAssetManager_t12CF3A3700E103AF50F84D3F3F557A1C93744C76 *, TypeDispatchData_t65943DEEB99C02CE434E8098F85F13F212B59C67, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__2.cpp:23562
#27	0x000000012b10744c in Action_1_Invoke_m46F291D76441C3A8ED4AEAF3C03F41CE6D4E3DE4_gshared_inline(Action_1_t93ED28E6D469C2CACD2C4299DDCD35DC30CC225A*, TypeDispatchData_t65943DEEB99C02CE434E8098F85F13F212B59C67, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.InternalAPIEngineBridge.021.cpp:2088
#28	0x000000012b107428 in Action_1_Invoke_m46F291D76441C3A8ED4AEAF3C03F41CE6D4E3DE4_inline(Action_1_t93ED28E6D469C2CACD2C4299DDCD35DC30CC225A*, TypeDispatchData_t65943DEEB99C02CE434E8098F85F13F212B59C67, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.InternalAPIEngineBridge.021.cpp:696
#29	0x000000012b107428 in ::U3CU3Ec__DisplayClass13_0_U3C_ctorU3Eb__0_mDE0B7583C4DCF1AA375EB744D847B94B07C1030B(U3CU3Ec__DisplayClass13_0_tDE4145DE501B5B45C9655ACDBF4B9E752537DA32 *, TypeDispatchData_tF20A8BD105729A9AA353F600381DFB39DD8BF21F, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.InternalAPIEngineBridge.021.cpp:1707
#30	0x000000012d5091e0 in Action_1_Invoke_m94D1F20BC74CD22A12F28E5B3B04BD7A0E227395_gshared_inline(Action_1_t42A8343A925FA227C9A30B3153BD9DFF00864DC0*, TypeDispatchData_tF20A8BD105729A9AA353F600381DFB39DD8BF21F, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.CoreModule__2.cpp:45096
#31	0x000000012d5091bc in Action_1_Invoke_m94D1F20BC74CD22A12F28E5B3B04BD7A0E227395_inline(Action_1_t42A8343A925FA227C9A30B3153BD9DFF00864DC0*, TypeDispatchData_tF20A8BD105729A9AA353F600381DFB39DD8BF21F, MethodInfo const*) [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.CoreModule__2.cpp:3897
#32	0x000000012d5091bc in ::U3CU3Ec_U3C_cctorU3Eb__54_0_mD6C58FAB3C4B1F6D05D271D4EB6BA99BDBCD4542(U3CU3Ec_t0256AF880BB2CA5FBA6840BBC250D86220FBCB41 *, ObjectU5BU5D_tD4BF1BEC72A31DF6611C0B8FA3112AF128FC3F8A *, intptr_t, intptr_t, int32_t, int32_t, Action_1_t42A8343A925FA227C9A30B3153BD9DFF00864DC0 *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.CoreModule__2.cpp:24262
#33	0x000000012e382158 in il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) at /Users/bokken/build/output/unity/unity/External/il2cpp/builds/libil2cpp/vm/Runtime.cpp:606
#34	0x000000012e3820a0 in il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) at /Users/bokken/build/output/unity/unity/External/il2cpp/builds/libil2cpp/vm/Runtime.cpp:592
#35	0x000000010546d7d4 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) ()
#36	0x00000001054817b8 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) ()
#37	0x000000010506d93c in ObjectDispatcher::DispatchTypeChangesAndClear(ObjectDispatcher::DispatchSystemHandle*, ScriptingClassPtr, ScriptingObjectPtr, bool, bool, ScriptingObjectPtr) ()
#38	0x0000000104a8d448 in ObjectDispatcher_CUSTOM_DispatchTypeChangesAndClear(void*, ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*, unsigned char, unsigned char, ScriptingBackendNativeObjectPtrOpaque*) ()
#39	0x000000012d50688c in ObjectDispatcher_DispatchTypeChangesAndClear_m558110F85E34BF214D62EAA8BE7ABBB5EFE0A25D [inlined] at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.CoreModule__2.cpp:24089
#40	0x000000012d506878 in ::ObjectDispatcher_DispatchTypeChangesAndClear_m588EBCC352E3F886342E49D34D4BC82909AC32F5(ObjectDispatcher_tEAB1C719841725D9587A7F17646D5D467D498D69 *, Type_t *, Action_1_t42A8343A925FA227C9A30B3153BD9DFF00864DC0 *, bool, bool, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.CoreModule__2.cpp:23661
#41	0x000000012b105e80 in ::ObjectDispatcherProxy_DispatchTypeChangesAndClear_mB008F7EF809274AD623569B0C081FEC0093E517A(ObjectDispatcherProxy_t8ED7A2464E343F926F21C4A9F41638B6FAD5AD8E *, Type_t *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.InternalAPIEngineBridge.021.cpp:1197
#42	0x000000012bcdd1dc in ::LocalAssetManager_ProcessChanges_m9027D5A52DF546639C7B8AC228BF3170864323E7(LocalAssetManager_t12CF3A3700E103AF50F84D3F3F557A1C93744C76 *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__2.cpp:22495
#43	0x000000012bdd1a54 in ::PolySpatialUnitySimulation_Update_mC94D0019BCCDD10DFEB6BAD48C34154904678772(PolySpatialUnitySimulation_t534909DD7A251F36F5473F74CD49AEC27D12B25C *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__6.cpp:19589
#44	0x000000012bda1b3c in ::PolySpatialCore_PolySpatialAfterLateUpdate_m7EC5B99661C30542E56C69109A612167F09B768C(PolySpatialCore_t78C69A271E1410AE3F9872DD271083D192D0203D *, const RuntimeMethod *) at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Il2CppOutputProject/Source/il2cppOutput/Unity.PolySpatial.Core__5.cpp:22560
#45	0x000000012e382158 in il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) at /Users/bokken/build/output/unity/unity/External/il2cpp/builds/libil2cpp/vm/Runtime.cpp:606
#46	0x000000012e3820a0 in il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) at /Users/bokken/build/output/unity/unity/External/il2cpp/builds/libil2cpp/vm/Runtime.cpp:592
#47	0x000000010546d7d4 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) ()
#48	0x00000001054817b8 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) ()
#49	0x00000001050685d4 in ExecutePlayerLoop(NativePlayerLoopSystem*) ()
#50	0x00000001050688c4 in PlayerLoop() ()
#51	0x00000001060d47c4 in UnityPlayerLoopImpl(bool) ()
#52	0x0000000121ebb088 in UnityRepaint at /Users/red-mac-builder-05/Documents/solitaire/Solitaire.Client/builds/visionos_simulator_development/Solitaire/Classes/UnityAppController+Rendering.mm:206
#53	0x0000000189e971d0 in CA::Display::DisplayLinkItem::dispatch_(CA::SignPost::Interval<(CA::SignPost::CAEventCode)835322056>&) ()
#54	0x0000000189e983f0 in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
#55	0x0000000189e97fbc in CA::Display::DisplayLink::callback(_CADisplayTimer*, unsigned long long, unsigned long long, unsigned long long, bool, void*) ()
#56	0x0000000189ea267c in CA::Display::DisplayLink::dispatch_deferred_display_links(unsigned int) ()
#57	0x0000000184914b04 in _UIUpdateSequenceRun ()
#58	0x000000018524a2fc in schedulerStepScheduledMainSection ()
#59	0x00000001852498a8 in runloopSourceCallback ()
#60	0x0000000180405be8 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#61	0x0000000180405b30 in __CFRunLoopDoSource0 ()
#62	0x00000001804052a0 in __CFRunLoopDoSources0 ()
#63	0x00000001803ff9b8 in __CFRunLoopRun ()
#64	0x00000001803ff2b4 in CFRunLoopRunSpecific ()
#65	0x000000018e9d2c20 in GSEventRunModal ()
#66	0x0000000185309b80 in -[UIApplication _run] ()
#67	0x000000018530d82c in UIApplicationMain ()
#68	0x00000001c715c938 in ___lldb_unnamed_symbol224846 ()
#69	0x00000001c715c7c8 in ___lldb_unnamed_symbol224844 ()
#70	0x00000001c6df47e4 in static App.main() ()
#71	0x00000001005389ec in static UnityPolySpatialApp.$main() [inlined] ()
#72	0x00000001005389b8 in main ()
#73	0x0000000100849544 in start_sim ()
#74	0x000000010095df28 in start ()

This post has a similar error, but doesn’t seem applicable, we aren’t attempting to switch between bounded and unbounded.

This wasn’t happening on 0.5.0 that we were on. We did try 0.6.3 a bit ago and didn’t see it then, but we aren’t directly updating from 0.6.3.

The root cause of this is a mesh that has tangent vectors, but not normals (which we use along with the tangents to compute the bitangent vectors). That’s not a combination we had anticipated, but I can change it so that we just avoid computing the bitangents in that case.

We’ve narrowed this down to a particle prefab we are creating. This prefab contains an Animator, a mesh, and a few particle systems. At first I thought it was the mesh inside which had the weird normals, but removing the mesh it still crashes. If we remove the particle systems and animator from the prefab, the crash does not happen. We possibly have some settings on our particle systems that are not supported causing the particles to have this issue.

Good to know; thanks! In that case, it sounds like we’re the ones generating meshes with tangents but no normals (assuming you’re using bake-to-mesh particles). Either way, the issue should be fixed in the next release.

Yup, we are using bake-to-mesh particles. Sounds good, thanks for the help here!

1 Like