-
I have set ctx.request_repaint_after_for(Duration::from_secs(5), ctx.viewport_id()); in my code so that it updates once every 5 seconds when the mouse is not over the canvas. However, when the mouse moves over the canvas, the FPS significantly increases, which causes me a lot of trouble. How can I configure it to ensure the FPS is not affected by the mouse's movement? egui: 0.28 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can't, at least not with eframe. The app always repaints on user interaction. The Generally you should assume that your UI code will be run at 60fps, because it will be whenever the user is interacting or an animation is in progress. If the problem is that the code is too expensive to run that often, you have to cache the results between frames. Egui provides the cache module to help with that. You can also use the time field obtainable via the input to determine when to refresh things. |
Beta Was this translation helpful? Give feedback.
You can't, at least not with eframe. The app always repaints on user interaction. The
request_repaint
methods are just to ensure it keeps updating when the user isn't doing anything, if the UI might change for some other reason. There is #4880 which aims to skip the repaint if the hovered widget isn't interactive, but it hasn't been reviewed yet.Generally you should assume that your UI code will be run at 60fps, because it will be whenever the user is interacting or an animation is in progress. If the problem is that the code is too expensive to run that often, you have to cache the results between frames. Egui provides the cache module to help with that. You can also use the time field …