Repository: DioxusLabs/dioxus

Issue #3080: with “dioxus::desktop::window().new_window()” to create a new window，The program will crash and crash.
Created: 2024-10-21T02:58:51Z
After clicking on the input box, the program froze and crashed. I tried using examples/popup.rs and encountered the same problem. My computer is running on Windows 11 system

pub fn create_topology_handle(mut address: Signal<String>) -> Coroutine<String> {
    use_coroutine(move |mut rx: UnboundedReceiver<String>| async move {
        while let Some(message) = rx.next().await {
            address.set(message);
        }
    })
}

pub fn topology_window(address: Signal<String>) {
    let tx = create_topology_handle(address).tx();
    dioxus::desktop::window().new_window(
        VirtualDom::new_with_props(
            topology_popup,
            Rc::new(move |s| match tx.unbounded_send(s) {
                Ok(_) => {}
                Err(error) => {
                    println!("{}", error);
                }
            }),
        ),
        Default::default(),
    );
}

pub fn topology_popup(send: Rc<dyn Fn(String)>) -> Element {


thread 'main' panicked at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\node.rs:70:49:
already borrowed: BorrowMutError
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
   1: core::panicking::panic_fmt
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
   2: core::cell::panic_already_borrowed
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\cell.rs:785
   3: core::cell::RefCell<slab::Slab<dioxus_core::nodes::VNodeMount> >::borrow_mut<slab::Slab<dioxus_core::nodes::VNodeMount> >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\cell.rs:1076
   4: dioxus_core::nodes::VNode::move_mount_to
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\node.rs:70
   5: dioxus_core::nodes::VNode::diff_node<dioxus_interpreter_js::write_native_mutations::MutationState>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\node.rs:38
   6: dioxus_core::diff::component::impl$0::diff_scope::closure$0<dioxus_interpreter_js::write_native_mutations::MutationState>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\component.rs:54
   7: dioxus_core::runtime::Runtime::with_scope_on_stack<tuple$<>,dioxus_core::diff::component::impl$0::diff_scope::closure_env$0<dioxus_interpreter_js::write_native_mutations::MutationState> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\runtime.rs:189
   8: dioxus_core::virtual_dom::VirtualDom::diff_scope<dioxus_interpreter_js::write_native_mutations::MutationState>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\component.rs:41
   9: dioxus_core::virtual_dom::VirtualDom::run_and_diff_scope<dioxus_interpreter_js::write_native_mutations::MutationState>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\diff\component.rs:30
  10: dioxus_core::virtual_dom::VirtualDom::render_immediate<dioxus_interpreter_js::write_native_mutations::MutationState>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\virtual_dom.rs:596
  11: dioxus_desktop::webview::WebviewInstance::poll_vdom
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:420
  12: dioxus_desktop::app::App::poll_vdom
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\app.rs:331
  13: dioxus_desktop::launch::launch_virtual_dom_blocking::closure$0
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\launch.rs:34
  14: tao::platform_impl::platform::event_loop::impl$3::run_return::closure$0<enum2$<dioxus_desktop::ipc::UserWindowEvent>,dioxus_desktop::launch::launch_virtual_dom_blocking::closure_env$0>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop.rs:237
  15: alloc::boxed::impl$49::call_mut<tuple$<enum2$<tao::event::Event<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >,ref_mut$<enum2$<tao::event_loop::ControlFlow> > >,dyn$<core::ops::function::FnMut<tuple$<enum2$<tao::event::Event<enum2$<dioxus_desktop::ipc::U
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2070
  16: tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop\runner.rs:250
  17: core::panic::unwind_safe::impl$25::call_once<tuple$<>,tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\panic\unwind_safe.rs:272
  18: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >,tuple$<> > 
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panicking.rs:559
  19: alloc::vec::drain::impl$5::next<tuple$<alloc::string::String,alloc::boxed::Box<dyn$<core::ops::function::Fn<tuple$<http::request::Request<alloc::vec::Vec<u8,alloc::alloc::Global> > >,assoc$<Output,http::response::Response<enum2$<alloc::borrow::Cow<slice2$<
  20: std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > > >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panicking.rs:523
  21: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >,tuple$<> >     
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panic.rs:149
  22: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<dioxus_desktop::ipc::UserWindowEvent> >::catch_unwind<enum2$<dioxus_desktop::ipc::UserWindowEvent>,tuple$<>,tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handle
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop\runner.rs:156
  23: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<dioxus_desktop::ipc::UserWindowEvent> >::call_event_handler<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop\runner.rs:242
  24: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<dioxus_desktop::ipc::UserWindowEvent> >::send_event<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop\runner.rs:224
  25: tao::platform_impl::platform::event_loop::ThreadMsgTargetSubclassInput<enum2$<dioxus_desktop::ipc::UserWindowEvent> >::send_event<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop.rs:125
  26: tao::platform_impl::platform::event_loop::thread_event_target_callback::closure$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop.rs:2296
  27: core::ops::function::FnOnce::call_once<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> >,tuple$<> >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
  28: core::panic::unwind_safe::impl$25::call_once<windows::Win32::Foundation::LRESULT,tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\panic\unwind_safe.rs:272
  29: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >,windows::Win32::Foundation::LRESULT>
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panicking.rs:559
  30: alloc::vec::drain::impl$5::next<tuple$<alloc::string::String,alloc::boxed::Box<dyn$<core::ops::function::Fn<tuple$<http::request::Request<alloc::vec::Vec<u8,alloc::alloc::Global> > >,assoc$<Output,http::response::Response<enum2$<alloc::borrow::Cow<slice2$<
  31: std::panicking::try<windows::Win32::Foundation::LRESULT,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > > >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panicking.rs:523
  32: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<dioxus_desktop::ipc::UserWindowEvent> > >,windows::Win32::Foundation::LRESULT>
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\panic.rs:149
  33: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<dioxus_desktop::ipc::UserWindowEvent> >::catch_unwind<enum2$<dioxus_desktop::ipc::UserWindowEvent>,windows::Win32::Foundation::LRESULT,tao::platform_impl::platform::event_loop::thread
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop\runner.rs:156
  34: tao::platform_impl::platform::event_loop::thread_event_target_callback<enum2$<dioxus_desktop::ipc::UserWindowEvent> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\tao-0.26.2\src\platform_impl\windows\event_loop.rs:2345
  35: DefSubclassProc
  36: DefSubclassProc
  37: DispatchMessageW
  38: DispatchMessageW
  39: windows::Win32::UI::WindowsAndMessaging::DispatchMessageA
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\windows-0.58.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:767
  40: webview2_com::wait_with_pump<enum2$<core::result::Result<tuple$<>,enum2$<webview2_com::Error> > > >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\webview2-com-0.33.0\src\lib.rs:78
  41: webview2_com::callback::CreateCoreWebView2ControllerCompletedHandler::wait_for_async_operation
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\webview2-com-0.33.0\src\callback.rs:114
  42: wry::webview2::InnerWebView::create_controller
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\wry-0.43.1\src\webview2\mod.rs:338
  43: wry::webview2::InnerWebView::new_in_hwnd
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\wry-0.43.1\src\webview2\mod.rs:121
  44: wry::webview2::InnerWebView::new<ref$<dyn$<raw_window_handle::borrowed::HasWindowHandle> > >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\wry-0.43.1\src\webview2\mod.rs:87
  45: wry::WebViewBuilder::build
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\wry-0.43.1\src\lib.rs:1036
  46: dioxus_desktop::webview::WebviewInstance::new
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:359
  47: dioxus_desktop::desktop_context::DesktopService::new_window
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\desktop_context.rs:105
  48: desktop::components::topology_popup::topology_window
             at .\desktop\src\components\topology_popup.rs:26
  49: desktop::components::custom_component::Label_Input_Address::closure$0
             at .\desktop\src\components\custom_component.rs:67
  50: dioxus_core::events::impl$16::new::closure$2<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData>,tuple$<>,tuple$<>,tuple$<>,desktop::components::custom_component::Label_Input_Address::closure_env$0>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:451
  51: alloc::boxed::impl$49::call_mut<tuple$<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData> >,dyn$<core::ops::function::FnMut<tuple$<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData> >,assoc$<Output,tuple$<> > > >,alloc::alloc:
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2070
  52: dioxus_core::events::impl$16::call::closure$0<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData>,tuple$<> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:485
  53: dioxus_core::runtime::Runtime::with_scope_on_stack<tuple$<>,dioxus_core::events::impl$16::call::closure_env$0<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData>,tuple$<> > >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\runtime.rs:189
  54: dioxus_core::events::Callback<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData>,tuple$<> >::call<dioxus_core::events::Event<dioxus_html::events::mouse::MouseData>,tuple$<> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:485
  55: dioxus_html::events::mouse::onclick::closure$0<dioxus_core::events::MarkerWrapper<tuple$<> >,desktop::components::custom_component::Label_Input_Address::closure_env$0>
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-html-0.6.0-alpha.3\src\events\mod.rs:33
  56: dioxus_core::nodes::impl$21::listener::closure$0<dioxus_html::events::PlatformEventData,dioxus_html::events::mouse::onclick::closure_env$0<dioxus_core::events::MarkerWrapper<tuple$<> >,desktop::components::custom_component::Label_Input_Address::closure_env
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\nodes.rs:777
  57: dioxus_core::events::impl$16::leak::closure$2<dioxus_core::events::Event<dyn$<core::any::Any> >,tuple$<>,dioxus_core::nodes::impl$21::listener::closure_env$0<dioxus_html::events::PlatformEventData,dioxus_html::events::mouse::onclick::closure_env$0<dioxus_c
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:466
  58: alloc::boxed::impl$49::call_mut<tuple$<dioxus_core::events::Event<dyn$<core::any::Any> > >,dyn$<core::ops::function::FnMut<tuple$<dioxus_core::events::Event<dyn$<core::any::Any> > >,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2070
  59: dioxus_core::events::impl$16::call::closure$0<dioxus_core::events::Event<dyn$<core::any::Any> >,tuple$<> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:485
  60: dioxus_core::runtime::Runtime::with_scope_on_stack<tuple$<>,dioxus_core::events::impl$16::call::closure_env$0<dioxus_core::events::Event<dyn$<core::any::Any> >,tuple$<> > >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\runtime.rs:189
  61: dioxus_core::events::Callback<dioxus_core::events::Event<dyn$<core::any::Any> >,tuple$<> >::call<dioxus_core::events::Event<dyn$<core::any::Any> >,tuple$<> >
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\events.rs:485
  62: dioxus_core::runtime::Runtime::handle_bubbling_event
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\runtime.rs:378
  63: dioxus_core::runtime::Runtime::handle_event
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-core-0.6.0-alpha.3\src\runtime.rs:299
  64: dioxus_desktop::webview::WebviewEdits::handle_html_event
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:121
  65: dioxus_desktop::webview::WebviewEdits::try_handle_event
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:59
  66: dioxus_desktop::webview::WebviewEdits::handle_event
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:50
  67: dioxus_desktop::protocol::desktop_handler
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\protocol.rs:169
  68: dioxus_desktop::webview::impl$1::new::closure$0
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\dioxus-desktop-0.6.0-alpha.3\src\webview.rs:221
  69: alloc::boxed::impl$50::call<tuple$<http::request::Request<alloc::vec::Vec<u8,alloc::alloc::Global> >,wry::RequestAsyncResponder>,dyn$<core::ops::function::Fn<tuple$<http::request::Request<alloc::vec::Vec<u8,alloc::alloc::Global> >,wry::RequestAsyncResponde
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2077
  70: wry::webview2::impl$3::attach_custom_protocol_handler::closure$0
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\wry-0.43.1\src\webview2\mod.rs:867
  71: alloc::boxed::impl$49::call_mut<tuple$<enum2$<core::option::Option<webview2_com_sys::Microsoft::Web::WebView2::Win32::ICoreWebView2> >,enum2$<core::option::Option<webview2_com_sys::Microsoft::Web::WebView2::Win32::ICoreWebView2WebResourceRequestedEventArgs
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2070
  72: webview2_com::callback::impl$551::Invoke
             at C:\Users\songy\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\webview2-com-0.33.0\src\callback.rs:341

Duplicate issue #3939: new_window creation on Windows
Created: 2025-04-01T09:31:44Z
Problem
I'm experiencing an issue when creating a new window using dioxus::desktop::window().new_window()
Behavior:
Works correctly on Linux
On Windows:
The window gets stuck and cannot be closed
When terminating the process via terminal, I get the following error:
[0401/164936.254:ERROR:window_impl.cc(122)] Failed to unregister class Chrome_WidgetWin_0. Error = 1411
Screenshots

Expected Behavior
Window should create and close properly on Windows, same as Linux behavior
Environment:

Dioxus version:  0.6.3
Rust version: 1.82.0
OS info:  Windows10 / Ubuntu 22.04
App platform:  desktop

Closing comment (2025-04-01T13:04:34Z): Closing as a duplicate of #3080