[Sugar-devel] What should be the ideal range for animations FPS ?

James Cameron quozl at laptop.org
Tue Jan 7 16:21:40 EST 2014


On Tue, Jan 07, 2014 at 05:37:34PM +0100, laurent bernabe wrote:
> As I am programming on a recent laptop, it can be easy to call
> javascript method  setTimeout with too high values, without noticing
> the wrong behaviour for real XO.
> 
> This is why I am wondering what should be the ideal range for
> animations Frames Per Second value ?

There is no easy answer.  There are too many factors.

I can speak from experience with Pygame and attempt to explain how to
transfer that experience to Javascript.

Now, Pygame is a raster based animation, and Javascript drawing can be
vector based.  I do not know if the layer between Javascript and the
display handles this as vectors or a raster.  At worst, it will be a
raster.

A raster based animation must update the display by blitting changed
rectangles.

At worst, the entire drawing area must be blitted.

At best, only a small rectangle covering the motion must be blitted.
This is a rectangle that is the union of the old position of the
object and the new position of the object.

There is a sequence of steps between the application program and the
hardware:

- the application program makes drawing commands,

- the application program asks for a frame to be revealed (Pygame's
  display update), or the library assumes it (setTimeout),

- the library translates the display update into the display protocol;
  which for Pygame means the change is passed to SDL, which passes it
  to X,

- some time later, the X display server receives the change and
  updates the frame buffer,

- the light from the display reaches the user.  ;-)

There is a queue before the X display server.  It is possible to fill
the queue.  Once this happens, the displayed image lags behind the
application program, and if motion is being displayed the frame rate
will change according to the complexity of the update; a small update
will give a faster frame rate.

Too hight a frame rate on Pygame gives the above effect.  I would be
interested to hear what happens if you use too high a frame rate on
Javascript.

There is insufficient feedback from the system to the application to
determine the spare CPU time available.  So we often guess at a frame
rate.

The only way to find an appropriate frame rate is to test on a known
combination of hardware and software.  For the XO laptop, gather test
results with the following associated data:

- the model,

- the SKU,

- the operating system version,

- a measure of the raw CPU performance at a few known temperatures,

The last point is the most interesting to me.  Laptops of the same
model, SKU, and operating system version, do not all perform the same.
This can be due to thermal problems.  A fault in the heat transfer
system degrades performance, and basing assertions on such results is
incorrect.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list