Giter VIP home page Giter VIP logo

Comments (12)

khyerdev avatar khyerdev commented on May 28, 2024 1

@rustbasic

struct MainWindow;
impl MainWindow {
    fn create(_cc: &eframe::CreationContext<'_>) -> Self {
        Self
    }
}
impl eframe::App for MainWindow {
    fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
        eframe::egui::CentralPanel::default().show(ctx, |_ui| {
            // empty app
        });
    }
}

fn main() -> eframe::Result<()> {
    let options = eframe::NativeOptions::default();
    eframe::run_native("vscode", options, Box::new(|cc| Box::new(MainWindow::create(cc))))
}

using eframe v0.26.2

from egui.

khyerdev avatar khyerdev commented on May 28, 2024 1

I copied the code and ran it on my machine, and I still had the same problem with both viewports. It might be an issue with Windows 11 or just my machine.

from egui.

khyerdev avatar khyerdev commented on May 28, 2024 1

@rustbasic
image
still the same issue

from egui.

emilk avatar emilk commented on May 28, 2024

Have you tried the wgpu backend?

from egui.

khyerdev avatar khyerdev commented on May 28, 2024

How would I use it natively?

from egui.

emilk avatar emilk commented on May 28, 2024

Just enable the wgpu feature of eframe

from egui.

khyerdev avatar khyerdev commented on May 28, 2024

Thank you!

Adding the wgpu feature does prevent the crashing, but it does also make the viewport look slightly stretched while I resize it, as well as doubling the file size of the output binary. Both of these I don't really like.

Not much of an issue though, and I can use it for now, but I would prefer if the default backend worked properly (no crashing when resizing from a corner)

from egui.

rustbasic avatar rustbasic commented on May 28, 2024

@OSCH2008

If you could make a simple example with one file (panic occurs when resizing), it would be helpful to check.

from egui.

YgorSouza avatar YgorSouza commented on May 28, 2024

I tried running the hello_world example on Windows 11 with the default features, and it didn't crash when resizing. Have you tried that? You have another dependency called screen-info that has a lot of unsafe code. Does it crash without that dependency as well? If you're only using it to center the window on the screen at startup, you can do that by passing centered: true to NativeOptions.

from egui.

khyerdev avatar khyerdev commented on May 28, 2024

I did use screen-info to calculate the center of my screen for the window, because I didn't like the inaccuracy of centered = true in one of my previous projects. But removing that dependency and using centered = true instead still did not stop the crashes.

from egui.

rustbasic avatar rustbasic commented on May 28, 2024

@OSCH2008

With the above source code, I tested it with egui v0.26.2 on Windows 10.
There is nothing wrong. ( I'm not used wgpu. )

I added one Viewport as follows and tested it all, and there was no problem.

struct MainWindow;
impl MainWindow {
    fn create(_cc: &eframe::CreationContext<'_>) -> Self {
        Self
    }
}
impl eframe::App for MainWindow {
    fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
        eframe::egui::CentralPanel::default().show(ctx, |ui| {
            ui.label("Main : Corner resize TEST");
            dev_viewport_immediate(ui);
        });
    }
}

fn main() -> eframe::Result<()> {
    let options = eframe::NativeOptions::default();
    eframe::run_native("vscode", options, Box::new(|cc| {
        Box::new(MainWindow::create(cc))
    }))
}

pub fn dev_viewport_immediate(ui: &mut egui::Ui) {

    let title = "Immediate Viewport";
    ui.ctx().show_viewport_immediate(
        egui::ViewportId::from_hash_of(title),
        egui::ViewportBuilder::default()
            .with_title(title)
            .with_inner_size([800.0, 600.0]),
        |ctx, class| {
            assert!(
                class == egui::ViewportClass::Immediate,
                "This egui backend doesn't support multiple viewports"
            );

            egui::CentralPanel::default().show(ctx, |ui| {
                ui.label("Viewport : Corner resize TEST");
            });

            if ctx.input(|i| i.viewport().close_requested()) {
                // Tell parent viewport that we should not show next frame:
            }
        },
    );
}

from egui.

rustbasic avatar rustbasic commented on May 28, 2024

I copied the code and ran it on my machine, and I still had the same problem with both viewports. It might be an issue with Windows 11 or just my machine.

cargo update
After trying once, try compiling again.

from egui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.