Feature to get target refresh rate
Is your feature request related to a problem? Please describe.
Hi, I'm developing an emulator that uses egui for its front end. I'm currently experiencing an issue where I need to synchronise emulation with when egui repaints the screen. Currently, I'm utilizing the request_repaint function, but it's proving quite a struggle to work without knowing the framerate this function is targeting.
Describe the solution you'd like
A way to know the refresh rate/frame rate egui/eframe targets when using request_repaint (or even without it, say if the user was just moving their cursor around or doing something that would require a repaint)
Describe alternatives you've considered I've tried implementing a similar method as showcased egui.rs, where on the backend tab, if you set the Mode to Continuous, it will calculate the FPS. However, this value is not entirely accurate because if the window loses focus (either via minimizing or switching tabs), it stops painting and ruins the average time between each frame.
Additional context
Try calling request_repaint() every time in update().
And try to solve other problem.
(Repaint does not work in the minimized state. - There seems to be no reason to measure invisible FPS.)
Try calling
request_repaint()every time inupdate()
That's what I've been doing, and as you say, it does not work in the minimized state. Because of this, it's impossible to use the time between frames to calculate the FPS (as done in the demo), and as far as I can see, there's also no way to see if repainting has been paused, so I believe a feature that simply allows developers to get the refresh rate egui is targeting would be beneficial.
Try calling
request_repaint()every time inupdate()That's what I've been doing, and as you say, it does not work in the minimized state. Because of this, it's impossible to use the time between frames to calculate the FPS (as done in the demo), and as far as I can see, there's also no way to see if repainting has been paused, so I believe a feature that simply allows developers to get the refresh rate egui is targeting would be beneficial.
See FPS handling in egui_demo_app.
There is also a way to handle this by checking the ‘minimized’ status.
See FPS handling in egui_demo_app.
As I said, the demo has the same problem. The way FPS handling is done in the demo has this flaw.
Additionally, the minimized status does not work in WASM and, therefore, cannot be used to solve my problem.