logoalt Hacker News

mort96yesterday at 9:56 AM6 repliesview on HN

Doesn't egui always re-render? I like my idle apps to be doing nothing, I don't want them running their render loop in the background


Replies

the__alchemistyesterday at 12:25 PM

I think the default behavior is to only re-render if the window is active/focused. You can trigger a render at specific points, including in the main loop, which will result in the behavior you mention.

This can be problematic, e.g. some of the sensor interfaces I have, I want to always display correct data, even if not focused. So, I have to decide if I want to have old data shown in the background misleading users, or have a per penalty from constant renders. Or try something else to be clever. (Maybe have it update at a low rate if not focused? I think that's the move...)

show 1 reply
user____nameyesterday at 10:05 AM

Any quarter decent imgui implementation will idle when there's no input or active animations, and the renderer can generate dirty tiles or rects to unnecessary redrawing -- if it matters, gpus are ridiculously overpowered for drawing a bunch of rectangles. Ui logic is usually firmly in the microseconds realm.

show 2 replies
throwawayffffasyesterday at 7:56 PM

You typically set it up so that it does not re-render when it's idle. Or at least not at 60fps.

By the way once upon a time, visual studio code I think it was, was using like 20% cpu when idle just because of the blinking cursor, fun.

WhyNotHugoyesterday at 6:05 PM

I suspect (and hope) you can block the main loop if no events are received. This avoids re-rendering if the UI is not visible and no interaction has happened.

freefrog1234yesterday at 10:18 AM

By default it re-renders on each event. This isn't often on mobile apps, but moving a mouse across a desktop app triggers multiple vents. There is a function call to request a re-render if you want not to wait for an event.

show 1 reply
baqyesterday at 10:00 AM

do you run without a compositor? I get where you're coming from, but 'idle' can mean a lot of different things and redrawing the whole UI at 60hz is not necessarily 'not idle' nowadays.

show 1 reply