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

[bug] Opening a webview window from Rust on linux fails parsing the url #12443

Open
ugniussle opened this issue Jan 19, 2025 · 0 comments
Open
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@ugniussle
Copy link

Describe the bug

Sometimes when opening a webview window on Linux from Rust with WebviewUrl::App the window opens but the url of it is Err(InvalidUrl(RelativeUrlWithoutBase)). This causes the window to be empty.

Image

I say sometimes because this problem goes away somewhat randomly. Things that made it disappear are not closing the splash screen and disabling the splash screen.

Reproduction

Have an new_playlist.html in the public directory {project}/public/new_playlist.html.

    let window_url = "/new_playlist.html";
    println!("window url: {}", window_url);

    let new_window = tauri::WebviewWindowBuilder::new(
        &app,
        "new_playlist",
        WebviewUrl::App(window_url.into())
    ).build();

    match new_window {
        Ok(_window) => {
            println!("Window created: {:?}", _window.url());
            _window.set_title("New Playlist");
            _window.set_size(tauri::LogicalSize::new(200, 200));
            _window.show();
        },
        Err(e) => {
            error!("Error creating window {label}: {e}");
            return Err(())
        },
    };

Expected behavior

The url of the window gets recognized correctly and the webview content loads.

Full tauri info output

[✔] Environment
    - OS: Manjaro 24.2.1 x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.46.4
    ✔ rsvg2: 2.59.2
    ✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)
    ✔ cargo: 1.84.0 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (2024-05-07)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 23.3.0
    - npm: 10.9.2

[-] Packages
    - tauri 🦀: 2.2.3
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1
    - tauri-cli 🦀: 2.0.2
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.0.2 (outdated, latest: 2.2.5)

[-] Plugins
    - tauri-plugin-fs 🦀: 2.0.1
    - @tauri-apps/plugin-fs : 2.2.0
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace


Additional context

tauri.conf.json

{
  "$schema": "https://schema.tauri.app/config/2.0.0",
  "productName": "test",
  "version": "0.1.0",
  "identifier": "com.test.app",
  "build": {
    "beforeDevCommand": "npm run dev",
    "devUrl": "http://localhost:1420",
    "beforeBuildCommand": "npm run build",
    "frontendDist": "../dist"
  },
  "app": {
    "windows": [
      {
        "title": "app",
        "width": 800,
        "height": 600
      },
      {
        "width": 400,
        "height": 200,
        "visible": true,
        "decorations": false,
        "url": "/splashscreen.html",
        "label": "splashscreen"
      }
    ],
    "security": {
      "csp": null,
      "capabilities": ["default"],
      "assetProtocol": {
        "enable": true,
        "scope": [
          "*/**"
        ]
      }
    }
  },
  "bundle": {
    "active": true,
    "targets": "all",
    "icon": [
      "icons/32x32.png",
      "icons/128x128.png",
      "icons/[email protected]",
      "icons/icon.icns",
      "icons/icon.ico"
    ]
  }
}

@ugniussle ugniussle added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

1 participant