From 22293ed6932119aa428065068f87c59cb58c1b87 Mon Sep 17 00:00:00 2001 From: redraw Date: Thu, 22 Jan 2026 17:31:01 -0300 Subject: [PATCH] jump counter forward when tab resumes from background --- watch-library/simulator/watch/watch_rtc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/watch-library/simulator/watch/watch_rtc.c b/watch-library/simulator/watch/watch_rtc.c index cbda46b0..3492032f 100644 --- a/watch-library/simulator/watch/watch_rtc.c +++ b/watch-library/simulator/watch/watch_rtc.c @@ -180,9 +180,12 @@ static void _watch_schedule_next_tick(void) { next_tick_time += ms; double delay = next_tick_time - now; - // If we're behind, schedule immediately + // If we're behind, jump counter forward and reset timing if (delay < 0) { - delay = 0; + uint32_t missed_ticks = (uint32_t)((-delay) / ms); + counter += missed_ticks; + next_tick_time = now + ms; + delay = ms; } emscripten_async_call(_watch_increase_counter, NULL, delay);