Skip to content

Fix aim jitter at high FPS limits by pacing at the game timer update - #5417

Open
Zephkek wants to merge 1 commit into
multitheftauto:masterfrom
Zephkek:fix/fps-limiter-pacing
Open

Zephkek wants to merge 1 commit into
multitheftauto:masterfrom
Zephkek:fix/fps-limiter-pacing

Conversation

@Zephkek

@Zephkek Zephkek commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The frame limiter waited in Present, but GTA measures its frame delta in CTimer::Update. Everything between the two (message pump, input, pre frame pulse) takes a different amount of time every frame, and all of it leaked into the delta GTA saw. CTimer::UpdateVariables adds floor(delta_ms) to the game clock, so at 240 FPS the 4.17 ms frames turned into a random mix of 4 and 5 ms ticks. That is the aim jitter, and it is why 144 with VSync looked fine while 240 did not.

The wait now runs in CCore::OnGameTimerUpdate, right before the clock is sampled, which is exactly where 1.6 waited. Present only paces frames the game timer never ticked for (minimized, loading). The waitable timer is created high resolution where Windows supports it, and the spin margin may grow to 2 ms when the timer keeps waking up late instead of being capped below what it actually needs.

Unlimited FPS has no pacing at all, so any jitter there is the game running above 300 FPS and is outside the limiter.

Fixes #5335

Test plan

Cap at 240 on a machine that reaches it, aim with a weapon and strafe. Repeat at 120 and 144. Frame times in the frame graph stay flat and the camera stays smooth. Minimize and restore, alt-tab, join and disconnect, the limiter keeps working through all of it.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

…mits

The limiter waited in Present while GTA measures its frame delta in
CTimer::Update, so everything between the two leaked into the delta
and the game clock, which only adds whole milliseconds per frame,
became an uneven mix of ticks. The wait now runs right before GTA
samples its clock, where 1.6 waited. Present only paces frames the
game timer never saw. The waitable timer is high resolution where
available and the spin margin may grow to 2 ms when the timer keeps
waking up late.
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.

Aiming camera jitter at 240 or unlimited FPS but smooth at 144 FPS

1 participant