emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.17k stars 1.6k forks source link

WSL OS error running simple program "Io error: Broken pipe (os error 32)" "Io error: Connection reset by peer (os error 104)" #4938

Open ravatex opened 2 months ago

ravatex commented 2 months ago

Describe the bug

When I run the example problem from the eframe docs one of the following 2 errors come out (interchangeably):

Actual output:

Io error: Broken pipe (os error 32)
Io error: Broken pipe (os error 32)
Io error: Broken pipe (os error 32)
thread 'main' panicked at src/main.rs:9:7:
called `Result::unwrap()` on an `Err` value: WinitEventLoop(ExitFailure(1))
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1654:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1077:23
   4: eframe_egui_bug::main
             at ./src/main.rs:5:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

or

Io error: Connection reset by peer (os error 104)
Io error: Connection reset by peer (os error 104)
Io error: Connection reset by peer (os error 104)
thread 'main' panicked at src/main.rs:9:7:
called `Result::unwrap()` on an `Err` value: WinitEventLoop(ExitFailure(1))
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1654:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1077:23
   4: eframe_egui_bug::main
             at ./src/main.rs:5:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

os error 32 happens more often

To Reproduce Steps to reproduce the behavior:

I suspect this is due to running this on WSL, the code that reproduces this error is the example in the eframe docs, shown here:

main.rs

use eframe::egui;

fn main() {
    let native_options = eframe::NativeOptions::default();
    eframe::run_native(
        "My egui App",
        native_options,
        Box::new(|cc| Ok(Box::new(MyEguiApp::new(cc)))),
    ).unwrap();
}

#[derive(Default)]
struct MyEguiApp {}

impl MyEguiApp {
    fn new(cc: &eframe::CreationContext<'_>) -> Self {
        // Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.
        // Restore app state using cc.storage (requires the "persistence" feature).
        // Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use
        // for e.g. egui::PaintCallback.
        Self::default()
    }
}

impl eframe::App for MyEguiApp {
    fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.heading("Hello World!");
        });
    }
}

Cargo.toml with the patched version, the error remains even in 0.28 or 0.28.1 w/o the patch

[package]
name = "eframe_egui_bug"
version = "0.1.0"
edition = "2021"

[dependencies]

eframe= "0.28.1"
[patch.crates-io]
eframe = { git = "https://github.com/emilk/egui", branch = "master" }

[workspace]
resolver = "2"

run $ RUST_BACKTRACE=1 cargo run

Expected behavior

A window with Hello World on it. Eframe 0.23 worked on a previous project of mine but this version here no longer works.

Screenshots

For a split second the window appears

image

Desktop (please complete the following information):

Additional context This is the first issue I've made, please inform me of any additional information I need to provide. Thank you.

JusticeBaum commented 1 week ago

I solved this issue by moving the file over to the windows system, installing Rust via powershell (though im unsure if this is necessary), and then running via cargo as normal.

ravatex commented 1 week ago

The error happens in the WSL, not on the actual windows system. Cargo, the source, and all dependencies are contained in the WSL not on windows, and the program is run on the WSL not windows itself.

JusticeBaum commented 1 week ago

Yes but within WSL navigating over to the mounted Windows file system cd /mnt/c/Users/... and containing the project there solved the issue on my system; Other alternatives I've seen for this issue have been setting up X forwarding between WSL and Windows or building for Windows when compiling your project. The issue stems from linux and windows graphic drivers not playing nice