Jarrah Technology logo

September 8, 2012

Category: News

Author: Charles

Vsync Twitter Facebook Share on Google+

The last couple of days I have struggling with frame stuttering or skipping in Unity3D. It seems that movement in my game would occasionally miss a frame or not update properly. It transpires that it is not Unity causing the problem, instead seems to be caused by a vsync mismatch between Windows and the video card.

Vsync is a system built into monitors to prevent screen tearing. A monitor updates the image it displays at a set rate - 60 times a second (hertz) for my monitor. However computers may prepare frames for display at a greater rate and if the computer updates the frame to display in the middle of the monitor displaying a frame then what is actually shown may be a mix of the two. This is screen tearing. Many games allow their framerate to be locked to monitor refresh rate to prevent tearing - this is vsync.

It seems Windows 7 also uses vsync to prevent tearing with its display. For some reason Windows uses a refresh rate of 59 hertz and I can’t seem to change it. This seems to cause a 1 frame per second mismatch, about the same rate of stutter observed. There are people with people with similar problems on the Unity forums here and here (and others, but the important information is just repeated).

I couldn’t find a way to change the monitor’s vsync rate. Instead I tried turning off vsync in Unity and with my slower mac with vsync - both resulted in the problem disappearing. Thus, I am fairly sure that the issue is not in my (still quite simple) Unity game. Although, there is some talk that this doesn’t happen in fullscreen mode, but when I tried fullscreen it still occurred.

I’m not sure how to completely fix this. With vsync turned off my game runs at around 4000 fps on my development machine, so there is little chance of tearing, but no guarantee other people will be as lucky. Anyone have any ideas?