Skip to content

fix: deliver timer delta (not frame delta) in Tick.delta (#116)#120

Merged
meszmate merged 1 commit into
mainfrom
issue-116
Jun 28, 2026
Merged

fix: deliver timer delta (not frame delta) in Tick.delta (#116)#120
meszmate merged 1 commit into
mainfrom
issue-116

Conversation

@meszmate

Copy link
Copy Markdown
Owner

Tick.delta was set to the per-frame render delta (~16ms at 60fps) for both one-shot and repeating timers, so everyMs(100) reported ~16ms instead of ~100ms, contradicting its "nanoseconds since last tick" documentation. This now delivers the actual timer delta — time since the previous tick for repeating timers (every), and time since the tick was scheduled for one-shot timers (tick, via a new pending_tick_scheduled_at anchor) — while the per-frame render delta remains available through ctx.delta / ctx.deltaSec() / ctx.fps(). On suspend/resume both timer anchors are rebased to the resume instant so the first post-resume delta is a normal interval rather than the whole suspended span. The Tick.delta doc comment was rewritten to match the real behavior. zig build and zig build test pass.

Fixes #116

`Tick.delta` was set to the per-frame render delta (~16ms at 60fps) for
both one-shot and repeating timers, so `everyMs(100)` reported ~16ms
instead of ~100ms — contradicting its "nanoseconds since last tick" doc.

Deliver the actual timer delta instead:
- repeating (`every`): time since the previous tick (`elapsed - last_every_tick`)
- one-shot (`tick`): time since the tick was scheduled, via a new
  `pending_tick_scheduled_at` anchor

The per-frame render delta remains available via `ctx.delta` /
`ctx.deltaSec()` / `ctx.fps()`. On suspend/resume both timer anchors are
rebased to the resume instant so the first post-resume delta is a normal
interval rather than the whole suspended span. Rewrote the `Tick.delta`
doc comment to match the actual behavior.

Fixes #116
@meszmate meszmate closed this Jun 27, 2026
@meszmate meszmate deleted the issue-116 branch June 27, 2026 17:06
@meszmate meszmate restored the issue-116 branch June 28, 2026 07:30
@meszmate meszmate reopened this Jun 28, 2026
@meszmate meszmate merged commit 226dd3f into main Jun 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zz.msg.Tick.delta contains the time since the last frame, not the last tick

1 participant