Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland support #7

Open
adsick opened this issue Sep 20, 2022 · 5 comments
Open

wayland support #7

adsick opened this issue Sep 20, 2022 · 5 comments

Comments

@adsick
Copy link

adsick commented Sep 20, 2022

when you try to open egui window in demo example on Fedora 36 (uses wayland) you get this:

main Resized(PhysicalSize { width: 655, height: 405 })
main Moved(PhysicalPosition { x: 0, y: 0 })
main Resized(PhysicalSize { width: 654, height: 409 })
main Moved(PhysicalPosition { x: 0, y: 0 })
main Resized(PhysicalSize { width: 654, height: 409 })
main Moved(PhysicalPosition { x: 0, y: 0 })
main Resized(PhysicalSize { width: 654, height: 409 })
main Focused(true)
thread 'main' panicked at 'glutin was not compiled with support for this display server', /home/adsick/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/mod.rs:126:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /home/adsick/rust/tauri-egui/src/plugin.rs:179:19

I tried to fix this by modifying Cargo.toml like so:
image
but no luck, it then gives a compilation error:
image

@Beanow
Copy link
Member

Beanow commented Sep 26, 2022

So on my Manjaro (Wayland Gnome) dev machine I can't reproduce this.
I'll give a fresh Fedora VM a try but so far it worked as-is.
image

@Beanow
Copy link
Member

Beanow commented Sep 26, 2022

Indeed a fresh fedora environment does have this problem.

$ RUST_BACKTRACE=1 cargo run --example demo
   Compiling tauri-egui v0.1.0 (/home/beanow/Downloads/tauri-egui)
    Finished dev [unoptimized + debuginfo] target(s) in 12.03s
     Running `target/debug/examples/demo`
main Moved(PhysicalPosition { x: 0, y: 0 })
main Resized(PhysicalSize { width: 452, height: 489 })
main Moved(PhysicalPosition { x: 0, y: 0 })
main Resized(PhysicalSize { width: 452, height: 489 })
main Focused(true)
thread 'main' panicked at 'glutin was not compiled with support for this display server', /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/mod.rs:126:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: glutin::platform_impl::platform::Context::new_windowed
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/mod.rs:126:9
   3: glutin::windowed::<impl glutin::ContextBuilder<T>>::build_windowed
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/windowed.rs:319:9
   4: tauri_egui::plugin::create_gl_window
             at ./src/plugin.rs:346:5
   5: <tauri_egui::plugin::EguiPlugin<T> as tauri_runtime_wry::Plugin<T>>::on_event
             at ./src/plugin.rs:201:17
   6: <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::run::{{closure}}
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-runtime-wry-0.11.1/src/lib.rs:2053:31
   7: tao::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.14.0/src/platform_impl/linux/event_loop.rs:952:19
   8: glib::main_context::<impl glib::auto::main_context::MainContext>::with_thread_default
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.12/src/main_context.rs:156:12
   9: tao::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.14.0/src/platform_impl/linux/event_loop.rs:932:5
  10: tao::platform_impl::platform::event_loop::EventLoop<T>::run
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.14.0/src/platform_impl/linux/event_loop.rs:888:21
  11: tao::event_loop::EventLoop<T>::run
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.14.0/src/event_loop.rs:179:5
  12: <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::run
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-runtime-wry-0.11.1/src/lib.rs:2051:5
  13: tauri::app::App<R>::run
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.1.1/src/app.rs:777:5
  14: demo::main
             at ./examples/demo/main.rs:37:3
  15: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /home/beanow/Downloads/tauri-egui/src/plugin.rs:179:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1814:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1107:23
   4: tauri_egui::plugin::EguiPluginHandle<T>::create_window::{{closure}}
             at ./src/plugin.rs:179:9
   5: tauri_runtime_wry::Context<T>::run_threaded
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-runtime-wry-0.11.1/src/lib.rs:202:5
   6: tauri_egui::plugin::EguiPluginHandle<T>::create_window
             at ./src/plugin.rs:149:5
   7: demo::open_native_window::{{closure}}
             at ./examples/demo/main.rs:24:17
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
   9: <F as futures_core::future::TryFuture>::try_poll
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.24/src/future.rs:82:9
  10: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/future/try_future/into_future.rs:34:9
  11: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/future/future/map.rs:55:37
  12: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/lib.rs:91:13
[beanow@fedora tauri-egui]$ 

@Beanow
Copy link
Member

Beanow commented Sep 26, 2022

So @adsick was on the right track here.
By default the glutin_tao replacement for glutin has the wayland feature disabled. However adding it won't compile.
Because glutin_tao is trying to use extension methods defined by winit but not available in tao.

  Compiling glutin_tao v0.30.0
error[E0599]: no method named `wayland_display` found for reference `&EventLoopWindowTarget<T>` in the current scope
  --> /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/wayland.rs:56:30
   |
56 |         let display_ptr = el.wayland_display().unwrap() as *const _;
   |                              ^^^^^^^^^^^^^^^ method not found in `&EventLoopWindowTarget<T>`

error[E0599]: no method named `wayland_display` found for struct `Window` in the current scope
  --> /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/wayland.rs:96:31
   |
96 |         let display_ptr = win.wayland_display().unwrap() as *const _;
   |                               ^^^^^^^^^^^^^^^ method not found in `Window`

error[E0599]: no method named `wayland_surface` found for struct `Window` in the current scope
  --> /home/beanow/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin_tao-0.30.0/src/platform_impl/unix/wayland.rs:97:27
   |
97 |         let surface = win.wayland_surface();
   |                           ^^^^^^^^^^^^^^^ method not found in `Window`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `glutin_tao` due to 3 previous errors

These exist here:
https://github.com/rust-windowing/winit/blob/fafdedfb7d3a7370ca4b01108f7713b685633164/src/platform/wayland.rs#L29

But not here:
https://github.com/tauri-apps/tao/blob/65f768e55fb1eb53642246c63194ef75e84f908a/src/platform/unix.rs#L148


I believe why my Manjaro environment didn't have this issue was because it wound up using XWayland, rather than native Wayland windows. You can force XWayland to be used by running, (and not compiling with the wayland feature for glutin_tao) :

GDK_BACKEND=x11 cargo run --example demo

@Beanow
Copy link
Member

Beanow commented Sep 26, 2022

@wusyong @lucasfernog, this is probably a bug for https://github.com/tauri-apps/glutin.
Because that's switched over to tao but is using APIs that don't exist. Probably it should be updated to not attempt compiling or using native Wayland until tao actually offers it.

@wusyong
Copy link
Member

wusyong commented Sep 27, 2022

Sorry I'm on vacation at the moment so I may be slow to response.
In short, we do not support wayland for now.
To add the support, we need to modify our glutin fork further but glutin has more difficult to add this kind of support.
I would like to support wgpu in the future since it only requires a raw handle.
And since we are switching back to winit, I would like to make all the changes at once so we don't need to do duplicate works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants