A screen that stuttered at full speed
Nintendo DS 3D games stuttered on screen even while running at full speed. In 1.5.0 each frame gets a time to be shown, so frames reach the screen one at a time and evenly.
Playing a Nintendo DS 3D game, the screen sometimes stuttered while the game itself kept its speed. The game was making frames at full speed, but about a third of them never reached the screen.
A frame-rate readout was added to find where the stutter happened. The first line shows the frames per second the game made and its speed relative to the real hardware; the second shows new frames shown on screen and the display refresh rate. If the first line is at full speed and only the second is low, the problem is the screen, not the game. It can be turned on and off in the Display section of the pause menu.
DS games often draw their 3D 30 times a second, so heavy and light frames alternate and two frames finish at almost the same moment. The screen took the newest frame at every refresh, so it skipped the first of each such pair instead of showing it.
Now each frame gets a time to be shown: the moment the game was due to produce it, plus a short wait. Up to four frames are kept, and at every refresh the screen shows the newest frame whose time has come. Two frames that finish together now each get their own turn on screen.
The delay first covered most frames, then the latest frame completed in the last two seconds. But when a slow frame left that window, the delay shrank and another frame could be skipped. Now the delay rises immediately when a frame finishes later than the current delay allows, then stays put. It falls by one frame only after 30 seconds in which every frame could be shown on time with that shorter delay. The limit is two frames. A slightly later picture was the tradeoff for less stutter.
iOS and Android both choose frames this way. When the game system’s timing differs from the display refresh timing by no more than 1.2%, the game runs at the display’s rate and audio playback changes by the same ratio. On iOS, DS 3D graphics are also drawn on a thread separate from the game, and the DS core is built with link-time optimization (LTO).
On real hardware this was checked on one iPhone only. How evenly frames arrive on Android devices and in other games has not been measured yet.
Related development stories
- Development storiesv1.3.0Closed beta testing
Bringing button responses forward with run-ahead
A game draws the result of a button press a frame or more after reading it. Run-ahead runs those frames in advance to bring the response forward, and uses more battery for the extra work.
- Development storiesv1.2.0Closed beta testing
Reduce repeated work on paused screens
A still picture can keep the renderer busy. Version 1.2.0 distinguishes when another draw is needed and lets you try settings before saving.