Game performance degrading when window does not have focus

Hi,

Per this issue: https://issuetracker.unity3d.com/issues/vr-earlyupdate-dot-xrupdates-cpu-usage-increases-by-about-2-dot-4ms-every-10minutes-if-the-unity-player-isnt-focused-on

Many of our users have been complaining about this bug, as sometimes SteamVR will switch focus away from the game window when the game is started. Looking at the bug report it looks like it won't get fixed for Unity 2018.3, and we definitely can't upgrade our production version of our game to a beta version of Unity. Does anyone know of a workaround for this issue? Or perhaps some way of forcing focus to the game window?

The fix is being back ported to 18.3. I'm don't have a specific version of 18.3 as of right now, but I am trying to land it in the earliest release possible due to it's severity. Depending on your time frame for shipping your game, if you can wait a week or two for the fix, don't upgrade to 19.2.

2 Likes

Thank you, that's great news.

Will the fix be available for 18.2 too? Does anyone found any workarounds?

BigscreenVR dev here. Our issue was ballooning PF delta when backgrounded, killing our perf after a minute. We tracked it down to some mishandled WndProc messages related to focus and activate, so we overrode the WndProc with our own, and sent these message types to the default message handler instead of Unity's. Hope this helps!

2 Likes

The latest patch notes state: "XR: Fixed performance degradation over time for Virtual Reality applications. (1130392)"

Can someone confirm that it's the same issue as listed above? Only asking for clarification because the issue ID's do not match (in patch notes 1130392, issue id on tracker 1112790)

I can confirm that is the fix. The issue tracker ID for 2018.3 was different from 2019.1 because of our back port tracking. The fix should be out in 2018.3+ latest versions.

Thanks, but on the issue page (https://issuetracker.unity3d.com/issues/vr-earlyupdate-dot-xrupdates-cpu-usage-increases-by-about-2-dot-4ms-every-10minutes-if-the-unity-player-isnt-focused-on) the resolution note states that the fix for this issue is only on 2018.3.10, is that a mistake or are there in fact multiple similar issues?

[quote=“return_chris”, post:5, topic: 735352]
BigscreenVR dev here. Our issue was ballooning PF delta when backgrounded, killing our perf after a minute. We tracked it down to some mishandled WndProc messages related to focus and activate, so we overrode the WndProc with our own, and sent these message types to the default message handler instead of Unity’s. Hope this helps!
[/quote]
After updating to 2018.3.9, I’m still seeing the issue, and I’m worried about waiting to see if 2018.3.10 actually fixes it. Would you be willing to describe your workaround in more detail? I’ve looked around, but I’m not sure how to override the WndProc. Is this something you need a Unity source license for, or are you able to do it in C#?

Update: 2018.3.10 came out, and I verified that it fixed the issue for us.

1 Like

I'm getting a report from a player where we have the exact opposite: When the game window has no focus, performance is fine (90FPS) - but when the game window has focus, performance is atrocious (22FPS).

I can't reproduce this issue on my end, but here's some data from our logfile (that doesn't show anything suspicious otherwise):

Initialize engine version: 2019.3.9f1 (e6e740a1c473)

Direct3D:
    Version:  Direct3D 11.0 [level 11.1]
    Renderer: NVIDIA GeForce GTX 1060 6GB (ID=0x1c03)
    Vendor:  
    VRAM:     6052 MB
    Driver:   26.21.14.4587

OpenVR initialized!

Created eye textures with a "double wide" layout.  The "single-pass" stereo mode will be used.

Windows 10  (10.0.0) 64bit
Processor: AMD Ryzen 7 1700 Eight-Core Processor  --- Cores: 16 --- Frequency: 3000
Graphics device: 'NVIDIA GeForce GTX 1060 6GB', vendor: 'NVIDIA'
VR SDK: OpenVR
HMD: Vive. MV (HTC Vive)
Initial resolution: 1512x1680 (game SS: 1)