Makie.jl
Makie.jl copied to clipboard
Improve accuracy of set framerate in GLMakie
Description
When targeting a framerate GLMakie uses sleep()
which is pretty bad at its job:
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:
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.
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.