Skip to content

[bug] Navigate on Android #14939

@dev-mash

Description

@dev-mash

Describe the bug

When starting the app, I want to open the last-viewed-page. This works on desktop. But on android there seems to be a problem with the order/timing. See pseudocode below. Any thoughts on how to implement this properly?

PS: When using async+sleep I can see that the navigation is working. So its not a problem of the navigate() itself.

My Pseudocode:

Starting the app

tauri::Builder::default()
            .setup(|app| {
                load_last_page(app.app_handle().clone());
                Ok(())
            })
            .build(tauri::generate_context!())
            .expect("error while running tauri application");

The function to load the last page (pseudeocode, simplified)

fn load_last_page(appHandle: &tauri::AppHandle) {
  println!("load_last_page Loading last page");
        let main_window = appHandle.get_webview_window("main").unwrap();
        match Url::parse("http://tauri.localhost/mypage") {
            Ok(url) => _ = {
              println!("load_last_page Navigating to the page");
              main_window.navigate(url);
              // tauri::async_runtime::spawn(async move {
              //   tokio::time::sleep(Duration::from_secs(3)).await;
              //   println!("load_last_page Navigating to sleep");
              //   main_window.navigate(url);
              // });
            },
            Err(e) => println!("Failed to parse URL {}", e),
        }
}

Reproduction

No response

Expected behavior

No response

Full tauri info output

> tauri info


[✔] Environment
    - OS: Ubuntu 24.4.0 x86_64 (X64) (ubuntu on wayland)
    ✔ webkit2gtk-4.1: 2.50.4
    ✔ rsvg2: 2.58.0
    ✔ rustc: 1.91.0 (f8297e351 2025-10-28)
    ✔ cargo: 1.91.0 (ea2d97820 2025-10-10)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.19.5
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.9.4, (outdated, latest: 2.10.2)
    - tauri-build 🦀: 2.5.3, (outdated, latest: 2.5.5)
    - wry 🦀: 0.53.5, (outdated, latest: 0.54.1)
    - tao 🦀: 0.34.5
    - @tauri-apps/api : 2.5.0 (outdated, latest: 2.10.1)
    - @tauri-apps/cli : 2.5.0 (outdated, latest: 2.10.0)

[-] Plugins
    - tauri-plugin-fs 🦀: 2.3.0, (outdated, latest: 2.4.5)
    - @tauri-apps/plugin-fs : 2.3.0 (outdated, latest: 2.4.5)
    - tauri-plugin-opener 🦀: 2.2.7, (outdated, latest: 2.5.3)
    - @tauri-apps/plugin-opener : 2.2.7 (outdated, latest: 2.5.3)
    - tauri-plugin-single-instance 🦀: git+https://github.com/tauri-apps/plugins-workspace?branch=v2#e4a40f44232834727334ceb4f8a0db30553eded9 (2.3.6), (outdated, latest: 2.4.0)
    - @tauri-apps/plugin-single-instance : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/myapp-ui
    - devUrl: http://localhost:1420/
    - framework: Angular
    - bundler: Webpack

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions