[Task Scheduler] Repeating alarms

I notice that the API only allows one-shot alarms (setTimeout style), so
apps that want to run periodically (both at exact times like a recurring
alarm/calendar event, and inexact times like background syncing) must
schedule a new task every time their task gets started.

That helps to keep the API nice and simple, but I worry that it might cause
sporadic failures. Specifically, if the app crashes, gets killed, or hits
an exception, in between the task starting and the app scheduling its next
execution, it will never be run again (until the app is next manually
launched, at which point a well-written app might check that the task is
still scheduled, though many apps may neglect to do this).

Two possible solutions:

1. Automatically schedule an additional task if a task crashes or gets
killed. However, there's a risk that this would perform actions twice (e.g.
if the background task sends an email, and we run an additional task with
the same data, 2 emails might get sent); alternatively we could pass null
data, but then that might confuse an app that only every schedules itself
with data. So I'm not really sure this is workable.

2. Add a recurring alarm variant. It might make sense to only allow inexact
alarms<http://lists.w3.org/Archives/Public/public-sysapps/2013Nov/0019.html> to
automatically recur; this would also allow us to simplify the API, as with
inexact alarms you don't actually need to specify an interval, instead the
browser will heuristically determine how often you deserve to get run (or
we could allow providing a "minimum interval", which is the period of time
after a given task execution during which the task should *not* be run, and
after that the browser can schedule the task whenever).

What do people think?
Thanks,
John

Received on Wednesday, 13 November 2013 12:39:09 UTC