[plt-scheme] FrTime: Animations get slow on Mac OSX...

From: Gregory Cooper (greg at cs.brown.edu)
Date: Tue Apr 10 11:11:43 EDT 2007

Hi Cyprien,

I have also noticed that animations seem to run more slowly under
MacOS, but I don't know why.  The fact that you can observe it even
when using MrEd directly suggests that FrTime is not the (only) cause.
 I don't think MacOS is really to blame, either, since most programs
(other than DrScheme) have excellent graphics performance.  I suspect
the problem is that less effort has been spent on optimizing WxWindows
for MacOS than for the other operating systems.  Sorry I can't offer
more help than that.

By the way, I'm impressed that you've figured out how to use FrTime at
such a low level.  However, this indicates that you're perhaps not
making the best use of it.  The goal is to be able to write programs
like this in a declarative style (without using set!).  For example,

(require (lib "animation.ss" "frtime"))

(define ball-coord
  (letrec ([bx (+ 15 (integral vx))]
            [by (+ 45 (integral vy))]
            [vx (accum-b ((when-e (or (> bx 390) (< bx 10))) . -=> . -) .06)]
            [vy (accum-b ((when-e (or (> by 390) (< by 10))) . -=> . -) .12)])
    (make-posn bx by)))

(display-shapes
 (list
  (make-rect (posn- mouse-pos (make-posn 15 15)) 30 10 "blue")
  (make-circle ball-coord 10 "red")))

On 4/10/07, Cyprien Nicolas <c.nicolas at gmail.com> wrote:
> Hi all,
>
> First, sorry for not so good English.
>
> I am trying to make a ball bouncing using FrTime, I have entered that code :
>
>
> (require (lib "frp-core.ss" "frtime")
>          (lib "animation.ss" "frtime"))
>
> (define-values (bx by) (values 15 45))
> (define-values (vx vy) (values  1  2))
> (define ny 350)
> (define DELAY 1)
>
> (define (update-bx) ; Manage x coordinate
>   (set! bx (+ bx vx))
>   (if (or (< bx 10) (> bx 390))
>       (set! vx (- vx)))
>   bx)
> (define (update-by) ; Manage y coordinate
>   (set! by (+ by vy))
>   (if (or (< by 10) (> by 390))
>       (set! vy (- vy)))
>   by)
>
> (define ball-coord ; The signal used to manage ball position
>   (let ([ret (proc->signal void)])
>     (set-signal-thunk! ret
>                        (lambda ()
>                          (let ([t (current-milliseconds)]
>                                [x (update-bx)]
>                                [y (update-by)])
>                            (schedule-alarm (+ DELAY t) ret)
>                            (make-posn x y))))
>     (set-signal-value! ret ((signal-thunk ret)))
>     ret))
>
> (display-shapes
>  (let ((nx (- (posn-x mouse-pos) 15)))
>      (list
>       (make-rect (make-posn nx ny) 30 10 "blue")
>       (make-circle ball-coord 10 "red"))))
>
>
> That code works fine running Linux and Windows, but there is some
> short slow down running OSX.
> I had a similar problem using MrEd libraries to do the same thing with
> objects. The speed of animation is constant on Linux, and alternate
> with faster and slower speeds on Mac OS.
>
> I don't have any idea where this comes from.
>
> I'm using DrScheme 369.8-svn19feb2007 [3m] (installed on the
> university's computers),
> using the following hardware :
>
>   CPU : Intel Core 2 Duo
>   Frequency :   2 GHz
>   Number of cores :     2
>   L2 cache :    4 Mo
>   RAM : 1 Go
>   RAM speed :   667 MHz
>
> Thanks,
> Cyprien Nicolas
> c.nicolas at gmail.com
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.