-
Notifications
You must be signed in to change notification settings - Fork 87
Description
Describe the bug
The main windows auto-closes immediately after start for WRY template when run on Windows.
Steps To Reproduce
cargo mobile init
# choose option 6 for WRY
# I did run `cargo mobile run` here, not sure if that matters
cargo run
# observe window opens then closes within a second. The application continues to runNote: cargo mobile run works as expected - the app stays open in android emulator
Expected behavior
cargo run should open the main window with the content, and the window should remain open, until explicitly closed
Screenshots
window auto-closes
Platform and Versions (please complete the following information):
Host OS: Windows 11
Target OS:
Rustc:
Ouput of cargo mobile doctor:
Additional context
Default settings, latest cargo mobile2.
Potential solution
The template on https://github.com/tauri-apps/wry is different from the one included in cargo mobile2. Specifically the window initialization logic is done outside of the event loop.
Moving build_webview from the event loop allows to run the app correctly on both Android and Windows:
Event::NewEvents(StartCause::Init) => {
// webview = Some(build_webview(event_loop).unwrap());
}
...
} => {
// webview.take();
*control_flow = ControlFlow::Exit;
}