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 alloc 1.7k on a background thread #1077

Open
AndersMalmgren opened this issue Dec 17, 2022 · 6 comments
Open

SteamVR alloc 1.7k on a background thread #1077

AndersMalmgren opened this issue Dec 17, 2022 · 6 comments
Labels
Fixed in next release Fix coming in next release

Comments

@AndersMalmgren
Copy link

I tried with SteamVR disabled and only use OpenXR. That does not allocate anything. I then try SteamVR and then it allocates 1.7kb in a background thread

image

You need to test this with a built player otherwise the editor keeps polluting the profiler

@AndersMalmgren
Copy link
Author

I have found the culprit. Package com.valvesoftware.unity.openvr in file OpenVRLoader.cs uses a System.IO.FileSystemWatcher to detect somekind of changes to some mirror cfg something, something. System.IO.FileSystemWatcher seems to allocate under Mono.

@zite
Copy link
Collaborator

zite commented Dec 19, 2022

Thanks for looking into this, Anders. I believe that watcher should be disabled for builds

@AndersMalmgren
Copy link
Author

Thanks for looking into this, Anders. I believe that watcher should be disabled for builds

Hi. It's enabled for builds at least the version included in latest steamvr plugin.

@AndersMalmgren
Copy link
Author

Hi again @zite I just checked, code in master is identical to the one from latest unity plugin

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

@AndersMalmgren
Copy link
Author

Also this method allocates when joystick is being used

    private static void UpdateActionSetsArray()
    {
        List<VRActiveActionSet_t> activeActionSetsList = new List<VRActiveActionSet_t>();

        SteamVR_Input_Sources[] sources = SteamVR_Input_Source.GetAllSources();

        for (int actionSetIndex = 0; actionSetIndex < SteamVR_Input.actionSets.Length; actionSetIndex++)
        {
            SteamVR_ActionSet set = SteamVR_Input.actionSets[actionSetIndex];

            for (int sourceIndex = 0; sourceIndex < sources.Length; sourceIndex++)
            {
                SteamVR_Input_Sources source = sources[sourceIndex];

                if (set.ReadRawSetActive(source))
                {
                    VRActiveActionSet_t activeSet = new VRActiveActionSet_t();
                    activeSet.ulActionSet = set.handle;
                    activeSet.nPriority = set.ReadRawSetPriority(source);
                    activeSet.ulRestrictedToDevice = SteamVR_Input_Source.GetHandle(source);

                    int insertionIndex = 0;
                    for (insertionIndex = 0; insertionIndex < activeActionSetsList.Count; insertionIndex++)
                    {
                        if (activeActionSetsList[insertionIndex].nPriority > activeSet.nPriority)
                            break;
                    }
                    activeActionSetsList.Insert(insertionIndex, activeSet);
                }
            }
        }

        changed = false;

        rawActiveActionSetArray = activeActionSetsList.ToArray();

        if (Application.isEditor || updateDebugTextInBuilds)
            UpdateDebugText();
    }

@zite
Copy link
Collaborator

zite commented Feb 8, 2023

Thanks, I've got this fixed in the beta branch and it'll go into the next release.

zite added a commit that referenced this issue Feb 8, 2023
Pose prediction - Poses were predicting two frames ahead instead of using the driver's prediction for the next frame. Switched back to that.
ActionSet / SteamVR.enabled - GC / Perf fixes. Thanks Anders #1077
RingBuffer - Odd perf issue with DateTime. Switched to Time.realtimesincestartup. Set SteamVR_RingBuffer.UseDateTimeForTicks to true to use the old version.
@zite zite added the Fixed in next release Fix coming in next release label Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in next release Fix coming in next release
Projects
None yet
Development

No branches or pull requests

2 participants