Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TickEvent skipping seconds?

ANSWERED

I developed a watch face (LCD style with a few PNGs) and I've noticed that 1-2 seconds are missing every 10-15 seconds.

Is there an issue with this API? Or just performance?
Not that I care much, but I would love to understand a bit what's going on...

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Found it. I was using setInterval(clocker, 1000) as in the sample provided. The right way though is to use:

 

clock.granularity = "seconds";
clock.ontick = (evt) => {
clocker(evt.date);
}

This is more accurate then setting the interval.
The sample code should be updated to use this.

View best answer in original post

Best Answer
3 REPLIES 3

Are the images flickering, or do you think it's just skipping the tick event entirely?

 

You could try adding `load="sync"` on your <image> tags.

 

Are you doing much other processing within the tick event? And are you using the date object from the event itself, or are you instantiating a new date object?

Best Answer
0 Votes

It's not flickering at all, it's just skipping seconds.
I am instantiating a new date and not using sync. Let me make these changes and get back to you.

I use the LCD sample on github as starting point.

Best Answer
0 Votes

Found it. I was using setInterval(clocker, 1000) as in the sample provided. The right way though is to use:

 

clock.granularity = "seconds";
clock.ontick = (evt) => {
clocker(evt.date);
}

This is more accurate then setting the interval.
The sample code should be updated to use this.

Best Answer