Hovering the pointer over an object with a MeshCollider component instantiated from an asset bundle results in an editor crash.
I am trying to use the OnPointerClicked event from the PointerHandler component on an object that has a MeshCollider and a NearInteractionTouchable component, instantiated from an asset bundle. This works as expected if the same object is dragged into the scene or instantiated from a prefab.
Click to display logs
Assertion failed on expression: 'chanType.dimension == 0'
UnityEngine.RaycastHit:CalculateRaycastTexCoord_Injected(Collider, Vector2&, Vector3&, UInt32, Int32, Vector2&)
UnityEngine.RaycastHit:CalculateRaycastTexCoord(Collider, Vector2, Vector3, UInt32, Int32)
UnityEngine.RaycastHit:get_textureCoord()
Microsoft.MixedReality.Toolkit.Input.MixedRealityRaycastHit:.ctor(Boolean, RaycastHit) (at Assets\MixedRealityToolkit\Definitions\InputSystem\MixedRealityRaycastHit.cs:36)
Microsoft.MixedReality.Toolkit.Input.DefaultRaycastProvider:Raycast(RayStep, LayerMask[], Boolean, MixedRealityRaycastHit&) (at Assets\MixedRealityToolkit.Services\InputSystem\DefaultRaycastProvider.cs:43)
Microsoft.MixedReality.Toolkit.Input.FocusProvider:QueryScene(IMixedRealityPointer, IMixedRealityRaycastProvider, LayerMask[], PointerHitResult, Int32, Boolean) (at Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:1140)
Microsoft.MixedReality.Toolkit.Input.FocusProvider:UpdatePointer(PointerData) (at Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:971)
Microsoft.MixedReality.Toolkit.Input.FocusProvider:UpdatePointers() (at Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:897)
Microsoft.MixedReality.Toolkit.Input.FocusProvider:Update() (at Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:540)
Microsoft.MixedReality.Toolkit.<>c:<UpdateAllServices>b__63_0(IMixedRealityService) (at Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:941)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:ExecuteOnAllServicesInOrder(Action`1) (at Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:1019)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:UpdateAllServices() (at Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:941)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:Update() (at Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:629)
[C:\buildslave\unity\build\Runtime/Graphics/Mesh/Mesh.h line 140]
(Filename: Assets/MixedRealityToolkit/Definitions/InputSystem/MixedRealityRaycastHit.cs Line: 36)
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) UnityEngine.RaycastHit.CalculateRaycastTexCoord_Injected (UnityEngine.Collider,UnityEngine.Vector2&,UnityEngine.Vector3&,uint,int,UnityEngine.Vector2&) [0x0000e] in <18b38ade9b8549a5aff4b379f33eccec>:0
at UnityEngine.RaycastHit.CalculateRaycastTexCoord (UnityEngine.Collider,UnityEngine.Vector2,UnityEngine.Vector3,uint,int) [0x0000a] in <18b38ade9b8549a5aff4b379f33eccec>:0
at UnityEngine.RaycastHit.get_textureCoord () [0x0001a] in <18b38ade9b8549a5aff4b379f33eccec>:0
at Microsoft.MixedReality.Toolkit.Input.MixedRealityRaycastHit..ctor (bool,UnityEngine.RaycastHit) [0x00052] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit\Definitions\InputSystem\MixedRealityRaycastHit.cs:36
at Microsoft.MixedReality.Toolkit.Input.DefaultRaycastProvider.Raycast (Microsoft.MixedReality.Toolkit.Physics.RayStep,UnityEngine.LayerMask[],bool,Microsoft.MixedReality.Toolkit.Input.MixedRealityRaycastHit&) [0x00013] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit.Services\InputSystem\DefaultRaycastProvider.cs:43
at Microsoft.MixedReality.Toolkit.Input.FocusProvider.QueryScene (Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.IMixedRealityRaycastProvider,UnityEngine.LayerMask[],Microsoft.MixedReality.Toolkit.Input.FocusProvider/PointerHitResult,int,bool) [0x00090] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:1140
at Microsoft.MixedReality.Toolkit.Input.FocusProvider.UpdatePointer (Microsoft.MixedReality.Toolkit.Input.FocusProvider/PointerData) [0x000dd] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:971
at Microsoft.MixedReality.Toolkit.Input.FocusProvider.UpdatePointers () [0x00085] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:897
at Microsoft.MixedReality.Toolkit.Input.FocusProvider.Update () [0x00011] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit.Services\InputSystem\FocusProvider.cs:540
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit/<>c.<UpdateAllServices>b__63_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService) [0x00000] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:941
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesInOrder (System.Action`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>) [0x00026] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:1019
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UpdateAllServices () [0x00001] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:941
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.Update () [0x0000c] in D:\Projets\Unity\TestMRTK\Assets\MixedRealityToolkit\Services\MixedRealityToolkit.cs:629
at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00020] in <437ba245d8404784b9fbab9b439ac908>:0
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Complete logs:
Editor.log
Download the project
TestMRTK.zip
Open the Main scene from the Scenes folder.
Hovering the pointer over an object with a MeshCollider instantiated from an asset bundle should not cause a crash.
Demo gif:

@Cameron-Micka Does this seem related to anything you've seen? Related at all to the 2019.3 mesh issues you reported?
@Cameron-Micka Does this seem related to anything you've seen? Related at all to the 2019.3 mesh issues you reported?
The issue I was seeing was in a ARM player build only. So probably not related?
Though looking at the Unity docs here it also looks like this is expected:
https://docs.unity3d.com/ScriptReference/Mesh-isReadable.html
Though looking at the Unity docs here it also looks like this is expected:
https://docs.unity3d.com/ScriptReference/Mesh-isReadable.html
Checking Read/Write Enabled on the mesh asset and rebuilding the asset bundle does indeed fix the issue. Didn't think this would be completely Unity's fault, sorry for the inconvenience! And thank you for the help 馃榾
I wonder if it's worth us adding a guard around this, if the collider is a MeshCollider we check isReadable before accessing?
Something like
c#
MeshCollider meshCollider = hitInfo.collider as MeshCollider;
if (meshCollider == null || meshCollider.sharedMesh.isReadable)
{
textureCoord2 = hitInfo.textureCoord2;
}
else
{
textureCoord2 = Vector2.zero;
}
I think that's a good temporary fix until Unity introduces a fix.
Most helpful comment
Something like
c# MeshCollider meshCollider = hitInfo.collider as MeshCollider; if (meshCollider == null || meshCollider.sharedMesh.isReadable) { textureCoord2 = hitInfo.textureCoord2; } else { textureCoord2 = Vector2.zero; }