iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.93k stars 1.18k forks source link

Minimizing the Window Panics With "not enough memory left" #603

Closed HTGAzureX1212 closed 3 years ago

HTGAzureX1212 commented 4 years ago

I created a super basic Hello World GUI Application to test Iced out, and it was really great. But when I minimize the window, I see this spat out to the console:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: OutOfMemory(Host)', C:\Users\harry\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-native-0.4.3\src\device.rs:2093:14
stack backtrace:
   0:     0x7ff69501e48e - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:108
   1:     0x7ff69501e48e - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66     
   2:     0x7ff69501e48e - std::sys_common::backtrace::_print_fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:67
   3:     0x7ff69501e48e - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:46
   4:     0x7ff695032b8b - core::fmt::write
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\core\src\fmt\mod.rs:1078
   5:     0x7ff69501bd58 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\io\mod.rs:1518
   6:     0x7ff695020ffd - std::sys_common::backtrace::_print
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:49
   7:     0x7ff695020ffd - std::sys_common::backtrace::print
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:36
   8:     0x7ff695020ffd - std::panicking::default_hook::{{closure}}
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:208
   9:     0x7ff695020bd8 - std::panicking::default_hook
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:227
  10:     0x7ff69502196f - std::panicking::rust_panic_with_hook
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:593
  11:     0x7ff695021471 - std::panicking::begin_panic_handler::{{closure}}
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:499
  12:     0x7ff69501edff - std::sys_common::backtrace::__rust_end_short_backtrace<closure-0,!>
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:141
  13:     0x7ff6950213c9 - std::panicking::begin_panic_handler
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:495
  14:     0x7ff695031130 - core::panicking::panic_fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\core\src\panicking.rs:92
  15:     0x7ff695030f73 - core::option::expect_none_failed
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\core\src\option.rs:1268
  16:     0x7ff694e91acc - wgpu_device_create_swap_chain
  17:     0x7ff694e0a437 - <iced_wgpu::window::backend::Backend as iced_native::window::backend::Backend>::create_swap_chain::h28c092ed874357b7
  18:     0x7ff694de7db9 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}::he6ee16cfe069b693
  19:     0x7ff694df4b81 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hd8481202a3cb8b7b
  20:     0x7ff694deaeb5 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::call_event_handler::h3b280ea1f929b5e5
  21:     0x7ff694de97f5 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event::h0bb160f314854795
  22:     0x7ff694df84ca - winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}::ha00088d63914e43b
  23:     0x7ff694de9fd8 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::hc5f1fb63853f6d52
  24:     0x7ff694dee611 - winit::platform_impl::platform::event_loop::public_window_callback::hbf55711930dd5d9a
  25:     0x7ffb2078b762 - DefSubclassProc
  26:     0x7ffb2078b625 - DefSubclassProc
  27:     0x7ffb3e975c1d - CallWindowProcW
  28:     0x7ffb3e9758ee - CallWindowProcW
  29:     0x7ffb173e3919 - glPushClientAttrib
  30:     0x7ffb3e975c1d - CallWindowProcW
  31:     0x7ffb3e9757ec - DispatchMessageW
  32:     0x7ffb3e981f83 - IsWindowVisible
  33:     0x7ffb4019fe34 - KiUserCallbackDispatcher
  34:     0x7ffb3d091764 - NtUserDispatchMessage
  35:     0x7ffb3e9756fc - DispatchMessageW
  36:     0x7ff694dea67c - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::owned_windows::hc57ac95fc34984a7
  37:     0x7ff694df4202 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h09fbd00e31380438
  38:     0x7ff694de9db8 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h6e6a5616fb16b0a8
  39:     0x7ff694deee9d - winit::platform_impl::platform::event_loop::EventLoopThreadExecutor::execute_in_thread::hd5d4d5245b2daaef
  40:     0x7ffb2078b762 - DefSubclassProc
  41:     0x7ffb2078b625 - DefSubclassProc
  42:     0x7ffb3e975c1d - CallWindowProcW
  43:     0x7ffb3e9757ec - DispatchMessageW
  44:     0x7ffb3e981f83 - IsWindowVisible
  45:     0x7ffb4019fe34 - KiUserCallbackDispatcher
  46:     0x7ffb3d091764 - NtUserDispatchMessage
  47:     0x7ffb3e9756fc - DispatchMessageW
  48:     0x7ff694dee354 - winit::platform_impl::platform::event_loop::EventLoop<T>::run::h6cb5e23a6a4c76fe
  49:     0x7ff694dfea02 - core::ptr::drop_in_place::h7fbff1f525d44d42
  50:     0x7ff694dfcee5 - iced_winit::application::Application::run::h99ebb9b5e942682d
  51:     0x7ff694dfbf12 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::h6390be9b1c1138ab
  52:     0x7ff694dffea6 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbc508e35cf5d39f1
  53:     0x7ff694df2fac - std::rt::lang_start::{{closure}}::h80fedae83cbca74d
  54:     0x7ff695021cb3 - core::ops::function::impls::{{impl}}::call_once
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\library\core\src\ops\function.rs:280
  55:     0x7ff695021cb3 - std::panicking::try::do_call
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:381
  56:     0x7ff695021cb3 - std::panicking::try
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:345
  57:     0x7ff695021cb3 - std::panic::catch_unwind
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panic.rs:396
  58:     0x7ff695021cb3 - std::rt::lang_start_internal
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\rt.rs:51
  59:     0x7ff694dfbf47 - main
  60:     0x7ff6950ce234 - invoke_main
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  61:     0x7ff6950ce234 - __scrt_common_main_seh
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  62:     0x7ffb3e5e7c24 - BaseThreadInitThunk
  63:     0x7ffb4016cea1 - RtlUserThreadStart

