Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRY template auto-closes main window on Windows. #425

Open
MichaelXt opened this issue Dec 21, 2024 · 0 comments
Open

WRY template auto-closes main window on Windows. #425

MichaelXt opened this issue Dec 21, 2024 · 0 comments

Comments

@MichaelXt
Copy link

MichaelXt commented Dec 21, 2024

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 run

Note: 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;
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant