I am part of a team building a special-purpose game for a customer with Unity. The game will be deployed on the customer’s internal LAN to be played inside virtual machine instances running on a hypervisor server. We are perfectly aware that a VM is not an ideal platform for running a Unity game and have discussed this at length with the customer, but due to their IT infrastructure and security policies the use of a VM is non-negotiable.
The virtual machines run CentOS 7. We’ve been building the game in Unity 2019.4.x (currently building from 2019.4.25f1) and are using the built-in render pipeline. We are currently testing in VMWare with hardware acceleration enabled in the VM graphics settings.
So on to the issue: we have found that, when run our Unity game in the CentOS 7 VM, the framerate is unrestricted. Application.targetFramerate and Vsync are both completely non-functional. For example, when I play in the VM on my PC, the game runs at 500 fps, regardless of the target framerate or whether vsync is enabled. This is problematic for several reasons:
- The engine is pushing the hardware as hard as it can, all of the time. This wastes electricity and taxes system resources on the host.
- In a single-core environment, asynchronously loading scenes is horrendously slow because the engine is burning so much CPU time on rendering that it scarcely devotes any time to loading.
The second issue is less important because there is the easy workaround of loading scenes synchronously, and it may turn out that the customer’s VM configuration offers multiple cores (haven’t gotten clarification on that point yet). The first issue is a much bigger problem; it will make the customer unhappy and may affect the performance of other VMs hosted on the same hypervisor.
Interestingly, Application.targetFramerate and vsync both work correctly in a real CentOS 7 machine; they only fail to work in the VM. I could imagine that perhaps the virtual GPU interface doesn’t support vsync, but I can’t imagine why Application.targetFramerate would not work.
Is this an engine bug? Are there any other solutions we can use?
@Tautvydas-Zilys I’ve seen you discuss frame throttling in other threads and would appreciate your input if possible.