PolySpatial 2.1.2 causes Unity to crash when loading AssetBundle resources

When using the VisionOS platform in the Unity Editor, loading assets through AssetBundle causes Unity to crash. The crash log contains the following information:

========== OUTPUTTING STACK TRACE ==================

0x00007FFCDDE1F3B0 (Unity) CopyChannelDirect
0x00007FFCDDE1D3F7 (Unity) VertexUtility::CopyChannel
0x00007FFCDDE1F79B (Unity) CopyChannels
0x00007FFCDDE1F8E9 (Unity) VertexUtility::CopyChannels
0x00007FFCDDE1CFD2 (Unity) MeshDataBindings::CopyAttributeIntoPtr
0x00007FFCDD4C7EC2 (Unity) Mesh_MeshData_CUSTOM_CopyAttributeIntoPtr
0x000001F07705853A (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Mesh/MeshData:CopyAttributeIntoPtr (intptr,UnityEngine.Rendering.VertexAttribute,UnityEngine.Rendering.VertexAttributeFormat,int,intptr)
0x000001F07705829B (Mono JIT Code) UnityEngine.Mesh/MeshData:CopyAttributeInto<UnityEngine.Vector3> (Unity.Collections.NativeArray`1<UnityEngine.Vector3>,UnityEngine.Rendering.VertexAttribute,UnityEngine.Rendering.VertexAttributeFormat,int)
0x000001F077057FB3 (Mono JIT Code) UnityEngine.Mesh/MeshData:GetVertices (Unity.Collections.NativeArray`1<UnityEngine.Vector3>)
0x000001F077050AA3 (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Rendering/MeshConversionHelpers.cs:81] Unity.PolySpatial.Internals.MeshConversionHelpers:ConvertMeshAssetToPolySpatialMesh (Unity.PolySpatial.Internals.AssetRepresentation,System.Action`2<Unity.PolySpatial.Internals.AssetRepresentation, Unity.PolySpatial.Internals.PolySpatialMesh>) 
0x000001F07704B0FB (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:1211] Unity.PolySpatial.Internals.LocalAssetManager:ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation) 
0x000001F07704894B (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:823] Unity.PolySpatial.Internals.LocalAssetManager:ProcessChanges () 
0x000001F076FE1423 (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:276] Unity.PolySpatial.Internals.PolySpatialUnitySimulation:UpdateInternal () 
0x000001F076FB7DAB (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:211] Unity.PolySpatial.Internals.PolySpatialUnitySimulation:Update () 
0x000001F076F8F4D3 (Mono JIT Code) [/Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:710] Unity.PolySpatial.Internals.PolySpatialCore:PolySpatialAfterLateUpdate () 
0x000001F18D005648 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFCD49869CE (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke 
0x00007FFCD48C8474 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3068] do_runtime_invoke 
0x00007FFCD48C8560 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3115] mono_runtime_invoke 
0x00007FFCDE2AB404 (Unity) scripting_method_invoke
0x00007FFCDE283193 (Unity) ScriptingInvocation::Invoke
0x00007FFCDDEF81C6 (Unity) ExecutePlayerLoop
0x00007FFCDDEFD31F (Unity) PlayerLoop
0x00007FFCDEFFF34A (Unity) EditorPlayerLoop::Execute
0x00007FFCDF015D47 (Unity) PlayerLoopController::InternalUpdateScene
0x00007FFCDF017AFD (Unity) PlayerLoopController::UpdateSceneIfNeededFromMainLoop
0x00007FFCDF0118B1 (Unity) Application::TickTimer
0x00007FFCDF6063FA (Unity) MainMessageLoop
0x00007FFCDF60C0C4 (Unity) UnityMain
0x00007FF6B76F2FBA (Unity) __scrt_common_main_seh
0x00007FFD4B057374 (KERNEL32) BaseThreadInitThunk
0x00007FFD4B1FCC91 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

A crash has been intercepted by the crash handler. For call stack and other details, see the latest crash report generated in:
 * C:/Users/hp/AppData/Local/Temp/Unity/Editor/Crashes

Sometimes, loading AssetBundles also triggers the following error in the console, but it doesn’t cause a crash. This issue occurs on both Windows 10 and macBook.

[Diagnostics] EXCEPTION NullReferenceException in PolySpatialCore:
  at Unity.Collections.NativeArray`1[T]..ctor (Unity.Collections.NativeArray`1[T] array, Unity.Collections.Allocator allocator) [0x00001] in /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:88 
  at Unity.PolySpatial.Internals.ConversionHelpers.GetRawTextureData (UnityEngine.Texture2D tex2d, Unity.Collections.Allocator allocator, UnityEngine.Experimental.Rendering.GraphicsFormat& graphicsFormat) [0x000b0] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Platforms/PolySpatialConversionHelpers.cs:838

Please report this as a bug from within the Editor by selecting “Help → Report a Bug…” and attach a reproduction project and log files. Our Customer QA team will then investigate the issue further.

2 Likes

You might want to try marking the meshes and textures that you’re adding to the AssetBundle as readable (Advanced → Read/Write for the texture importer settings, Meshes → Read/Write for the model importer), if you haven’t already done so. The underlying issue here is that PolySpatial can’t access the contents of the textures/meshes in order to transfer them to RealityKit. If that doesn’t work, as @Oyvind_F says, please submit a bug report with a repro case so that we can look into it further. If you mention the incident number (IN-#####) in this thread, I can look into it more quickly.

1 Like

By enabling the Read/Write property on the Mesh, I have resolved the crash issue. However, there is still a texture named “Background” that is not set to Read/Write, causing the AssetBundle to fail to load. This texture appears to be a built-in Unity texture, such as the one referenced in the Slider component, and I cannot modify its Read/Write property.

I believe I could resolve this issue by removing its reference from the Image component, but currently, I am unable to locate the component where this texture is being used.

Do you have any suggestions for a better solution?
@kapolka @Oyvind_F
The following is the error message reported on Vision Pro:

UnityException: Texture 'Background' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
  at UnityEngine.Texture2D.GetRawTextureData[T] () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.XR.ARFoundation.MutableRuntimeReferenceImageLibraryExtensions.ScheduleAddImageWithValidationJob (UnityEngine.XR.ARSubsystems.MutableRuntimeReferenceImageLibrary library, UnityEngine.Texture2D texture, System.String name, System.Nullable`1[T] widthInMeters, Unity.Jobs.JobHandle inputDeps) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.ConversionHelpers.GetRawTextureData (UnityEngine.Texture2D tex2d, Unity.Collections.Allocator allocator, UnityEngine.Experimental.Rendering.GraphicsFormat& graphicsFormat) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.SendTextureAssetChanged (Unity.PolySpatial.Internals.PolySpatialAssetID assetID, UnityEngine.Object unityTexture, System.Boolean computeDataHash, System.Boolean allowNativeTextures) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation representation) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 

Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (00000006:kIOGPUCommandBufferCallbackErrorBackgroundExecutionNotPermitted)

[Diagnostics] EXCEPTION UnityException in PolySpatialCore:
  at UnityEngine.Texture2D.GetRawTextureData[T] () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.XR.ARFoundation.MutableRuntimeReferenceImageLibraryExtensions.ScheduleAddImageWithValidationJob (UnityEngine.XR.ARSubsystems.MutableRuntimeReferenceImageLibrary library, UnityEngine.Texture2D texture, System.String name, System.Nullable`1[T] widthInMeters, Unity.Jobs.JobHandle inputDeps) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.ConversionHelpers.GetRawTextureData (UnityEngine.Texture2D tex2d, Unity.Collections.Allocator allocator, UnityEngine.Experimental.Rendering.GraphicsFormat& graphicsFormat) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.SendTextureAssetChanged (Unity.PolySpatial.Internals.PolySpatialAssetID assetID, UnityEngine.Object unityTexture, System.Boolean computeDataHash, System.Boolean allowNativeTextures) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation representation) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
UnityException: Texture 'Background' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
  at UnityEngine.Texture2D.GetRawTextureData[T] () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.XR.ARFoundation.MutableRuntimeReferenceImageLibraryExtensions.ScheduleAddImageWithValidationJob (UnityEngine.XR.ARSubsystems.MutableRuntimeReferenceImageLibrary library, UnityEngine.Texture2D texture, System.String name, System.Nullable`1[T] widthInMeters, Unity.Jobs.JobHandle inputDeps) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.ConversionHelpers.GetRawTextureData (UnityEngine.Texture2D tex2d, Unity.Collections.Allocator allocator, UnityEngine.Experimental.Rendering.GraphicsFormat& graphicsFormat) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.SendTextureAssetChanged (Unity.PolySpatial.Internals.PolySpatialAssetID assetID, UnityEngine.Object unityTexture, System.Boolean computeDataHash, System.Boolean allowNativeTextures) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation representation) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.DebugLogHandler:Internal_LogException_Injected(Exception, IntPtr)
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Debug:LogErrorFormat(Object, String, Object[])
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogErrorFormat(Object, String, Object[])
UnityEngine.Debug:LogException(Exception)
Unity.PolySpatial.Internals.PolySpatialCore:PolySpatialAfterLateUpdate()
UnityEngine.LowLevel.UpdateFunction:Invoke()

This might be helpful for you:

1 Like

Thank you for the solution you provided; my issue has been resolved!

2 Likes