ValveSoftware / steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
BSD 3-Clause "New" or "Revised" License
1.02k stars 255 forks source link

GetDigitalActionData error InvalidHandle handle when starting the game with the controllers turned off. #894

Open matt-bcs opened 3 years ago

matt-bcs commented 3 years ago

Hello,

On a standalone windows 64bit build, in each frame, each action prints out the following debug error when starting the game with controllers turned off.

[SteamVR] GetDigitalActionData error (/actions/default/in/MenuSelect): InvalidHandle handle: 1152945556423704825 UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:LogError(Object) Valve.VR.SteamVR_Action_Boolean_Source:UpdateValue() Valve.VR.SteamVR_Action_In_Source_Map`1:UpdateValues() Valve.VR.SteamVR_Input:UpdateNonVisualActions() Valve.VR.SteamVR_Input:Update()

The game starts with "Initialize XR on Startup" unchecked and launches into VR mode based on command line arguments.

This is the following code in SteamVR_Action_Boolean.cs that leads to the error.

`public override void UpdateValue() { lastActionData = actionData; lastActive = active;

        EVRInputError err = OpenVR.Input.GetDigitalActionData(action.handle, ref actionData, actionData_size, inputSourceHandle);
        if (err != EVRInputError.None)
            Debug.LogError("<b>[SteamVR]</b> GetDigitalActionData error (" + action.fullPath + "): " + err.ToString() + " handle: " + action.handle.ToString());`

While I don't know 100% for sure, it seems pretty consistent that starting the game with the controllers powered on and recognized this issue does not occur.

Unity 2020.2.0f1 OpenVR XR Plugin 1.1.4 XR Plugin Management 3.2.17 XR Legacy Input Helpers 2.1.6 IL2CPP Build

zite commented 3 years ago

Hi, thanks for the report. Is this with a clean project, just the plugin? Are there any errors above this? What code are you using to start vr mode?

matt-bcs commented 3 years ago

This project is full game project. It has been through many iterations of Unity upgrades. Here is the code that starts VR Mode:

        private void Start()
        {
            StartCoroutine(StartXRInternal());
        }

        IEnumerator StartXRInternal()
        {

            Debug.Log("Initializing XR...");
            yield return XRGeneralSettings.Instance.Manager.InitializeLoader();

            if (XRGeneralSettings.Instance.Manager.activeLoader == null)
            {                Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
                _xrStartFailed.Invoke();
            }
            else
            {
                Debug.Log("Starting XR...");
                XRGeneralSettings.Instance.Manager.StartSubsystems();
                _xrStartSucceeded.Invoke();
            }
            yield return null;
        }

On success, I initiatize SteamVR with the following line of code:

Valve.VR.SteamVR_Behaviour.Initialize();

I don't have a clean repro set up at the moment, but might be able to get one tomorrow. If you otherwise prefer, I can get you access to the beta branch of the game. It is exhibiting the behavior on that build.

As a side note, we experience this in the editor as well. I haven't pinned down why. This happens to both myself and another developer.

On another slight side note, one thing that tripped me up for a few days...it seems like you better have your Asset Serialization set to Force Text. My project was set as mixed and that was copying an OpenVRSettings.asset with binary data to the streaming resources folder. The runtime seems to require the yaml/text version of OpenVRSettings.asset. That was a fun one to track down. :-)

In addition to that, after each build I need to remove the following line from the boot.config that is created for the build: xrsdk-pre-init-library=XRSDKOpenVR. If I do not, Unity attempts to always initialize XR at game start regardless of the setting in editor.

zite commented 3 years ago

Thanks for the additional info. Got some more questions for you: Does SteamVR initialize after you call that function, and before errors? What version of the steamvr plugin are you upgrading from? (when it last worked) Can you send me a player / editor log?

matt-bcs commented 3 years ago

After a bit more experimentation, it looks like the more likely cause here is whether or not Steam VR has started before the game is launched.

Here are some consistent observations after a bit of testing launching from the Steam Desktop App:

In all cases, Unity successfully recognizes and provides positional data on the controllers.

Does SteamVR initialize after you call that function, and before errors?

SteamVR initialize is called after the function and before the errors.

What version of the steamvr plugin are you upgrading from? (when it last worked)

v2.6.1 (sdk 1.13.10) and before that v1.2.3. One thing to note, the previous version I know to completely work used Unity XR input mechanisms. I have not yet had a fully successful experience moving to the action model. This transition from Unity XR input to Steam VR is in concert with moving to a newer version of Unity where Unity XR button input no longer fuctions.

Can you send me a player / editor log?

I will share a log of a failed run and a success run via email.

Thank you!

zite commented 3 years ago

Thanks, investigating...

zite commented 3 years ago

Sorry, just to be clear: you're saying this is happening when you're launching your game from the Steam client? (has an appid and everything?) In that case, a key / beta access would be helpful, send it over to my email

drewofficial commented 3 years ago

I had a similar problem. Switching back to a previous release did it for me.

matt-bcs commented 3 years ago

Hi @drewofficial. Are you saying switching back to 2.6.1 solved the issue?

drewofficial commented 3 years ago

Hi @matt-bcs. Yes it did solve it for me.

I think my problem only differed from yours in that way that even if one/both controller/s was/were connected, I received this error. But now after switching back to 2.6.1, everything is working again.

CarpetHead commented 3 years ago

We have a nearly identical issue with our application. You can get it on steam for free https://store.steampowered.com/app/551370/Gravity_Sketch/

It doesn't happen every time. To get the best chance of reproducing it, fully close SteamVR before trying to launch the app, and allow SteamVR to be opened by opening our app. You know you hit it when all of your inputs don't work. It's affecting a lot of our users.

I use an index with knuckles to reproduce it, but it seems to affect WMR headset users too, at least

It looks to be affecting quite a lot of our users, it would be great if you could help :)