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

imgui UI out of bounds in example "imgui-winit" #338

Open
martinteoharov opened this issue Feb 24, 2023 · 6 comments
Open

imgui UI out of bounds in example "imgui-winit" #338

martinteoharov opened this issue Feb 24, 2023 · 6 comments
Labels
info needed More information is required

Comments

@martinteoharov
Copy link

martinteoharov commented Feb 24, 2023

Whenever I switch between my monitors and run my program I get an instant crash before the first render. I narrowed it down to the UI drawing to a slightly bigger frame. I tried to recreate it in the example mentioned in the title and I also got the same error. A restart of my PC fixes it sometimes.

[2023-02-24T15:14:51Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `pixels_command_encoder`
    In a set_scissor_rect command
    Scissor Rect { x: 0, y: 0, w: 911, h: 650 } is not contained in the render target Extent3d { width: 910, height: 650, depth_or_array_layers: 1 }

I tried tweaking the code, but I couldn't find a solution. Any advice?

@parasyte
Copy link
Owner

It looks like an off by one based on the error message, but this is a new failure mode to me.

Do your displays have different logical pixel sizes? Maybe that has something to do with it. I honestly have not done a lot of testing with multiple displays and handling changes to the scaling factor. I can put together a setup and try to reproduce this.

Because that example uses the scaling factor within its resize handler, I suspect these two events need to be handled simultaneously. That's my current theory.

@parasyte parasyte added the question Usability question label Feb 24, 2023
@martinteoharov
Copy link
Author

thanks @parasyte . My setup is basically a laptop that i connect to 2 different monitors (1920x1080 and 1920x1200) throughout the day (not at the same time).

ill have a look tomorrow and will try to come up with a solution, thanks for the advice and for the great project, ive found it very useful :))

@parasyte parasyte added info needed More information is required and removed question Usability question labels Feb 24, 2023
@tommythorn
Copy link

I just cloned the repo and ran through some examples and hit this. My message was a bit different though:

    Finished `dev` profile [unoptimized + debuginfo] target(s) in 14.25s
     Running `/Users/tommy/projects/Rust/pixels/target/debug/imgui-winit`
[2024-11-12T22:16:56Z ERROR imgui_winit] pixels.resize_surface() failed: Texture width is invalid: 4294967295
[2024-11-12T22:16:56Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3056:5:
wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `pixels_command_encoder`
    In a set_scissor_rect command
    Scissor Rect { x: 0, y: 0, w: 4294967295, h: 4294967295 } is not contained in the render target Extent3d { width: 1280, height: 960, depth_or_array_layers: 1 }


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
-[_MTLCommandEncoder dealloc]:134: failed assertion `Command encoder released without endEncoding'
Abort trap: 6

This is on an iMac 5K (x86) running the latest OS and run: 15.1 and Rust rustc 1.82.0 (f6e511eec 2024-10-15).

@tommythorn
Copy link

The (truncated) backtrace:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
   2: wgpu::backend::direct::default_error_handler
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3056:5
   3: core::ops::function::Fn::call
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:79:5
   4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/boxed.rs:2245:9
   5: wgpu::backend::direct::ErrorSinkRaw::handle_error
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3042:17
   6: wgpu::backend::direct::Context::handle_error
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:324:9
   7: <wgpu::backend::direct::Context as wgpu::context::Context>::command_encoder_end_render_pass
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:1946:13
   8: <T as wgpu::context::DynContext>::command_encoder_end_render_pass
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/context.rs:2796:9
   9: <wgpu::RenderPass as core::ops::drop::Drop>::drop
             at /Users/tommy/.cargo.x86_64-darwin/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/lib.rs:3898:13
  10: core::ptr::drop_in_place<wgpu::RenderPass>
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ptr/mod.rs:574:1
  11: imgui_winit::gui::Gui::render
             at ./src/gui.rs:128:5
  12: imgui_winit::main::{{closure}}::{{closure}}
             at ./src/main.rs:74:17

@tommythorn
Copy link

Clarification: this is a plain vanilla iMac setup and no second monitor. I don't think there's anything unusual about my setup.

@parasyte
Copy link
Owner

parasyte commented Nov 12, 2024

Scissor Rect { x: 0, y: 0, w: 4294967295, h: 4294967295 }

This is indicative of the window being hidden. Which should not cause a draw. (I would consider it a bug to redraw while the window is hidden. But I don't remember ever making a conscious decision to avoid redraws on hidden windows. It was identified in #174, though.)

Also, see this discussion: #400.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed More information is required
Projects
None yet
Development

No branches or pull requests

3 participants