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

Panic when drawing no_fill() without also calling stroke_weight() #627

Open
JoshuaBatty opened this issue Jul 14, 2020 · 4 comments
Open
Labels

Comments

@JoshuaBatty
Copy link
Member

I've managed to find a few examples that are crashing now when an object that is set to no_fill does not also call stroke_weight(val). In these instances, running a backtrace reveals that the line below is where nannou panics.

let point_buffer = device.create_buffer_with_data(points_bytes, vertex_usage);

here is the full backtrace.

thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`', C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.5.2\src\lib.rs:940:9
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:77
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:59
   3: core::fmt::write
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libcore\fmt\mod.rs:1052
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\io\mod.rs:1426
   5: std::sys_common::backtrace::_print
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:62
   6: std::sys_common::backtrace::print
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:49
   7: std::panicking::default_hook::{{closure}}
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:204
   8: std::panicking::default_hook
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:224
   9: std::panicking::rust_panic_with_hook
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:472
  10: std::panicking::begin_panic_handler
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:380
  11: std::panicking::begin_panic_fmt
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:334
  12: wgpu::Device::create_buffer_mapped
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.5.2\src\lib.rs:940
  13: wgpu::Device::create_buffer_with_data
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.5.2\src\lib.rs:964
  14: nannou::draw::renderer::Renderer::encode_render_pass
             at .\nannou\src\draw\renderer\mod.rs:820
  15: nannou::draw::renderer::Renderer::render_to_frame
             at .\nannou\src\draw\renderer\mod.rs:932
  16: nannou::draw::Draw<f32>::to_frame
             at .\nannou\src\app.rs:911
  17: p_2_1_2_03::view
             at .\generative_design\shape\p_2_1_2_03.rs:85
  18: nannou::app::run_loop::{{closure}}<p_2_1_2_03::Model,nannou::event::Event>
             at .\nannou\src\app.rs:1115
  19: winit::platform_impl::platform::event_loop::{{impl}}::run_return::{{closure}}<(),closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:200
  20: alloc::boxed::{{impl}}::call_mut<(winit::event::Event<()>, mut winit::event_loop::ControlFlow*),FnMut<(winit::event::Event<()>, mut winit::event_loop::ControlFlow*)>>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\liballoc\boxed.rs:1022
  21: winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::{{closure}}<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:239
  22: std::panic::{{impl}}::call_once<(),closure-0>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:318
  23: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,()>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:305
  24: panic_unwind::__rust_maybe_catch_panic
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libpanic_unwind\lib.rs:86
  25: std::panicking::try<(),std::panic::AssertUnwindSafe<closure-0>>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281
  26: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,()>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:394
  27: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::catch_unwind<(),(),closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150
  28: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::call_event_handler<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:233
  29: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::send_event<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:208
  30: winit::platform_impl::platform::event_loop::SubclassInput<()>::send_event<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:90
  31: winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:819
  32: core::ops::function::FnOnce::call_once<closure-0,()>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libcore\ops\function.rs:232
  33: std::panic::{{impl}}::call_once<isize,closure-0>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:318
  34: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,isize>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:305
  35: panic_unwind::__rust_maybe_catch_panic
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libpanic_unwind\lib.rs:86
  36: std::panicking::try<isize,std::panic::AssertUnwindSafe<closure-0>>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281
  37: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,isize>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:394
  38: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::catch_unwind<(),isize,closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150
  39: winit::platform_impl::platform::event_loop::public_window_callback<()>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:1893
  40: DefSubclassProc
  41: DefSubclassProc
  42: CallWindowProcW
  43: CallWindowProcW
  44: glPushClientAttrib
  45: CallWindowProcW
  46: DispatchMessageW
  47: IsWindowVisible
  48: KiUserCallbackDispatcher
  49: NtUserDispatchMessage
  50: DispatchMessageW
  51: winit::platform_impl::platform::event_loop::EventLoop<()>::run_return<(),closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:215
  52: winit::platform_impl::platform::event_loop::EventLoop<()>::run<(),closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:185
  53: winit::event_loop::EventLoop<()>::run<(),closure-0>
             at C:\Users\josh\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\event_loop.rs:149
  54: nannou::app::run_loop<p_2_1_2_03::Model,nannou::event::Event>
             at .\nannou\src\app.rs:1020
  55: nannou::app::Builder<p_2_1_2_03::Model, nannou::event::Event>::run<p_2_1_2_03::Model,nannou::event::Event>
             at .\nannou\src\app.rs:471
  56: p_2_1_2_03::main
             at .\generative_design\shape\p_2_1_2_03.rs:32
  57: std::rt::lang_start::{{closure}}<()>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67
  58: std::rt::lang_start_internal::{{closure}}
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\rt.rs:52
  59: std::panicking::try::do_call<closure-0,i32>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:305
  60: panic_unwind::__rust_maybe_catch_panic
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libpanic_unwind\lib.rs:86
  61: std::panicking::try
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:281
  62: std::panic::catch_unwind
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panic.rs:394
  63: std::rt::lang_start_internal
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\rt.rs:51
  64: std::rt::lang_start<()>
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67
  65: main
  66: invoke_main
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  67: __scrt_common_main_seh
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  68: BaseThreadInitThunk
  69: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\examples\p_2_1_2_03.exe` (exit code: 101)
