ValveSoftware / unity-xr-plugin

OpenVR plugin for Unity's XR API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Freeze on close when game is built with IL2CPP

Meoo opened this issue · comments

https://github.com/ValveSoftware/unity-xr-plugin/blob/master/com.valve.openvr/Runtime/OpenVRLoader.cs#L259

When the project is built with IL2CPP, the thread OpenVRLoader.ManualFileWatcherLoop() never stops, freezing the application.

The variable "running" is never set to false, setting it to false in my debugger correctly closes the application.

There are 2 versions of this function, and one is specific for IL2CPP, which could explain why this error does not happen with Mono builds.

I am using Unity 2020.2.2f1 and SteamVR plugin 2.7.2 (which has openvr 1.1.4)

More info:

The freeze only happens when trying to close the app from the desktop while SteamVR is still running, when doing so, the logs show the stop & shutdown events but freeze anyway:

[XR] [OpenVR] XR OpenVR Display Stop
[XR] [OpenVR] XR OpenVR Display Shutdown
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
[XR] [OpenVR] Shutdown
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
[XR] [OpenVR] Device disconnected (stopping provider). Handle: -2133114816. DeviceID: 0
[XR] [OpenVR] Device disconnected (stopping provider). Handle: -2133114816. DeviceID: 1
[XR] [OpenVR] Device disconnected (stopping provider). Handle: -2133114816. DeviceID: 2
-> Some game objects are destroyed, then the app freezes

Shutting down VR or closing the game from SteamVR works as intended, although the thread is not terminated cleanly :

[XR] [OpenVR] Device disconnected (stopping provider). Handle: -254066624. DeviceID: 0
[XR] [OpenVR] Device disconnected (stopping provider). Handle: -254066624. DeviceID: 1
[XR] [OpenVR] Device disconnected (stopping provider). Handle: -254066624. DeviceID: 2
[XRInputSubsystem] A device disconnection with the id 1 has been reported but no device with that id was connected.
UnityEngine.XR.Management.XRLoaderHelper:StopSubsystem()
Unity.XR.OpenVR.OpenVRLoader:Stop()
UnityEngine.XR.Management.XRManagerSettings:DeinitializeLoader()
UnityEngine.XR.Management.XRGeneralSettings:DeInitXRSDK()
UnityEngine.DisplaysUpdatedDelegate:Invoke()

[ line 1244589864]

ThreadAbortException
  at Unity.XR.OpenVR.OpenVRLoader.ManualFileWatcherLoop () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.TimerCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.Video.ErrorEventHandler:Invoke(VideoPlayer, String)

[XR] [OpenVR] XR OpenVR Display Stop
[XR] [OpenVR] XR OpenVR Display Shutdown
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
XRTextureManager::RequestDestroyTexture
[XR] [OpenVR] Shutdown
-> Some gameobjects are destroyed, then the app is closed gracefully

this is happening to me as well. Any updates?

calling the Stop method on the loader fixes this
OpenVRLoader.Stop()

courtesy of @zezba9000