CNA-BUG-088: In variable-step mode Game gives its first updates a non-zero ElapsedGameTime where XNA 4.0 reports zero
Evidence basis: source-verified at the pinned commit; tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.
The zero-first-update rule exists only on the fixed-step path; in variable step the first Update gets the time since Run() began, while XNA values recorded by CNA show zero elapsed for the first two updates.
- Identifier
CNA-BUG-088- Category
- Bug
- Subsystem
- Core & runtime
- Status
- Open
- Verified against
- CNA
009d40f5(009d40f5dd085c4e674d3479675fac84b12b3e0a) - Severity
- Low (a triage suggestion, not a project priority)
- Evidence basis
- Source-verified: read at TARGET, not executed
- Tests touching this area
- Yes: see Current tests
- Affected contract
- Microsoft::Xna::Framework::Game::Tick (variable time step) / GameTime.ElapsedGameTime
Expected behaviour
The comment on VariableStepTotalAlsoLagsItsOwnUpdate in GameClockFirstUpdateTests.cpp records the real XNA runtime reporting update 3 with elapsed 0.0211 and total still 0. Since total is the sum of the earlier elapsed values, XNA's first two variable-step updates had zero elapsed time.
Actual behaviour at TARGET
In Game.cpp the fixed-step branch uses hasUpdatedOnce_ ? TargetElapsedTime_ : Zero, but the variable branch passes the whole accumulator (or zero only after ResetElapsedTime). The first variable-step Update therefore sees the time since Run() seeded previousPerformanceCounter_, and the second sees a real frame interval.
Source locations
modules/runtime/src/Game.cpp— Game::Tick variable-step branchmodules/runtime/tests/Microsoft/Xna/Framework/GameClockFirstUpdateTests.cpp— VariableStepTotalAlsoLagsItsOwnUpdate and its recorded XNA values
Evidence
Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. XNA's values come from CNA's own recorded measurement in the test comment; the conclusion that both of XNA's first two updates had zero elapsed follows arithmetically from them. Why XNA reports zero twice (an initial Update plus a forced-zero first tick) was not re-derived from the IL.
Focused reproduction
No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.
Current tests
VariableStepTotalAlsoLagsItsOwnUpdate asserts only that each total equals the previous total plus elapsed; it does not assert the zero values it documents.
Regression test
Extend that test to assert elapsed == 0 for the first two variable-step updates (and total == 0 at update 3), matching the recorded XNA run.
Blast radius
Variable-step games whose first frames integrate ElapsedGameTime; the offset is one start-up interval, so simulations drift by that amount.
Workaround
Ignore ElapsedGameTime in the first two updates.
Related pages
The same subject is explained at several altitudes. These are the neighbouring pages at each one.
- Deep dives
- GameTime: variable step
- Known issues
- Bug index