You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix ecs_progress blocking when the clock does not advance between frames
Frame time measurement retried in a loop until the clock returned a
nonzero delta. On a clock that is too coarse to measure a short frame
(a browser with reduced timer precision, a coarse OS tick), every frame
that finishes within one clock quantum busy-spins reading the clock
until the quantum passes. On a clock that only advances when the host
steps it in between frames (emscripten without asyncify, simulated
clocks) the loop never exits and ecs_progress blocks forever.
A zero measurement now reports a minimal nonzero delta
(ECS_FRAME_MIN_DELTA_TIME) rather than measuring again until the clock
moves. Because the frame start time is written back value-identical when
the clock did not advance, the elapsed time is credited in full to the
frame in which the clock next advances, so no time is lost or invented
beyond the reported minimum. Reporting a nonzero delta also keeps every
existing divisor of delta_time safe. A delta of zero is already
observable today (time_scale 0, OnStart systems), so this changes no
contract for consumers. The first frame that reports the minimum logs a
warning, once per world, so a rate that was computed by dividing by it
can be traced to the clock rather than debugged as a spike.
The first-frame branch is now selected by a world flag instead of
testing the frame start time against zero, which pinned a simulated
clock that starts at 0 to the first-frame branch forever.
The world summary computed fps as 1.0 / delta_time_raw, which is inf
before the first measured frame (not representable in JSON on the REST
endpoint) and a rate in the billions on frames where the clock did not
advance. It now reports 0 when no measurable frame time exists, and the
windowed fps gauge in the stats addon applies the same threshold: a
stats window averaging at or below the minimum delta reports 0 instead
of the reciprocal of the minimum.
Tests cover a stalled clock, a stalled clock that reads 0, the warning
firing exactly once across repeated stalled frames, and a coarse clock,
including that measured deltas add up to how far the clock actually
moved; the stalled clock stats test pins the summary and the gauge
together.
Note: with a target FPS configured a stalled clock still blocks, in the
frame rate limiting loop of flecs_insert_sleep. That is a separate
defect with its own fix and tests, submitted as a follow-up PR.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments