BUG: Major CPU Spike in Release Builds when disabling SteamVR.

When disabling VR in a release build, it causes my CPU to spike to 80% usage.

Here’s a video of it in action:
http://treefortress.com/shared/2017-01-31_16-33-46.mp4 (skip to 10s as I let it stabilize)

Notes:

  • This does NOT happen in the editor, only in release builds.
  • Nothing is present in the logs to indicate any sort of error.
  • It only seems to occur when a SteamVR_TrackedObject is attached to the
  • Using Unity 5.5.1f1

This is causing me issues when testing my multiplayer game locally, as I want to disable VR on one instance of the game, and use VR in another instance, but the performance is so poor that I can barely test.

I’ve uploaded a reproduction build, and logged a bug here:
https://fogbugz.unity3d.com/default.asp?876462_df7niip7v98s2dri

I’ve narrowed it down to this line of code:

void OnEnable(){
var render = SteamVR_Render.instance;
}

If you have that on a script, and you disable VR, this CPU spike comes out of nowhere.

The call to .instance initializes SteamVR_Render and SteamVR singletons, which must be the root cause of this.

I’ve also confirmed this on my home machine, with Unity 5.5.0f3

The entire bug can be reproduced with this single class:

public class CpuSpikeBug : MonoBehaviour {
    /**
    * Add this class to any gameObject in a VR enabled scene
    * export a build, and run it
    * Press SPACE to cause permanent CPU spike.
    **/
    void OnEnable() {
        print(SteamVR_Render.instance);//Comment out this line, and the bug goes away.
    }
    void Update() {
        if (Input.GetKeyDown(KeyCode.Space)) {
            VRSettings.LoadDeviceByName("None");
        }
    }
}

It’s strange because the CPU load doesn’t show up in TaskManager under the UnityProcess, but you can clearly see the huge spike on cores #1, 2, 4, 6, 7, 8:

Bump?