Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replace frame limiter #2618

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

Replace frame limiter #2618

wants to merge 5 commits into from

Conversation

theyareonit
Copy link

Fixes #2610 by removing the possibility for long-term desync between the player's FPS cap and their actual framerate.

I'm not 100% sure about the things I mentioned in the comments about GLFW.glfwWaitEventsTimeout and Thread.sleep. I would appreciate some input from anyone who might know more on those subjects.

@theyareonit theyareonit changed the title Replace Frame Limiter Replace frame limiter Jul 29, 2024
@douira
Copy link
Collaborator

douira commented Aug 9, 2024

I've done some tests to observe the behavior of this patch:

reference commit before this patch with targets of 80 and 150. It can reach 80, but not 150:

80 reference
150 reference

this patch with targets 80 an 150:

80 new
150 new

With the patch, it much more accurately holds a frame rate that it can actually produce. However, if it can't produce the frames fast enough, with the patch it will have regularly spaced spikes. I don't know if these spikes are noticeable or impact the experience, but I wanted to point this out.

@theyareonit
Copy link
Author

theyareonit commented Aug 9, 2024

One of the things this patch does is that it fully drops a frame if it can't come on time, to ensure that frames always stay perfectly in sync. This should be fine if your FPS limit is a multiple of your monitor's refresh rate, but it might make the game less smooth if you're running a strange FPS limit (for this reason, a patch that would allow the user to set their FPS limit to any value might help).

But yeah, it might be worth trying other approaches to synchronization. I also experimented with a version that essentially shifts to unlimited FPS whenever you lag to reduce dropped frames, but it just felt bad to play on IMO, probably because most of those extra frames weren't actually doing anything.

@jellysquid3 jellysquid3 added this to the Sodium 0.6.1 milestone Aug 13, 2024
@jellysquid3 jellysquid3 modified the milestones: Sodium 0.6.1, Sodium 0.6.2 Dec 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve frame synchronization
4 participants