Any help would be greatly appreciated, thank you.

HTGAzureX1212 commented 4 years ago

Update: I updated the crate to the one on this master branch and the backtrace now is:

thread 'main' panicked at 'not enough memory left', C:\Users\harry\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.6.0\src\backend\direct.rs:1323:35
stack backtrace:
   0:     0x7ff6e85e606e - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:108
   1:     0x7ff6e85e606e - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff6e85e606e - std::sys_common::backtrace::_print_fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:67
   3:     0x7ff6e85e606e - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:46
   4:     0x7ff6e85fc2db - core::fmt::write
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\core\src\fmt\mod.rs:1078
   5:     0x7ff6e85e3688 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\io\mod.rs:1518
   6:     0x7ff6e85e8bdd - std::sys_common::backtrace::_print
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:49
   7:     0x7ff6e85e8bdd - std::sys_common::backtrace::print
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:36
   8:     0x7ff6e85e8bdd - std::panicking::default_hook::{{closure}}
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:208
   9:     0x7ff6e85e87b8 - std::panicking::default_hook
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:227
  10:     0x7ff6e85e954f - std::panicking::rust_panic_with_hook
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:593
  11:     0x7ff6e85e9051 - std::panicking::begin_panic_handler::{{closure}}
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:499
  12:     0x7ff6e85e69df - std::sys_common::backtrace::__rust_end_short_backtrace<closure-0,!>
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\sys_common\backtrace.rs:141
  13:     0x7ff6e85e8fa9 - std::panicking::begin_panic_handler
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:495
  14:     0x7ff6e85e8f5c - std::panicking::begin_panic_fmt
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:437
  15:     0x7ff6e8425d60 - <core::result::Result<T,E> as wgpu::backend::direct::PrettyResult<T>>::unwrap_pretty::{{closure}}::ha7b2c627e5c67fcf
  16:     0x7ff6e82baa89 - <wgpu::backend::direct::Context as wgpu::Context>::device_create_swap_chain::hd34977fbefa0ead5
  17:     0x7ff6e82bf836 - wgpu::Device::create_swap_chain::h94c2a5694fbc00f3
  18:     0x7ff6e81df8e3 - <iced_wgpu::window::compositor::Compositor as iced_graphics::window::compositor::Compositor>::create_swap_chain::hb63c1ed998df4de8
  19:     0x7ff6e81afe91 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h588941a2614dfd41
  20:     0x7ff6e810f9b1 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}::hc6a61a9212ceb70c
  21:     0x7ff6e81aef36 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::call_event_handler::{{closure}}::hcd4233a4d4a6df9b
  22:     0x7ff6e8111395 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::register_window::h916112b4e334a4c4
  23:     0x7ff6e810fc24 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event::h9625547e04dd3162
  24:     0x7ff6e81ab0cc - winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}::h05b7a3c82a44df04
  25:     0x7ff6e81101a8 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h2633751b0f184f95
  26:     0x7ff6e8199941 - winit::platform_impl::platform::event_loop::public_window_callback::hcaf0c39e7dc97069
  27:     0x7ffb2078b762 - DefSubclassProc
  28:     0x7ffb2078b625 - DefSubclassProc
  29:     0x7ffb3e975c1d - CallWindowProcW
  30:     0x7ffb3e9758ee - CallWindowProcW
  31:     0x7ffb173e3919 - glPushClientAttrib
  32:     0x7ffb3e975c1d - CallWindowProcW
  33:     0x7ffb3e9757ec - DispatchMessageW
  34:     0x7ffb3e981f83 - IsWindowVisible
  35:     0x7ffb4019fe34 - KiUserCallbackDispatcher
  36:     0x7ffb3d091764 - NtUserDispatchMessage
  37:     0x7ffb3e9756fc - DispatchMessageW
  38:     0x7ff6e8110b5c - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::owned_windows::h72000d05ab829556
  39:     0x7ff6e81ae6ac - winit::platform_impl::platform::event_loop::thread_event_target_callback::{{closure}}::h0486bf3c2c2acbd0
  40:     0x7ff6e81103c8 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h391c9473cd8e8da1
  41:     0x7ff6e819a1d4 - winit::platform_impl::platform::event_loop::EventLoopThreadExecutor::execute_in_thread::h9f337c15769047c3
  42:     0x7ffb2078b762 - DefSubclassProc
  43:     0x7ffb2078b625 - DefSubclassProc
  44:     0x7ffb3e975c1d - CallWindowProcW
  45:     0x7ffb3e9757ec - DispatchMessageW
  46:     0x7ffb3e981f83 - IsWindowVisible
  47:     0x7ffb4019fe34 - KiUserCallbackDispatcher
  48:     0x7ffb3d091764 - NtUserDispatchMessage
  49:     0x7ffb3e9756fc - DispatchMessageW
  50:     0x7ff6e8199694 - winit::platform_impl::platform::event_loop::EventLoop<T>::run::ha2c30e2dff117ba5
  51:     0x7ff6e81c6bae - alloc::alloc::box_free::h20f4e46d63dcec6a
  52:     0x7ff6e81c31c8 - iced::application::Application::run::h644759be6d346e86
  53:     0x7ff6e81b354c - wgpu_core::command::CommandBuffer<B>::insert_barriers::hfb499ef1ac00ee73
  54:     0x7ff6e80e74d6 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbc508e35cf5d39f1
  55:     0x7ff6e8195c7c - std::rt::lang_start::{{closure}}::h80fedae83cbca74d
  56:     0x7ff6e85e9893 - core::ops::function::impls::{{impl}}::call_once
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\library\core\src\ops\function.rs:280
  57:     0x7ff6e85e9893 - std::panicking::try::do_call
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:381
  58:     0x7ff6e85e9893 - std::panicking::try
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panicking.rs:345
  59:     0x7ff6e85e9893 - std::panic::catch_unwind
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\panic.rs:396
  60:     0x7ff6e85e9893 - std::rt::lang_start_internal
                               at /rustc/b2d115f6db5172c961dfeb50de15f35784dbc7c9\/library\std\src\rt.rs:51
  61:     0x7ff6e81b35f7 - main
  62:     0x7ff6e86b4a30 - invoke_main
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  63:     0x7ff6e86b4a30 - __scrt_common_main_seh
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  64:     0x7ffb3e5e7c24 - BaseThreadInitThunk
  65:     0x7ffb4016cea1 - RtlUserThreadStart
HTGAzureX1212 commented 4 years ago

So now this issue has a bug label. Is it a bug in iced, or a bug in wgpu?

cwfitzgerald commented 4 years ago

I have triaged this on the wgpu side: creating a swapchain of size (0, 0) is an invalid use of vulkan, so wgpu will add validation that asserts on creating a swapchain of size (0, 0). On the iced side, iced needs to not recreate the swapchain when the size of the window is (0, 0).

HTGAzureX1212 commented 4 years ago

Thanks