egui icon indicating copy to clipboard operation
egui copied to clipboard

eframe use egui-winit for both native and web

Open luiswirth opened this issue 3 years ago • 2 comments

I believe that eframe should use egui-winit for both native and web. eframe should in my opinion be like my old crate eww (egui + winit + wgpu) (doesn't has to be wgpu). Meaning that eframe is only a wrapper around a platform crate (winit) and a renderer crate (wgpu, glium or glow).

This would streamline the egui ecosystem a lot I believe. Currently the step from eframe to a custom integration is still quite big. This would hopefully make this process a lot easier. This could probably also avoid code duplication in eframe as you wouldn't have to handle wasm support separately as winit would do it for you.

As mentioned in discord I got my own egui + winit + wgpu integration running on wasm. I know it's way to early to now make the switch to only using winit. But I think this goal is worth pursuing. I'll first provide an example like you @emilk asked on discord for #1755.

luiswirth avatar Sep 07 '22 11:09 luiswirth

I agree that this is something worth investigating, but before we do we must first get egui-winit to work on web (https://github.com/emilk/egui/issues/1032). Once we have egui-winit working on web (with a working example in the egui repository) we can evaluate whether or not we should switch to it for eframe. You mention a lot of upsides (all of which I agree with), but there are some potential downsides:

A) more reliance on winit, making it more difficult to try out alternatives (like https://github.com/tauri-apps/tao) B) an extra layer (more overhead, more compilation time, with its own quirks, more difficult for us to fix, etc, etc)

emilk avatar Sep 07 '22 12:09 emilk

I agree with everything you said.

luiswirth avatar Sep 07 '22 12:09 luiswirth

As mentioned on discord, I got my application called carveout, which uses a custom egui + wgpu + winit integration, running on the web using wasm. You can check out a live web demo on https://lwirth.com/. It's a digital pen note taking application.

@coderedart also managed to create a running egui + wgpu + winit setup using his egui toolkit etk. Check out their live web demo https://coderedart.github.io/etk/!

In my setup I noticed some things aren't working right now:

  • There is a scaling issue with the cursor position in my UI. For the drawing canvas I directly process winit events which works perfectly fine but the egui cursor pos is wrong for some reason. This doesn't happen with etk.
  • Multi-Touch doesn't work
  • On chrome mobile the website is just blank.

I haven't investigated these problems so far.

luiswirth avatar Sep 22 '22 13:09 luiswirth

What's the latest on this issue? My app Hyperspeedcube uses egui+winit+wgpu and works very well, with the only issues I notice being:

  • copy/paste doesn't work on some browsers, such as Firefox (could probably be worked around using JS hooks but I'm not particularly knowledgeable there)
  • I have not implemented automatic dark/light theme detection

It even gets scancodes + virtual keycodes for key input! My app uses both depending on the context.

HactarCE avatar Mar 10 '24 03:03 HactarCE