Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can instruct egui to discard a frame. That way you can perform this two phase layout across two frames without showing an unfinished UI.

This mechanism can get you there most of the time.



Take the Code Example demo initially opened: drag age up to 120, then press the Increment button, and watch the label “Arthur is 120” briefly blip to “Arthur is 121” (while the DragValue still shows 120!) before being dragged back down to 120 presumably by rerendering and egui::DragValue::new(age).range(0..=120) clamping it.

That’s… eww. It probably doesn’t often cause real problems—though it surely could, as it’s allowing temporary rendering with out-of-bounds values that a developer might have expected to be clamped—but it’s still very eww, the idea that mutating data leads to parts of a frame being rendered with different data.


I’m currently on mobile, where I couldn’t reproduce this.

I agree, that shouldn’t happen and it might be a bug, because the input is handled after drawing the initial frame and should be clamped before starting to draw the next frame. Drag events are tricky though, because they come with a frame delay by default (you have to recognize the drag).

Does this reproduce reliably on desktop? If so then I can create an issue for this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: