Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

Discussion in 'AR/VR (XR) Discussion' started by gskinner, Feb 1, 2017.

  1. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    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
     
    Last edited: Feb 1, 2017
  2. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    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.
     
    Last edited: Feb 1, 2017
  3. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    I've also confirmed this on my home machine, with Unity 5.5.0f3

    The entire bug can be reproduced with this single class:
    Code (CSharp):
    1. public class CpuSpikeBug : MonoBehaviour {
    2.     /**
    3.     * Add this class to any gameObject in a VR enabled scene
    4.     * export a build, and run it
    5.     * Press SPACE to cause permanent CPU spike.
    6.     **/
    7.     void OnEnable() {
    8.         print(SteamVR_Render.instance);//Comment out this line, and the bug goes away.
    9.     }
    10.     void Update() {
    11.         if (Input.GetKeyDown(KeyCode.Space)) {
    12.             VRSettings.LoadDeviceByName("None");
    13.         }
    14.     }
    15. }
    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:
     
    Last edited: Feb 1, 2017
  4. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    Bump?