08-28-2021 03:00 PM
Reporting bugs on this forum feels like whispering in the wind, but here goes:
Expected results:
If running ARM64 build (IL2CPP):
E CRASH : Cause: null pointer dereference
If running ARM7 build (Mono):
E Unity : ArgumentNullException: Value cannot be null.
E Unity : Parameter name: dest
E Unity : at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.copy_to_unmanaged(System.Array,int,intptr,int)
E Unity : at System.Runtime.InteropServices.Marshal.Copy (System.Byte[] source, System.Int32 startIndex, System.IntPtr destination, System.Int32 length) [0x00000] in <8cb436e1877f4e87804bd45a3de980ae>:0
E Unity : at OVRHaptics+OVRHapticsOutput.Process () [0x001d5] in <project path>\Assets\Oculus\VR\Scripts\OVRHaptics.cs:227
E Unity : at OVRHaptics.Process () [0x0000c] in <project path>\Assets\Oculus\VR\Scripts\OVRHaptics.cs:381
E Unity : at OVRManager.LateUpdate () [0x00001] in <project path>\Assets\Oculus\VR\Scripts\OVRManager.cs:2010
I'm definitely not passing a null OVRHapticsClip, and if I launch the app in controller mode the haptic plays correctly.
Theory: If you start the app in hand tracking mode this call doesn't return what you're expecting:
// OVRHaptics.cs line 67
OVRPlugin.HapticsDesc desc = OVRPlugin.GetControllerHapticsDesc((uint)OVRPlugin.Controller.RTouch);
06-17-2022 07:46 PM
I can confirm that this is still an issue with Oculus Integration v40 and all of the other settings you listed above. Your theory is correct, GetControllerHapticsDesc() returns invalid values if hand tracking is active when the app is launched. These invalid values cause m_nativeBuffer to be initialized with a capacity of 0, which leads to a crash in OVRHapticsOutput.Process() when Marshal.Copy() attempts to copy data into the empty buffer.
The crash can be prevented by wrapping each call to Marshal.Copy() with an if statement that checks whether m_nativeBuffer.GetCapacity() is large enough to accept the data being copied. The side effect is that the haptics simply won't work if you switch from hand tracking to controllers after the app starts. Making this change yourself also means you will have to manually restore your edits to OVRHaptics.cs every time you update the Oculus Integration scripts, at least until the issue with GetControllerHapticsDesc() is fixed.