slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 601 forks source link

Application aborts when running on WSL2 #4089

Closed araraloren closed 3 months ago

araraloren commented 11 months ago

Platform: WSL2 Fedora release 39 (Thirty Nine) Slint: 1.3.2

Io error: Broken pipe (os error 32)
thread 'Io error: smithay-clipboard' panicked at /home/xxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:98Broken pipe: (os error 4732:
)called `Result::unwrap()` on an `Err` value: OtherError(IoError(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }))

stack backtrace:
Io error: Broken pipe (os error 32)
   0: rust_begin_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1652:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1077:23
   4: smithay_clipboard::worker::worker_impl
             at /home/xxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:98:9
   5: smithay_clipboard::worker::spawn::{{closure}}
             at /home/xxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:23:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Error: Other("Error running winit event loop: Exit Failure: 1")

 *  The terminal process "cargo 'run', '--package', 'slint-demo', '--bin', 'slint-demo'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.
fn main() -> Result<(), Box<dyn std::error::Error>> {
    MainWindow::new()?.run()?;
    Ok(())
}

slint::slint! {
    export component MainWindow inherits Window {
        Text {
            text: "Hello World!";
            color: red;
        }
    }
}

Running with cargo run, with default feature.

hunger commented 11 months ago

What where you doing when this panic triggered?

Is that right after the start or were you actually copying something from the window or pasting something into the window when this triggered?

araraloren commented 11 months ago

@hunger Nothing. I try to debug it, I can see the window is display. But then it is crashed.

hunger commented 11 months ago

So no user interaction (besides maybe the mouse moving). Strange.

My first suspicion without having looked into this much would of course be a problem in the smithay-clipboard crate, but of course we might just be using it wrong:-)

You could try using the Qt backend for slint (installing Qt6 into the WSL changeroot before building slint should suffice). That has very different code paths from the winit-based code we use elsewhere. That might at least get you around this problem so that you are not blocked on it.

araraloren commented 11 months ago

Okay, I will try.

araraloren commented 11 months ago

@hunger It is working with dependence configuration slint = { version = "1.3", features = ["std", "backend-qt", "compat-1-2"], default-features = false}.

ogoffart commented 11 months ago

As @hunger said, the panic is inside the smithay-clipboard crate which is used indirectly by our winit backend via the copypasta crate to get the clipboard on Wayland.

So IMHO this is a bug in smithay-clipboard and it should be reported there.

tronical commented 11 months ago

The error message suggests that the peer that provides clipboard-data is not alive anymore (so the FD transfer fails). That's a little weird though. @araraloren did you do anything with your clipboard before launching? What happens if you select text in say a web browser or terminal, copy it into the clipboard, and then start the app?

microhobby commented 10 months ago

@tronical I have something similar:

