[SailfishDevel] QML Timer stops running

Thomas Tanghus thomas at tanghus.net
Tue Jan 14 14:11:00 UTC 2014


On Tuesday 14 January 2014 13:05 Graham Cobb wrote:
> On 14/01/14 01:14, Thomas Tanghus wrote:
> > On Tuesday 14 January 2014 01:53 Ove Kåven wrote:
> >> No matter what OS or platform you're on, counting the number of times
> >> your timer callback is called is *never* a good idea, even on desktop
> >> PCs. Timer callbacks can be skipped for any number of reasons (heavy
> >> system load, laptop suspend, etc).
> 
> > Good point. That will also at least work around the issue when in
> > "pre-deep- sleep".
> 
> I agree with Ove (that is how every timer function I have ever worked on
> works, from interrupt handlers in embedded system kernels through to the
> GPE Calendar app) -- repeating timers are a convenience, but are never
> treated as accurate.
> 
> But I would also suggest that for any apps that do timing, when the app
> is not being displayed (and so the screen doesn't need to be updated),
> the code should switch to using a single-shot timer set to the time when
> the next event happens, instead of using repeating timers.  If the
> kitchen timer is set for 25 minutes and the screen is blank you don't
> want your app waking up every second.  Of course, it is a little bit
> tedious to write the code to cancel the long timer and restart short
> timers when the screen is turned back on but the user will thank you for it.

It sounds like a good idea, and should be fairly easy to implement. I just 
don't know how to detect when the screen is off (this is my first baby-steps 
in mobile coding). We have the applicationActive property, but the cover can 
still be active and visible while it is false.

> Unfortunately, I have no idea how you actually set up a single shot
> timer that will fire correctly in deep sleep from the Qt environment
> (the last time I implemented that logic was on Maemo).

Rainisto pointed to libiphb[1] which I have now implemented with a crude 
wakeup every 5-10 seconds. Not optimal, but I'm OK with it for v 0.1.1 ;)

[1] http://talk.maemo.org/showpost.php?p=1401318&postcount=2

-- 
Med venlig hilsen / Best Regards

Thomas Tanghus


More information about the Devel mailing list