Skip to content

[bug] android crashes when url is set on a WebviewWindow #13461

@Vexcited

Description

@Vexcited

Describe the bug

When setting an url on a WebwiewWindow, the app immediately crashes on Android.
It also happens when using the builder like this, during the .setup() in tauri::Builder::default() :

let app_url = Url::parse("https://ecole-directe.plus/login").unwrap();
let app_url_external = WebviewUrl::External(app_url);
let mut win = WebviewWindowBuilder::new(app, "main", app_url_external);
// ...

Reproduction

  • Create any project with pnpm create tauri-app
  • Run pnpm tauri android init
  • Update src-tauri/tauri.conf.json properties to set an external URL on devUrl, frontendDist and windows[0].url like the following, for example :
{
  "$schema": "https://schema.tauri.app/config/2",
  "productName": "tauri-app",
  "version": "0.1.0",
  "identifier": "com.tauri-app.app",
  "build": {
    "beforeDevCommand": "",
    "devUrl": "https://ecole-directe.plus/login",
    "beforeBuildCommand": "",
    "frontendDist": "https://ecole-directe.plus/login"
  },
  "app": {
    "withGlobalTauri": true,
    "windows": [
      {
        "title": "tauri-app",
        "url": "https://ecole-directe.plus/login",
        "width": 800,
        "height": 600
      }
    ],
    "security": {
      "csp": null
    }
  },
  "bundle": {
    "active": true,
    "targets": "all",
    "icon": [
      "icons/32x32.png",
      "icons/128x128.png",
      "icons/128x128@2x.png",
      "icons/icon.icns",
      "icons/icon.ico"
    ]
  }
}
  • Run pnpm tauri android dev
  • See the app crash on start !

Expected behavior

The app should not crash.

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.5.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.86.0 (05f9846f8 2025-03-31)
    ✔ cargo: 1.86.0 (adf9b6ad1 2025-02-28)
    ✔ rustup: 1.28.1 (f9edccde0 2025-03-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 23.11.0
    - pnpm: 10.9.0
    - yarn: 1.22.22
    - npm: 11.3.0
    - bun: 1.2.13

[-] Packages
    - tauri 🦀: 2.5.1
    - tauri-build 🦀: 2.2.0
    - wry 🦀: 0.51.2
    - tao 🦀: 0.33.0
    - @tauri-apps/api : 2.5.0
    - @tauri-apps/cli : 2.5.0

[-] Plugins
    - tauri-plugin-opener 🦀: 2.2.6
    - @tauri-apps/plugin-opener : 2.2.6

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: https://ecole-directe.plus/login
    - devUrl: https://ecole-directe.plus/login
    - bundler: Vite

Stack trace

05-17 20:39:40.868 15866 15913 I RustStdoutStderr: 
05-17 20:39:40.868 15866 15913 I RustStdoutStderr: thread '<unnamed>' panicked at /Users/vexcited/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.5.1/src/manager/webview.rs:437:35:
05-17 20:39:40.868 15866 15913 I RustStdoutStderr: called `Result::unwrap()` on an `Err` value: ()
05-17 20:39:40.868 15866 15913 I RustStdoutStderr: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional context

webview.rs:437

WebviewUrl::External(url) => {
  let config_url = app_manager.get_url(pending.webview_attributes.use_https_scheme);
  let is_local = config_url.make_relative(url).is_some();
  let mut url = url.clone();
  if is_local && PROXY_DEV_SERVER {
    url.set_scheme("tauri").unwrap(); // LINE 437 !! Crashes when setting the scheme ?
    url.set_host(Some("localhost")).unwrap();
  }
  url
}

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