Io error: Connection reset by peer (os error 104)
thread 'smithay-clipboard' panicked at /home/castello/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:98:47:
called `Result::unwrap()` on an `Err` value: OtherError(IoError(Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" }))
stack backtrace:
Io error: Connection reset by peer (os error 104)
Io error: Connection reset by peer (os error 104)
   0:     0x7fac1ae12b7c - std::backtrace_rs::backtrace::libunwind::trace::he43a6a3949163f8c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fac1ae12b7c - std::backtrace_rs::backtrace::trace_unsynchronized::h50db52ca99f692e7
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fac1ae12b7c - std::sys_common::backtrace::_print_fmt::hd37d595f2ceb2d3c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fac1ae12b7c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h678bbcf9da6d7d75
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fac1ae4118c - core::fmt::rt::Argument::fmt::h3a159adc080a6fc9
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/rt.rs:138:9
   5:     0x7fac1ae4118c - core::fmt::write::hb8eaf5a8e45a738e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fac1ae0ecfe - std::io::Write::write_fmt::h9663fe36b2ee08f9
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/io/mod.rs:1714:15
   7:     0x7fac1ae12964 - std::sys_common::backtrace::_print::hcd4834796ee88ad2
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fac1ae12964 - std::sys_common::backtrace::print::h1360e9450e4f922a
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fac1ae14253 - std::panicking::default_hook::{{closure}}::h2609fa95cd5ab1f4
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:270:22
  10:     0x7fac1ae13f6c - std::panicking::default_hook::h6d75f5747cab6e8d
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:290:9
  11:     0x7fac1ae147d9 - std::panicking::rust_panic_with_hook::h57e78470c47c84de
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:707:13
  12:     0x7fac1ae146d7 - std::panicking::begin_panic_handler::{{closure}}::h3dfd2453cf356ecb
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:599:13
  13:     0x7fac1ae130a6 - std::sys_common::backtrace::__rust_end_short_backtrace::hdb177d43678e4d7e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x7fac1ae14422 - rust_begin_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
  15:     0x7fac19414793 - core::panicking::panic_fmt::hd1e971d8d7c78e0e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
  16:     0x7fac19414c8a - core::result::unwrap_failed::hccb456d39e9c31fc
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1652:5
  17:     0x7fac1a5f3432 - core::result::Result<T,E>::unwrap::h8159f6ca1f0376ad
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1077:23
  18:     0x7fac1a614e78 - smithay_clipboard::worker::worker_impl::h2ca189306439a074
                               at /home/castello/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:98:9
  19:     0x7fac1a6148c0 - smithay_clipboard::worker::spawn::{{closure}}::hbb76fd90cda3a3ff
                               at /home/castello/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-clipboard-0.7.0/src/worker.rs:23:13
  20:     0x7fac1a618886 - std::sys_common::backtrace::__rust_begin_short_backtrace::h16a1cb9361532cf4
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:154:18
  21:     0x7fac1a6456fd - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h75f14234e0e14b82
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/thread/mod.rs:529:17
  22:     0x7fac1a638011 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hebf7580d20050366
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panic/unwind_safe.rs:271:9
  23:     0x7fac1a61098b - std::panicking::try::do_call::ha1157924e2446d25
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
  24:     0x7fac1a6153db - __rust_try
  25:     0x7fac1a6107a2 - std::panicking::try::h769676fcd3cdceb3
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
  26:     0x7fac1a645541 - std::panic::catch_unwind::hc2869124ab9a9e67
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
  27:     0x7fac1a645541 - std::thread::Builder::spawn_unchecked_::{{closure}}::h6288bc9da2ebfdb6
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/thread/mod.rs:528:30
  28:     0x7fac1a5fdacf - core::ops::function::FnOnce::call_once{{vtable.shim}}::hdff27d5c412e8047
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:250:5
  29:     0x7fac1ae19535 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haadd4e5af2ab0d62
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/alloc/src/boxed.rs:2007:9
  30:     0x7fac1ae19535 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he4ba1fb09c16d807
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/alloc/src/boxed.rs:2007:9
  31:     0x7fac1ae19535 - std::sys::unix::thread::Thread::new::thread_start::he524ecf4b47bee95
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys/unix/thread.rs:108:17
  32:     0x7fac9b7eab43 - start_thread
                               at ./nptl/pthread_create.c:442:8
  33:     0x7fac9b87ca00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  34:                0x0 - <unknown>
thread '<unnamed>' panicked at src/lib.rs:546:26:
called `Result::unwrap()` on an `Err` value: Other("Error running winit event loop: Exit Failure: 1")
stack backtrace:
   0:     0x7fac1ae12b7c - std::backtrace_rs::backtrace::libunwind::trace::he43a6a3949163f8c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fac1ae12b7c - std::backtrace_rs::backtrace::trace_unsynchronized::h50db52ca99f692e7
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fac1ae12b7c - std::sys_common::backtrace::_print_fmt::hd37d595f2ceb2d3c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fac1ae12b7c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h678bbcf9da6d7d75
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fac1ae4118c - core::fmt::rt::Argument::fmt::h3a159adc080a6fc9
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/rt.rs:138:9
   5:     0x7fac1ae4118c - core::fmt::write::hb8eaf5a8e45a738e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fac1ae0ecfe - std::io::Write::write_fmt::h9663fe36b2ee08f9
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/io/mod.rs:1714:15
   7:     0x7fac1ae12964 - std::sys_common::backtrace::_print::hcd4834796ee88ad2
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fac1ae12964 - std::sys_common::backtrace::print::h1360e9450e4f922a
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fac1ae14253 - std::panicking::default_hook::{{closure}}::h2609fa95cd5ab1f4
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:270:22
  10:     0x7fac1ae13f6c - std::panicking::default_hook::h6d75f5747cab6e8d
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:290:9
  11:     0x7fac1ae147d9 - std::panicking::rust_panic_with_hook::h57e78470c47c84de
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:707:13
  12:     0x7fac1ae146d7 - std::panicking::begin_panic_handler::{{closure}}::h3dfd2453cf356ecb
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:599:13
  13:     0x7fac1ae130a6 - std::sys_common::backtrace::__rust_end_short_backtrace::hdb177d43678e4d7e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x7fac1ae14422 - rust_begin_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
  15:     0x7fac19414793 - core::panicking::panic_fmt::hd1e971d8d7c78e0e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
  16:     0x7fac19414c8a - core::result::unwrap_failed::hccb456d39e9c31fc
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1652:5
  17:     0x7fac1a805931 - core::result::Result<T,E>::unwrap::hfeb072dd70924711
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1077:23
  18:     0x7fac1945ff78 - slint_dotnet::rnet_export_run::inner::{{closure}}::h1a20187d20a525ea
                               at /home/castello/projects/D/slint-dotnet/src/lib.rs:546:9
  19:     0x7fac19462210 - std::thread::local::LocalKey<T>::try_with::h1a75201c014473e6
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/thread/local.rs:270:16
  20:     0x7fac194620ee - std::thread::local::LocalKey<T>::with::hfacaf4bd98b4a657
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/thread/local.rs:246:9
  21:     0x7fac1942c806 - slint_dotnet::rnet_export_run::inner::hfdf3cc9d37abdcad
                               at /home/castello/projects/D/slint-dotnet/src/lib.rs:537:5
  22:     0x7fac1942c7e6 - rnet_export_run
                               at /home/castello/projects/D/slint-dotnet/src/lib.rs:533:1
  23:     0x7fac1cdf6937 - <unknown>
fatal runtime error: failed to initiate panic, error 5
The program '[7375] test.dll' has exited with code 0 (0x0).

Even having stuff on the clipboard the error occurs.

araraloren commented 10 months ago

The error message suggests that the peer that provides clipboard-data is not alive anymore (so the FD transfer fails). That's a little weird though. @araraloren did you do anything with your clipboard before launching? What happens if you select text in say a web browser or terminal, copy it into the clipboard, and then start the app?

Yes, it's working if I clean the clipboard from clipboard settings of Windows.

microhobby commented 10 months ago

The error message suggests that the peer that provides clipboard-data is not alive anymore (so the FD transfer fails). That's a little weird though. @araraloren did you do anything with your clipboard before launching? What happens if you select text in say a web browser or terminal, copy it into the clipboard, and then start the app?

Yes, it's working if I clean the clipboard from clipboard settings of Windows.

interesting, for me this does not work. Could you please share the Windows and WSL 2 version?

araraloren commented 10 months ago

@microhobby Here is the output of wsl --version(Fedora release 39 (Thirty Nine)):

WSL version: 2.0.9.0
Core version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3803
ogoffart commented 9 months ago

Upstream bug: https://github.com/Smithay/smithay-clipboard/issues/52

ogoffart commented 9 months ago

Closing as this is a bug upstream and we can't do anything in Slint

tronical commented 8 months ago

So this turned out not to be a bug in smithay-clipboard. It just happened to panic, but the root symptom is that the Wayland connection breaks off. Afaics Weston crashes. Have yet to find out why.

microhobby commented 8 months ago

hey @tronical, so this https://github.com/Smithay/smithay-clipboard/pull/54 will not fix from the Slint side?

tronical commented 8 months ago

That's correct. It allows for better error propagation, but what's crashing is Weston. I haven't figured out yet why. Perhaps I can file a ticket with wslg - Weston should not crash. The clipboard is a red herring.

As to workaround: I don't know any yet :(.

microhobby commented 8 months ago

I think that I figure out a workaround:

WAYLAND_DISPLAY= slint_app

Unsetting the WAYLAND_DISPLAY appears to fix the panic. The point against it is that it will use the X11 as a fallback.

tronical commented 3 months ago

This is worked around now with https://github.com/slint-ui/slint/issues/5657 until we have https://github.com/slint-ui/slint/issues/5667 in place.