ViveTrackers icon indicating copy to clipboard operation
ViveTrackers copied to clipboard

Unity crash on exit playmode

Open NyanCetch opened this issue 1 year ago • 0 comments

Hello, I have the following problem. When exiting playmode, the editor crashes due to OpenVR. I'm using 1 x Vive Tracker 3.0, 1 x Base Station 2.0, null hmd driver. After starting playmode everything works fine, but when exiting playmode the editor crashes.

I tried different versions of the editor: 2021.3, 2022.3. The problem remains. I tried different versions of SteamVR Plugin: 2.8.0, 2.8.3 (in which, according to the description, they fixed the editor crash). The problem remains. I tried reinstalling SteamVR, installing different versions of it from the network and even beta versions. Nothing helped.

When creating a new project and a clean installation of the SteamVR Plugin, the editor may start 1-2 times and exit playmode without errors, but then everything repeats again. I can't reproduce the actions that lead to this. This also affects POGO pins. They can work 1-2 times, and then stop sending events. At the same time, in the SteamVR menu you can see that the buttons work.

After looking at the editor logs after the crash, I came to the conclusion that errors occur in 2 places in the ViveTrackersManager class: _cvrSystem.GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin.TrackingUniverseStanding, 0f, _ovrTrackedDevicePoses); _cvrSystem.GetControllerState(tracker.ID.trackedDevice_Index, ref _ovrControllerState, _ovrControllerStateSize);

Here is part from the log:

[XR] [OpenVR] Device connecting (status change). OpenVRIndex: 0. UnityID: 0 [XR] [OpenVR] Device connecting (status change). OpenVRIndex: 1. UnityID: 1 XRTextureManager::RequestCreateTexture XRTextureManager::RequestCreateTexture XRTextureManager::RequestCreateTexture XRTextureManager::RequestCreateTexture XRTextureManager::SetupRenderTextureFromXRRequest (id: 1 col: 0000000000000000 d: 0000000000000000 sr: 0000000000000000) RenderTexture::Create (id: 1) XRTextureManager::SetupRenderTextureFromXRRequest (id: 2 col: 0000000000000000 d: 0000000000000000 sr: 0000000000000000) RenderTexture::Create (id: 2) XRTextureManager::SetupRenderTextureFromXRRequest (id: 3 col: 0000000000000000 d: 0000000000000000 sr: 0000000000000000) RenderTexture::Create (id: 3) XRTextureManager::SetupRenderTextureFromXRRequest (id: 4 col: 0000000000000000 d: 0000000000000000 sr: 0000000000000000) RenderTexture::Create (id: 4) [XR] [OpenVR] Created Native Color: 7a0bfab8 [XR] [OpenVR] Created Native Depth: 7a0bdb38 [XR] [OpenVR] Device connected (status change). Handle: 1458458000. OpenVRIndex: 0. UnityID: 0 [XR] [OpenVR] Device connected (status change). Handle: 1458458000. OpenVRIndex: 1. UnityID: 1 [XR] [OpenVR] Found device OpenVRIndex:(1) UnityIndex:(1) with input profile:(vive_tracker_handed) and name: (OpenVR Tracked Device(VIVE Tracker 3.0 MV)) [XR] [OpenVR] Created Native Color: 7a0bae78 [XR] [OpenVR] Created Native Depth: 7a0bc378 TrimDiskCacheJob: Current cache size 992mb [XR] [OpenVR] Device connecting (status change). OpenVRIndex: 2. UnityID: 2 [XR] [OpenVR] Device connected (status change). Handle: 1458458000. OpenVRIndex: 2. UnityID: 2 [XR] [OpenVR] Found device OpenVRIndex:(2) UnityIndex:(2) with input profile:() and name: (OpenVR Tracking Reference(Valve SR Imp)) [XR] [OpenVR] Device disconnected (stopping provider). Handle: 1458458000. DeviceID: 0 [XR] [OpenVR] Device disconnected (stopping provider). Handle: 1458458000. DeviceID: 1 [XR] [OpenVR] Device disconnected (stopping provider). Handle: 1458458000. DeviceID: 2 [XRInputSubsystem] A device disconnection with the id 0 has been reported but no device with that id was connected.[XR] [OpenVR] XR OpenVR Display Stop XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture [XR] [OpenVR] XR OpenVR Display Shutdown XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture XRTextureManager::RequestDestroyTexture [XR] [OpenVR] Shutdown

================================================================= Native Crash Reporting

Got a UNKNOWN while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.

================================================================= Managed Stacktrace:

at <unknown> <0xffffffff>
at System.Object:wrapper_native_00007FF831E842E0 <0x00908>
at <Module>:invoke_void_ETrackingUniverseOrigin_single_TrackedDevicePose_t[]_uint <0x0016d>
at Valve.VR.CVRSystem:GetDeviceToAbsoluteTrackingPose <0x000c2>
at ViveTrackers.ViveTrackersManager:UpdateTrackers <0x00312>
at ViveTrackers.ViveTrackersTest:Update <0x00178>
at System.Object:runtime_invoke_void__this__ <0x00187>

================================================================= Received signal SIGSEGV Obtained 2 stack frames

I was able to get around editor crash by writing a small method to exit playmode using a button on the keyboard. The point is simple:

  1. disable UpdateTrackers (so as not to call the 2 methods described above)
  2. wait a little time
  3. exit playmode

Using this workaround, the editor no longer crashes, but now you cannot exit playmode using a button in top panel in editor.

Another option I found is to replace the GetDeviceToAbsoluteTrackingPose method call with the OpenVR.Compositor.GetLastPoses method. I also disabled button handling because I couldn't find an alternative method to replace GetControllerState. Everything works, but the trackers are now a little jittery compared to the original method (this doesn’t bother me, as long as there are no crashes).

NyanCetch avatar Nov 07 '24 04:11 NyanCetch