[haiku-development] Screensaver SetTickSize()?

  • From: Caitlin Shaw <rogueeve@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 22 Sep 2009 14:48:16 -0700

I believe I may have found a bug in the ScreenSaverRunner 
(/src/kits/screensaver/ScreenSaverRunner.cpp:202).


The Be Book states in regards to the SetTickSize() function:

<< The default tick size is 50000 (50 milliseconds). Setting the tick 
size to 0 causes *Draw() 
<http://www.bebox.nu/bebooks/BeBookR5/Screen%20Saver/ScreenSaverClass.html#Draw%28%29>*/*DirectDraw()
 
<http://www.bebox.nu/bebooks/BeBookR5/Screen%20Saver/ScreenSaverClass.html#DirectDraw%28%29>*
 
to be called with almost no delay; in reality, there will be some 
variable delay depending on scheduling latency >>

-- which implies that there is no specific minimum tick rate.
However, the replacement ScreenSaverRunner used by Haiku is unable to 
honor tick sizes smaller than 50ms, and will never tick  at a rate 
faster than 50ms. If you check the code:

    const uint32 kTickBase = 50000;
    <--snip-->
       // break the idle time up into ticks so that we can evaluate
        // the quit condition with greater responsiveness
        // otherwise a screen saver that sets, say, a 30 second tick
        // will result in the screen saver not responding to deactivation
        // for that length of time
        snooze(kTickBase);
        if (system_time() - lastTickTime < tick)
            continue;
        else {
            // re-evaluate the tick time after each successful wakeup -
            // screensavers can adjust it on the fly and we must be
            // prepared to accomodate that
            tick = fSaver ? fSaver->TickSize() : kTickBase;
            lastTickTime = system_time();
        }

If the screen saver sets the tick size smaller than kTickBase (50000us), 
then the runner will see it but stills snoozes for 50000 before checking 
if the time is up. This prevents the screensaver from running at it's 
requested rate.

The addition of something such as
    if (tick < kTickBase) kTickBase = tick;
    else if (kTickBase < 50000 && tick >= 50000) kTickBase = 50000;

after "tick = fSaver ? fSaver->TickSize() : kTickBase", should solve 
this issue. Of course a constant to replace 50000 might be nice as well. 
I assume the "k" in "kTickBase" is hungarian notation for "constant", so 
that might would want to be changed also.





Other related posts: