At ArKaos we work a lot on the fluidity of the animations produced by our softwares. To do so we multi thread a lot the software and make the best use of the graphical acceleration.
It looks like on the Mac, under 10.5.6 at least, it’s very difficult to have perfectly fluid animations on one monitor while continuing to update a software interface on another monitor. Unfortunately it’s what we want to achieve in all our softwares.
I was able to reduce the problem by creating a simple application that draw a band in one window at 60 FPS. As soon as the system is slowing down you see clearly the speed of the animation being irregular. Because the code is very light, uses no texture, I was expecting this code to run very smoothly.
The function that is called for every frame is as simple as this one:
static int framecount = 0;
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
/* viewing transformation */
float x_pos = – ((framecount++ % 60) – 30.0) / 8.0;
gluLookAt (x_pos, 0.0, 5.0, x_pos, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (1.0, 2.0, 1.0); /* modeling transformation */
It simply draw a band like this that cycle in the window:
Because framecount is incremented for each new frame it has a very visible impact when you miss a frame, this is what I want to see.
Here is the result of sharking the application, untitled and untitled copy are the 2 instances running. You see that the whole machine is almost idle, but very clearly on this picture after 6 frames you see that the time between 2 ticks on the untitled line start to double:
I have the feeling that the problem is in the WindowServer process but it’s out of my scope to understand what is wrong there.
If you are curious my very simple GLUT sample is here GlutSample.zip
Once you unzip it just run band1 and band2 and move one window on a second monitor you should see the animation become irregular.
Here is the shark file GlutSample.mshark