[SailfishDevel] QML Timer stops running

Jonni Rainisto jonni.rainisto at jolla.com
Wed Jan 15 11:18:59 UTC 2014


You can for example listen to for activity suspend resume

And for display on/off signal is displayStateChanged:

Br, Jonni

From: devel-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] on behalf of Luca Donaggio [donaggio at gmail.com]
Sent: Wednesday, January 15, 2014 11:29 AM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] QML Timer stops running

I'm in a  similar situation: I've written a small app for my personal use that periodically download some stats from one of my company's web servers.
I'm perfectly fine with it not doing anything while in deep-sleep, but I would like to do a forced update as soon as the device wakes up.
How can I detect such event from C++ side (my app is run as a daemon actually, so no qml involved)? Is there some DBus signal I can listen to?


Luca Donaggio

On Wed, Jan 15, 2014 at 9:26 AM, Jonni Rainisto <jonni.rainisto at jolla.com<mailto:jonni.rainisto at jolla.com>> wrote:

For the love of ***, dont use libiphb every 5 seconds, that will kill batterylife for suspend (store QA will reject apps that eat battery). Its more meant to be triggered every 10, 15, 30 etc. minutes. So if you want to make 25 minute timer that works even while suspended, then you should do libiphb to wake up after 25 minutes.

Or if you want to make libiphb to wake up device every 10 minutes, you can make your application to check how much time has really passed since last wakeup by checking hw clock (as that is the only clock which is updated even while beeing suspended) timestamps like this:

static void tv_get_monotime(struct timeval *tv)
#if defined(CLOCK_BOOTTIME)
  struct timespec ts;
  if (clock_gettime(CLOCK_BOOTTIME, &ts) < 0)
      if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
          qFatal("Can't clock_gettime!");

From: devel-bounces at lists.sailfishos.org<mailto:devel-bounces at lists.sailfishos.org> [devel-bounces at lists.sailfishos.org<mailto:devel-bounces at lists.sailfishos.org>] on behalf of Thomas Tanghus [thomas at tanghus.net<mailto:thomas at tanghus.net>]
Sent: Tuesday, January 14, 2014 4:11 PM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] QML Timer stops running

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
SailfishOS.org Devel mailing list
SailfishOS.org Devel mailing list

Luca Donaggio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140115/e30fdd77/attachment.html>

More information about the Devel mailing list