I discovered a strange behavior in MonoGame in full screen mode.
On a very fast system at 60Hz, most of the time it is 1/60sec (~17ms) between Draw() and the Update() calls and almost instantaneous from Update() back to Draw().
However, occasionally, (about 1 out of 100 refresh cycles), suddenly Draw() then Update() takes 2/60 sec (~33ms). But a smooth scrolling animation shows absolutely no judder at all, and I can see a single frame drop. The subsequent Draw-then-Update becomes suddenly 0/60sec to ‘catch’ up, before going back to a normal cadence of 1/60sec.
Since Update() does the keyboard reads, I need input reads to occur exactly 1/60sec apart for more predictable VSYNC ON activity – rather than erratically jittering around 1/60sec from proper input read timing (creating erratic input lag).
I’m using the Stopwatch object (better than microsecond resolution).
I’m getting these numbers (microseconds between Draw() and then Update() as an example:
0.0334241493 <— Double VSYNC
0.0000173187 <— Near instant
What’s causing this sudden major timing jitter? (that doesn’t show up as a visual judder of a dropped frame – motion is still perfectly smooth, zero frame drops).
The VSYNC buffering is probably smoothing it out perfectly with absolutely zero jitters, but the problem is that input reads occur with Update() and these sudden lag jitter is throwing aiming off. (Visualize this example about how important precise input reads are – A smooth scrolling archery target at 1000 pixels/sec = 17 pixels per refresh cycle. A mis-timed button read that’s late, will cause an arrow to miss the dead center when the button is timed perfectly – because of this strange bug that forces input reads to be out-of-sync with the displayed frame)
This is on a Geforce Titan, so the graphics performance is not an issue here. If VSYNC is OFF (graphics.SynchronizeWithVerticalRetrace = false) then framerate runs at >2000fps, so there is no rendertime issue at play here. Also, garbage collection pattern isn’t matching these intervals, so it doesn’t seem to be garbage collection either.
Is this a graphics driver behavior or something else?
Or a monogame issue?