Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SteamVR instance is never initialized due to XRSettings.enabled being false #793

Open
methusalah opened this issue Aug 2, 2020 · 16 comments

Comments

@methusalah
Copy link

Context: Unity 2020.1.0, HDRP on Windows 10, with SteamVR Unity plugin 2.6.0 and the OpenVR XR plugin v1 preview 12. "Initialize XR on Startup" and "OpenVR loader" are both checked in Unity project settings, and SteamVR 1.13.10 in running on my computer (I also tested with SteamVR shut down).

Running the Interactions_Examples scene, the player's steam VR objects are disabled and the fallback objects are enabled. I observe the same in my game using a single SteamVR_Behavior_Pose. SteamVR instance is not initialized and a null exception is raised each frame.

I've debbuged it a little and it appears that SteamVR class instance is never initialized because XRSettings.enabled is false. The only code path where XRSetting.enabled is set to true is by using the boolean "forceUnityVRToOpenVR" to true, which is only used in the component SteamVR_ForceSteamVRMode, as far as I understand. Of course, XRSettings.enabled could also be set to true in the Unity side but it is not in my situation.

Is there something I'm doing wrong here?

@zite
Copy link
Collaborator

zite commented Aug 2, 2020

Looked into it a little more, try just deleting lines 33/34 in SteamVR.cs that check to see if XRSettings.enabled is true

@methusalah
Copy link
Author

Ok that seem to allow me to run without issue, thanks!

Unfortunatly, I've got a systematic Unity crash when I leave play mode now. I suppose it is related since it appeared just after that only code modification. Here are Unity and SteamVR logs.

Editor.log
error.log
SteamVR-2020-08-02-PM_10_16_52.txt

@zite
Copy link
Collaborator

zite commented Aug 2, 2020

How about this instead of just deleting that section:

#if UNITY_2020_1_OR_NEWER
                if (!XRSettings.isDeviceActive)
                    enabled = false;
#else
                if (!XRSettings.enabled)
                    enabled = false;
#endif

Sorry I'm having you test this, I'm just not able to repro locally.

@methusalah
Copy link
Author

methusalah commented Aug 2, 2020

In this configuration, the SteamVR inctance is not instanced because XRSettings.isDeviceActive is always false during play time.

I can stop the playmode without crash.

But now, Unity crashes 50% times on enter playmode. I've noticed that if SteamVR is not running when a crash on enter play mode occur, it is not started at all.

I have also noticed thath SteamVR is not started when I open my Unity project, as it was back with 2019. Now it is only started when the game enters play mode. I don't know if any of this is relevant.

Don't hesitate if you need more information or have things to make me test.

@methusalah
Copy link
Author

methusalah commented Aug 2, 2020

I've build a new project and now I do not experience craches anymore with XRSettings.isDeviceActive. Yet, it is still always false and SteamVR instance never initialize.

I've noticed that sometimes, randomly, if SteamVR is not running, launching unity and even entering playmode won't start it. Resulting in this warning: "[SteamVR] Initialization failed. VR may be disabled in player settings. Go to player settings in the editor and check the 'Virtual Reality Supported' checkbox'. OpenVR is not in your list of supported virtual reality SDKs. Add it to the list in player settings. To force OpenVR initialization call SteamVR.Initialize(true). "

My process for building the project:

  • create a new HDRP project with Unity 2020.1
  • import XR plugin management
  • import the latest SteamVR unity plugin unitypackage, which import OpenVR XR plugin and activate itself in the settings.
  • copy my assets folder (except the SteamVR folders) from my working project to the new one.

Nothing fancy I suppose. I don't copy any library, binary, settings or whatnot. Only assets.

@matejdubec
Copy link

I am glad you pointed this one out because i am having the same issue. I didn't know what the problem was I only knew player's steamVR objects are always disabled in play mode. Also I think it only happens with HDRP projects because i created new URP project and it worked just fine.
My setup:

  • HDRP project
  • unity 2019.3.15f1
  • the latest steamVR unity plugin and OpenVR XR plugin

@methusalah
Copy link
Author

@matejdubec Can you debug and confirm that the issue is the same for you, having both XRSettings.enabled and XRSettings.isDeviceActive to false at all time during playmode?

This would tend to confirm that it is not a regression introduced by Unity 2020.1

@matejdubec
Copy link

@matejdubec Can you debug and confirm that the issue is the same for you, having both XRSettings.enabled and XRSettings.isDeviceActive to false at all time during playmode?

This would tend to confirm that it is not a regression introduced by Unity 2020.1

Yes but not before tomorrow (i don't have access to VR headset right now) but everything you described happened to me. I've got [SteamVR] Initialization failed warning as well as 'SteamVR_Behavior_Pose. SteamVR instance is not initialized and a null exception error. Also my controllers were visible after deleting lines 33/34 SteamVR.cs

@zite
Copy link
Collaborator

zite commented Aug 3, 2020

Just to confirm, you're both on beta 4 of the steamvr_unity_plugin, right? I tried the repro steps and am not able to produce any errors. Can one of you send me a barebones project that doesn't work?

@methusalah
Copy link
Author

I'm using SteamVR unity plugin 2.6.0b4. I will try and make you a minimal project with the error.

@methusalah
Copy link
Author

methusalah commented Aug 3, 2020

I've been able to reproduce the bug on a minimal project. You will find it via google drive here.

The process:

  • create a new HDRP project with Unity 2020.1.0f1,
  • into project settings, import XR plugin management,
  • import the unitypackage of SteamVR Unity Plugin v2.6.0b4 found here ,
  • OpenVR XR plugin is imported automatically in the process, and both "Initialize XR on Startup" and "OpenVR Loader" are checked,
  • in the sample scene, create a cube and add a SteamVR_behavior_pose component on it.

I've also removed the standard asset to save file weight.

@zite
Copy link
Collaborator

zite commented Aug 3, 2020

Thanks for the project, I was able to repro with it. Give this a try: https://drive.google.com/file/d/19rb9dATOtlW-h7iyUlgujWdcS2LqK56M/view

@methusalah
Copy link
Author

Thank you @zite, it solved the issue for me. SteamVR class instance is correctly initialized and I have experienced no crash so far.

Great job!

@matejdubec
Copy link

matejdubec commented Aug 4, 2020

I can confirm, it solved the issue for me as well. However I had to change the version in SteamVR.cs on line 33 but I'll be upgrading to newer version anyway so that's not a problem. Thank you very much!

@kinacho2
Copy link

Great job! You deserve an asado! thank you so much @zite! You are my hero now xD

@ary1111
Copy link

ary1111 commented Aug 18, 2020

I had this issue in 2019.3.14, so like @matejdubec I also had to change line 33 in SteamVR.cs once I imported package version 2.6.1. My code is:
#if UNITY_2019_3_OR_NEWER
Works as intended now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants