Acknowledged

bug: Background.registerForTemporalEvent(pastMoment) triggers 5 minutes later instead of immediately

According to the documentation: https://developer.garmin.com/connect-iq/api-docs/Toybox/Background.html#registerForTemporalEvent-instance_function : "If a temporal event is scheduled for a time in the past, the event will trigger immediately."

When I try the following code in my datafield with SDK 4.1.7 simulator (fr255) {did not try on any real device, so I don't know if it works there}:

var lastTime = Background.getLastTemporalEventTime();
var nextTime = lastTime != null ? lastTime.add(new Time.Duration(300)) : Time.now();
log("now: " + timeFormat(Time.now()) + "lastTime: " + (lastTime == null ? null : timeFormat(lastTime)) + ", nextTime: " + timeFormat(nextTime));
Background.registerForTemporalEvent(nextTime);

I see this in the log:
now: 23:05:37, lastTime: 22:33:28, nextTime: 22:38:28

It doesn't throw an InvalidBackgroundTimeException, so I know that more than 5 minutes passed since last time it was called, and also from the logs we know that more than 30 minutes passed since last temporal event. And still it's not triggered immediately. In fact it's always triggered exactly 5 minutes later:

Background: 23:10:37 onTemporalEvent

Parents
  • As a temporal event can run at most every 5 minutes, "immediately" isn't correct.  It's "immediately 5 minutes after the last time it ran.  Also not, that in general, a background will run "as soon as possible" after it's scheduled time, and that means it could be 5 minutes later, or if you are running a device app, after that exits.

    There is no way to actually trigger the background "immediately".  The "every 5 minutes at most" rule always applies.

    When you say it took 30 minutes, is this in the sim or a real device?  Has you not registered a new temporal event last time it ran?  deleted the temporal event last time your app exited?

Comment
  • As a temporal event can run at most every 5 minutes, "immediately" isn't correct.  It's "immediately 5 minutes after the last time it ran.  Also not, that in general, a background will run "as soon as possible" after it's scheduled time, and that means it could be 5 minutes later, or if you are running a device app, after that exits.

    There is no way to actually trigger the background "immediately".  The "every 5 minutes at most" rule always applies.

    When you say it took 30 minutes, is this in the sim or a real device?  Has you not registered a new temporal event last time it ran?  deleted the temporal event last time your app exited?

Children
No Data