with “dioxus::desktop::window().new_window()” to create a new window,The program will crash and crash.
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
I can reproduce this on Windows 10 with the popup example except I get a different error:
thread 'main' panicked at packages\generational-box\src\unsync.rs:253:47:
already borrowed: BorrowMutError
The windows freezing and the new window not mounting act the same.
I also tested this on Linux with the only issue being that the new window couldn't be closed but otherwise, it worked without error.
Yes, I have encountered this error in the Popup example before, but when I used a similar method to write other programs, I encountered an error that is different from Popup
Hi @DogeDark,
I'm currently working on fixing the already borrowed error (), especially around get_split_ref and get_split_mut. I’m digging into potential conflicts in recursive borrowing and exploring ways to prevent these issues from recurring. Could you assign this issue to me so I can continue making progress?
About the error : The already borrowed error typically occurs in Rust when a **RefCell** is borrowed as immutable or mutable while there is already another active borrow that conflicts with the new one. This issue often arises in single-threaded environments when there are overlapping Ref and RefMut borrows, and Rust's borrow checker catches this.
Thank You for your help!
Hi everyone,
After spending some time debugging this, I think I’ve identified what seems to be causing the problem.
It initially appeared that borrow_mut in unsync.rs might be the source of the issue (cause we are providing mut ref within a loop). However, after a closer look, unsync.rs actually seems to be functioning as expected. The real issue seems related to the desktop::window().new_window() method when creating a secondary window.
The problem can be consistently reproduced by running the multiwindow.rs or popup.rs examples. When there is already an active primary window and a new window is created, the new window appears but does not render content properly.
The already_borrow error occurs specifically when attempting to close the primary window before the new window. Since we’re unable to close the new popup window (as it gets stuck), the mutable reference (from RefCell) remains borrowed by the new window, leading to this error.
This suggests that the borrowing conflict might stem from how .new_window() method handles the references when the primary window is still active.
As of now, I'm still working on this, trying to figure out the issue. I'm focusing on these potential causes:
- Why the new window is not getting rendered properly with the window().new_window() method.
- Could this be an issue with the
SharedContextin theDesktopService? - Could it be related to the
VirtualDomfrom theWebviewInstancestruct?
- Could this be an issue with the
Hope this helps clarify the issue! I’ll update as I learn more, and please let me know if there’s any additional insight you have.
Addressing Window Creation Blockage in Multi-Window Setup
Hi @ealmloff @DogeDark,
~It's not a Fix , rahter a workaround for now.~
After several days of debugging this issue, here's what I found and the steps I followed: Steps:
- I dug very deep into various methods, such as
window.new_window(), creating a newWebInstance, setting up a newVirtual DOMandConfig, and experimenting with thewrylibrary. - I focused especially on the the
WebView.build()method which I found was getting stuck during second window creation , async code in thecreate_controllerfunction. - During my investigation, I found that something might be blocking the main thread, potentially causing the mpsc channel to be blocked or waiting indefinitely.
- To test this, I added timers at different places between creating the primary window and the second window to see if any delays would resolve the issue.
- After this experimentation, I came up with a solution involving
multi-threadingandasync functions. While this might not be the most optimal solution, I believe it's a good workaround. There should ideally be a better way to create windows without spinning up a new thread.
Solution:
- I am now using separate threads to create the new window.
That said, I’m very open to any suggestions or alternative solutions that might be more efficient or better aligned with the intended design.
_
NOTE: I've also updated the example documentation for using .new_window() to guide users through the process.
Sorry, I didn't open GitHub to view the information a while ago. Thank you for your detailed answer. If I have any new discoveries in the future, I will communicate with you in detail
I have found that the last working commit was 8b62b71e2d687d0b6fc92872697a644352879688 before #2792 (cab573eefd28bde49ed4d162e5e5c46321e1cdf6) was merged. Something in there is causing CreateCoreWebView2Controller to block indefinitely.
Update - CreateCoreWebView2Controller isn't blocking, it's the CreateCoreWebView2ControllerCompletedHandler::wait_for_async_operation which is blocking and never moves onto the rx.recv(). Creating the actual webview succeeds.
Are there any updates on this issue? It is still not working for me on windows 10
Same on Windows 11 - new_window blocks indefinitely.
I think this is the same issue as https://github.com/tauri-apps/wry/issues/583 and this related windows behavior: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/threading-model#reentrancy
Our code lets you call new_window from the synchronous event handler which would be reentrant. We need to queue the event and then handle it after the event handler is finished. The spawn workaround effectively does that with the dioxus task queue, but it would be more clear to use the wry custom event queue