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

Crash when minimising the "Window" widget #15

Closed
stephanbuys opened this issue Apr 13, 2021 · 4 comments · Fixed by #18
Closed

Crash when minimising the "Window" widget #15

stephanbuys opened this issue Apr 13, 2021 · 4 comments · Fixed by #18

Comments

@stephanbuys
Copy link
Contributor

Hi,

When I run the ui.rs example and I "minimize" the "Window" widget I consistently get the following crash ( https://github.com/mvlabat/bevy_egui/blob/main/examples/ui.rs#L110):

wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(1, 284, Metal)>`
    In a set_scissor_rect command
    Invalid ScissorRect parameters


thread 'main' panicked at 'Handling wgpu errors as fatal by default', /.../.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.7.1/src/backend/direct.rs:1896:5
stack backtrace:
  11: <bevy_egui::egui_node::EguiNode as bevy_render::render_graph::node::Node>::update
             at ./src/egui_node.rs:266:9
          at ./examples/ui.rs:7:5
@mvlabat
Copy link
Owner

mvlabat commented Apr 14, 2021

Hi @stephanbuys! Thanks for creating the issue. Yeah, I was able to reproduce it while working on the 0.4.0 release as well. I believe that Egui started sending ScissorRect with negative height, which is problematic for some graphics backends. I think that this is a problem on the Egui side, though I'm not 100% sure about this. I was going to reach out to the Egui author about this, but I haven't got a chance yet.

If you'd like to investigate this deeper and probably report this problem in the Egui repo, I'd appreciate this. But anyway, I was going to do that myself at the weekend.

@stephanbuys
Copy link
Contributor Author

stephanbuys commented Apr 14, 2021

Ok, so I "patched" the file to see if I could do a hotfix as follows (https://github.com/mvlabat/bevy_egui/blob/main/src/egui_node.rs#L313)

This "patch" fixes the crash.

                    let scale_factor = window_size.scale_factor * egui_settings.scale_factor as f32;

                    let (x,y,w,mut h) = (
                        (draw_command.clipping_zone.min.x * scale_factor) as u32,
                        (draw_command.clipping_zone.min.y * scale_factor) as u32,
                        (draw_command.clipping_zone.width() * scale_factor) as u32,
                        (draw_command.clipping_zone.height() * scale_factor) as u32
                        );

                    log::info!("{:?}, {:?}, {:?}, {:?}", x,y,w,h);

                    if h == 0 {
                        h = 1;
                    }

                    render_pass.set_scissor_rect(
                        x,y,w,h
                    );

So as a total newbie just playing this through my mind logically I think it would be impossible to render something of zero height or width, so I would suggest that if a egui widget is set to (w,h) = (0,0) rendering should be skipped for that widget? Logically it still exists in Egui, but in terms of rendering it it is pointless.

@stephanbuys
Copy link
Contributor Author

@mvlabat I submitted my suggested fix as PR #16 I don't think it's a egui issue, I wasn't able to induce any negative numbers.

@mvlabat
Copy link
Owner

mvlabat commented Apr 24, 2021

I've just released the 0.4.1 version with the fix. Thanks for the contribution!

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

Successfully merging a pull request may close this issue.

2 participants