Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[bug] [macOS] verticalSync problem since macOS13 (GLFW-inherited issue) #7760

Open
artificiel opened this issue Nov 19, 2023 · 5 comments
Open

Comments

@artificiel
Copy link
Contributor

artificiel commented Nov 19, 2023

macOS13 introduces jitter in the timing of update/draw cycle of GLFW apps glfw/glfw#2249. it has (at least) 2 concrete negative effects in OF as demontrated in #7752 (comment)

  • sometimes the jitter pushes the draw() later than the actual frame cycle, stuttering/dropping a frame

  • ofGetElapsedTimef() is not reliable to control phase-based animations requiring isochronous steps

until it is fixed within GLFW (seems hard) — or at OF-level by working around the Timer (as inspiration see the google deepmind workaround) , or by implementing a metal backend, or other — ofSetVerticalSync(false) and using ofSetFrameRate(nnn) is recommended. using macOS14 game mode in fullscreen also helps as seen in #7752 (comment).

the uneven timing issue can be worked around by using something like ofGetExpectedPaintTimef(), but that will not prevent dropped frames.

this issue will be updated as the GLFW and OF evolution affects the behaviour.

@artificiel artificiel changed the title [macOS][bug] verticalSync problem since macOS13 (GLWF-inherited issue) [bug] [macOS] verticalSync problem since macOS13 (GLFW-inherited issue) Nov 19, 2023
@danomatika
Copy link
Contributor

danomatika commented Nov 20, 2023

Does this issue happen with both ofSetVerticalSync(true) and ofSetFrameRate(60)? I don't quite remember why, but I feel like there was an issue with vsync only and I added setting the frame rate as well.

@artificiel
Copy link
Contributor Author

yes, adding the framerate is better top the point of things being mostly unnoticeable, if the CPU load is low and if you don't relay of ofGetElapsedTimef()

timing with vsync, frameRate(60), OF fullscreen:
image

timing without vsync, frameRate(60), OF fullscreen:
image

and to give good measure of what is achievable, timing native fullscreen with game mode and no vsync:
image

(more can be found here)

@dimitre
Copy link
Member

dimitre commented Jan 18, 2024

I think ofSetFrameRate should be redesigned out of ofTimer.
Or maybe an alternative ofTimer using std::chrono exclusively.
I've made some experiments in measuring here:

and some insights from Glenn Fiedler about fps https://gafferongames.com/post/fix_your_timestep/

@dimitre
Copy link
Member

dimitre commented May 13, 2024

Framerate drift is merged and it is much more precise now.
VSync is doable now outside GLFW if we use a similar solution to this one:
google-deepmind/mujoco@2f0fb1e
It seems ok because OF project is already including CoreVideo framework

@danomatika
Copy link
Contributor

Thanks for the work on this, all!

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

No branches or pull requests

3 participants