Precision Drift in t() Over Long Uptimes
Bug Description
Over hours, floating-point division yields cumulative precision drift.
This results in noticeable glitching in all applications that derive any of their values from t() at any point during their _update() or _draw() functions.
Summary
- Root cause:
lua54_time()uses60.0f(32-bit), resulting in precision drift - Fix: change
60.0f=>60.0 - Alternatives: new
stat(STAT_SEC_TICKS)orstat(STAT_TICKS_RUNNING, n)
If this is behaving as intended or you go with the "Fix", I implore you to consider implementing one of the stat() solutions!
Context
time()is the lua-side of the c functionlua54_time()lua54_time()returnscproc->ticks_running / 60.0as a lua_Numberticks_runningis a once-per-tick integer counter- (tick = 1/60 seconds) =>
t()increments ~0.01667 seconds per tick
- (tick = 1/60 seconds) =>
- No reliable sub-second API for long-running apps






0 comments