Expand description
The desktop event loop: eframe’s winit application plus application-command dispatch that does not wait for a frame (a hidden Wayland window gets none). The desktop event loop.
eframe::run_native runs the app only under winit’s RedrawRequested.
On Wayland winit withholds that event while the surface’s frame callback
is outstanding (winit 0.30 wayland/event_loop/mod.rs, which skips a window
whose callback is Requested, with no timeout), and a compositor sends no
callbacks to a window it is not showing (another workspace, a hidden
scratchpad, a covered window under some compositors). An automation command
queued then waited until the user focused the window: the 2026-10-31
desktop report’s 29 s initial read. eframe’s fallback for invisible windows
does not apply, because Wayland reports neither visibility nor minimisation
(is_visible/is_minimized return None). And once a repaint is
outstanding with no pass run, egui stops calling its repaint callback, so a
later submit did not even wake the loop.
run owns the winit loop instead (eframe::create_native) and wraps
eframe’s handler in DesktopLoop. The automation queue’s waker sends the
loop its own event (never forwarded to eframe), and after every batch of
events the loop runs BrepApp::service_automation on this, the app’s
thread, whenever the queue’s head can be dispatched without a frame. Frames
still drain the queue exactly as before; this path draws nothing.
A command that needs more than app state (input egui must apply, a layout
read, a capture) does not wait for a frame either: the loop runs an egui
pass itself, on demand (run_pass). It is the same pass eframe runs
(raw_input_hook, then logic and ui inside Context::run_ui), on the
window’s last known size and clock, and it is never presented: a capture
asked for in it is drawn into an offscreen texture (crate::offscreen).
Everything else the pass hands back goes where eframe would have put it:
its textures to the shared renderer, its viewport and platform commands
back onto the context for eframe’s next real frame, and a capture’s
Event::Screenshot into the next pass’s input, as eframe delivers one.
The loop also keeps an undrawn window idle. eframe arms
ControlFlow::Poll whenever it requests a redraw (check_redraw_requests)
and disarms it only in the pass that redraw runs, so a redraw the
compositor never delivers leaves the loop polling, a core spinning while
idle. winit wakes the loop itself when a requested redraw is delivered, so
after one polled iteration without a RedrawRequested, the loop waits.
Structs§
- Desktop
Loop - eframe’s winit handler plus the frame-free service step.
- Shell
- eframe’s view of the shared app: every
eframe::Appmethod forwards. - Slot
- The app, shared on the loop thread between eframe (through
Shell) and the loop’s service step. The two never run at once: winit delivers events to one handler, sequentially, on this thread.
Functions§
- on_
demand_ passes - How many passes the loop has run on demand in this process.
- run
- Run the app on a new event loop.
- run_on
- Run the app on
event_loop.wrapsits betweenDesktopLoopand eframe’s handler: the identity in production; a test interposes there to play a compositor that withholds frames. - waker
- A waker that sends the loop its wake event. Safe from any thread; a closed loop ignores it.