Makie.jl icon indicating copy to clipboard operation
Makie.jl copied to clipboard

Improve accuracy of set framerate in GLMakie

Open ffreyer opened this issue 8 months ago • 3 comments

Description

When targeting a framerate GLMakie uses sleep() which is pretty bad at its job: Screenshot 2024-06-08 154030

And thus the frametimes are pretty off. For the default 30fps GLMakie targets we should have 1/30 = 0.033s delay between frames but I get around 0.045: Screenshot 2024-06-10 220324

This pr adds some bookkeeping for the used time per frame. If one frame sleeps for too long the next frame will know about it and sleep for less time. This averages out the frametimes to match the requested framerate.

Screenshot 2024-06-11 214118

An alternative option would be have a while (current_time < frametime) yield() which would be better for stability but I assume would be worse for power usage.

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)

Checklist

  • [x] Added an entry in CHANGELOG.md (for new features and breaking changes)
  • [ ] Added or changed relevant sections in the documentation
  • [x] Added unit tests for new algorithms, conversion methods, etc.
  • [ ] Added reference image tests for new plotting functions, recipes, visual options, etc.

ffreyer avatar Jun 11 '24 19:06 ffreyer