4 ms·
Egui keeps getting better and better! For those unfamiliar you can run the web demo on your phone or desktop: https://egui.rs https://egui.rs I’ve personally b
by juancampa 4y ago
Egui keeps getting better and better! For those unfamiliar you can run the web demo on your phone or desktop: https://egui.rs https://egui.rs
I’ve personally built relatively complex UIs with egui. Both a Chrome extension and a VSCode extension for https://membrane.io https://membrane.io and couldn’t be happier with it.
- mwcampbell 4y agoDo note that this AccessKit integration doesn't yet help with the web backend of egui, only the winit-based backend on Windows and macOS. A web platform adapter for AccessKit is planned, but not a top priority.
- juancampa 4y agoGood to know. Thanks for clarifying!
- chrismorgan 4y agoegui’s web implementation is purely canvas with no DOM (apart from how it handles text input), so for now it’s completely invisible to screen readers. But even once AccessKit supports the web (and even pretending it wouldn’t be a performance sink that undermines half of the purpose of the canvas rendering approach in web apps), it will still be heavily inferior to something done with DOM for almost all types of content. Some examples: text rendering is awful on some common browser configurations (mine included—Firefox on Linux/Wayland, rendered at 2× scaling and downsampled to 1.5×; the text is extraordinarily fuzzy, and it’s rendering in its own font because I suppose it’s bundling a complete font, shaper and renderer—since I force my own font selections so only the generic font-families work, and I also block all web fonts at fetch time); the font rendering technique means no fallback which means things like emoji would only render if they provided a font that supported that (at present they don’t, and it’s just a nasty technique all round, you want to be able to use local fonts); links are fake, so various interactions can never work correctly (e.g. Ctrl+click and middle-click should mostly open a background tab, and right-clicking should give you the normal context menu); scrolling can’t be done properly and will thus inevitably be extremely obnoxious on most devices; mobile-style pinch zoom cannot be supported. ⸻And I’m just mentioning some of the unfixable problems with this approach; there are more things that are wonky or painful apart from that: things that could be fixed, but where it’s not surprising that they’re broken because that’s a common problem when you throw away almost all of the stuff the platform gives you and try to implement it all from scratch. I very strongly recommend against using this general approach at all on the web. The web platform just doesn’t provide the primitives required to make it anything other than miserable. (I’m not speaking against egui for platforms other than web, only for web. The fact of the matter is that functionally you’re fine building a native app with native tech, a native app with web tech, or a web app with web tech, but that building a web app with native tech is a terrible idea that will always be inferior, in important, unfixable ways.)
- dnsco 4y agoFor native, it's pretty awesome, and it's nice that you can get a hint of what it can do by checking out the web demo.
- chrismorgan 4y agoI agree. I just wish that it was paired with a banner along the lines of “this demo works on the web, but egui is focused on other platforms and you probably shouldn’t use it for the web” paired with a link to an article detailing the problems and how unsuitable it is.
- juancampa 4y agoOn the other hand you have Figma and Google Docs as examples of canvas-based applications that work well enough. I admit there are additional challenges to using egui on a Web context, but when you're building a highly interactive application (!), the benefits can outweigh the drawbacks. When building DOM-based applications that require frequent updates I've always ended up working around browser limitations in awkward ways, e.g. minimizing re-rendering by using redux's relesect. I decided to use egui because I get to use Rust for the entire stack, but also because it lets me ship a native app without an entire (slow to init) browser.
- chrismorgan 4y agoI can’t speak about Figma, never having used it. Google Docs I have just now tried. It isn’t like egui. egui throws away everything the browser gives it, other than a text input element and a canvas element, and does all the rendering itself and dumps it to the canvas as a bitmap. Google Docs is full DOM for everything other than rendering the document, and it still uses the browser’s text layout and painting facilities. (I say this because I have my browser set to only use my chosen fonts—so for English text, there are only the default font, serif, sans-serif and monospace—and I observe that it renders and shapes everything in my chosen default font, and am mildly disappointed it doesn’t even do a sane fallback, e.g. “Courier New” to monospace, and “Sans Serif” to sans-serif.) Almost all of my criticisms of the egui approach are avoided. Scrolling works fine, because it’s using the DOM for that, so it’s just normal scrolling. Links work fine, because it uses normal links (these are in tooltip-like things when you move the cursor to the link in the normal text flow). (I retract my remark about mobile-style pinch zoom not being possible in canvas-only, because Google Docs does support it. I can now imagine how it’s done and I’m not sure why I didn’t see it before.) But I would also remark about Google Docs since I’ve now tried it in edit mode for the first time since canvas rendering: ugh it’s slow. Low throughput, high latency, high jitter. This on a very fast (Ryzen 5800HS), near-idling laptop with a 165 Hz screen and 2× devicePixelRatio. Just try holding a letter down (I have a 40ms repeat rate), and compare the result to the same actions on contenteditable: the difference is stark. It also gets keyboard caret navigation behaviour wrong for my platform (Linux, Firefox), and its behaviour doesn’t match my vague recollection of Windows’ either. (I mean things like where Ctrl+Left and Ctrl+Right stop—whether at the end of one word or the start of the next, and whether to consider punctuation as part of another word or a word on its own; that kind of thing.)
- the__alchemist 4y agoI was also surprised to learn how nice EGUI is. Big widget kit, clean API (Which is often not true for Rust dependencies!) and integrates into WGPU-rendering. It allows me to use Rust to make Desktop applications. I'm concerned about the performance hit of an immediate-mode GUI when not tieing it into a 3D render (ie the CPU access from repeatedly re-drawing), but haven't compared.
- juancampa 4y agoIn my experience it's surprisingly fast. Egui doesn't need to redraw when it's idling, only when you're interacting with it (mouse move) or it's animating something so IMO it's not a big deal. I have to admit that I've only tested it on high-end laptops/phones though. Not sure about mid/low-end ones yet.
- Narishma 4y agoIt seems to cause high CPU usage whenever you move the mouse in the web demo.
- juancampa 4y agoThat's because egui uses an "immediate mode" approach: it's rendering everything from scratch every time something _might_ have changed (e.g. a mouse move could've trigged a hover effect). Whereas the DOM uses "retained mode": it continually modifies a representation of the layout (DOM elements) and re-renders when something _actually_ changes. You can click on the "Backend" button at the top, and "Mean CPU usage" will tell you how long it takes for each frame to be produced. It'll vary depending on how complex the layout is: e.g. how many windows are open. But, contrary to retained mode, it doesn't matter at all if everything is animating simultaneously. More about immediate vs. retained: https://github.com/emilk/egui#why-immediate-mode https://github.com/emilk/egui#why-immediate-mode