@sbauer322
Copy link
Contributor

sbauer322 commented Jul 16, 2020

I'm not sure if all of the following are related, but I've seen a very similar stack trace in the following examples in Generative Design:

p_1_0_01.rs
p_1_2_3_02.rs
p_1_2_3_03.rs
p_1_2_3_04.rs
m_6_2_01.rs (last line printed before failing: Link 20: Vintage Press )
m_2_5_02.rs (runs 24 seconds then fails)
p_2_0_02.rs
p_2_0_03.rs
p_2_1_3_01.rs
p_2_1_5_03.rs
p_2_2_5_01.rs (triggers when both circles and lines are hidden)
p_2_2_6_01.rs (triggers when everything is hidden)
p_2_3_1_01.rs
p_2_3_2_01.rs
p_2_3_3_01.rs
p_3_1_3_02.rs (triggers when everything is hidden)
p_3_1_3_03.rs (triggers when everything is hidden)
p_3_1_3_04.rs (triggers when pressing 4 key)

Could this be related to #631 as well?

@justinsilvestre
Copy link

I also get a similar stack trace when running those same examples @sbauer322 mentioned, at least for the ones I've tried:

p_1_0_01.rs
p_1_2_3_02.rs
p_1_2_3_03.rs
p_1_2_3_04.rs
m_6_2_01.rs (last line printed before failing: Link 20: Vintage Press )
m_2_5_02.rs (runs 24 seconds then fails)

Interestingly, these all run with no issue when I switch from the locally built nannou to the prebuilt one from the internet:

# in generative_design/Cargo.tml

[dev-dependencies]
# nannou = { version ="0.14.1", path = "../nannou" }
nannou = "0.14.1"

@sbauer322
Copy link
Contributor

sbauer322 commented Jul 29, 2020

For what its worth, @justinsilvestre , #636 might have fixed this behavior for the examples mentioned and was merged this morning. If you pull the latest code from master and run the example again then it should work (at least it does for me).

My basic understanding, thanks to the people of the Nannou Slack, was that if nothing is actually being drawn in the window then wgpu would crash due to 0 vertices. In the case of some of those examples, such as p_1_0_01.rs, this would happen because the mouse coordinates defaulted to 0.0 when the example loads and a rectangle of 0 width and 0 height has no vertices.

@ghost
Copy link

ghost commented Jul 29, 2020

@justinsilvestre Hi bro! :)

@sbauer322 Ahh yeah I was thinking that could be the case with the mouse coords. That's probably different between desktop environments, which would explain why it happens to others on the first frame, but didn't happen to me until I moved my mouse to make the Rectangle shrink on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants