dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Opening Multiple Windows on Desktop-Windows Fails 9 out of 10 Times.

Open NotGovernor opened this issue 8 months ago • 1 comments

Problem

Opening Multiple Windows on Desktop-Windows Fails 9 out of 10 Times.

Steps To Reproduce

Steps to reproduce the behavior:

Create a single window with a single button that attempts to open a new window. New window command copy pasted from new window example code in the repo.

main.rs (excerpts)

#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
	#[route("/")]
	Home {},
}

fn main() {
	let cfg = dioxus::desktop::Config::new().with_menu(None);
	LaunchBuilder::desktop().with_cfg(cfg).launch(App);
}

#[component]
fn App() -> Element {
	rsx! {
		Router::<Route> {}
	}
}

#[component]
fn Home() -> Element {
	rsx! {
		div {	// Window background
			class: "bg-slate-900 flex w-screen h-screen text-white justify-center items-center",

			div {
				class: "{ButtonStyling}",
				// onclick: OpenAWindow,
				onclick: move |_| {
					let dom = VirtualDom::new(windows::userinfowindow::UserInfoWindow);
					dioxus::desktop::window().new_window(dom, Default::default());
				},
				"User Info"
			}
		}
	}
}

UserInfoWindow

#[component]
pub fn UserInfoWindow() -> Element {
	rsx! {
		"test"
	}
}

Start app with dx serve --hot-reload --platform desktop

Window with button loads fine.

1 out of every 10 times I start the app and click the button the new window opens fine.

9 out of 10 times I start the app and click the button I get:

Connected to hot reloading 🚀
thread 'main' panicked at C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dioxus-desktop-0.5.1\src\webview.rs:192:39:
called `Result::unwrap()` on an `Err` value: WebView2Error(WindowsError(Error { code: HRESULT(0x8007139F), message: "The group or resource is not in the correct state to perform the requested operation." }))

Here's the full backtrace: https://pastebin.com/h07yntzs

Expected behavior

The new window always opens.

Environment: dioxus = { version = "0.5", features = ["desktop", "router"] } rustc 1.78.0 OS: Windows Platform: Desktop

Thanks for everyone's work on this project!

NotGovernor avatar Jun 06 '24 18:06 NotGovernor