Skip to content

[bug] cannot manually create window invisible #13452

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

Open
UNIkeEN opened this issue May 16, 2025 · 2 comments
Open

[bug] cannot manually create window invisible #13452

UNIkeEN opened this issue May 16, 2025 · 2 comments
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@UNIkeEN
Copy link

UNIkeEN commented May 16, 2025

Describe the bug

I set this in tauri.conf.json:

{
        "label": "game_log",
        "create": false,
        ...
        "visible": false
      }

and call this:

let error_window = 
  match create_webview_window(&app, &label, "game_log", None).await {
    Ok(window) => Some(window),
    Err(_) => None,
  };

pub async fn create_webview_window(
  app: &AppHandle,
  label: &str,
  config_label: &str,
  url: Option<Url>,
) -> SJMCLResult<WebviewWindow> {
  let window_config = app
    .config()
    .app
    .windows
    .iter()
    .find(|cfg| cfg.label == config_label)
    .ok_or_else(|| SJMCLError(format!("Config label '{}' not found", config_label)))?;

  let mut window_config = window_config.clone();
  window_config.label = label.to_string();

  if let Some(custom_url) = url {
    window_config.url = WebviewUrl::External(custom_url);
  }
  
  let builder = WebviewWindowBuilder::from_config(app, &window_config).map_err(SJMCLError::from)?;
  let window = builder.build().map_err(SJMCLError::from)?;

  Ok(window)
}

The created window should be invisible, but it's shown.

Reproduction

No response

Expected behavior

The created window should be invisible.

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.16.0
    - pnpm: 10.6.5
    - npm: 10.8.1

[-] Packages
    - tauri 🦀: 2.5.1
    - tauri-build 🦀: 2.2.0
    - wry 🦀: 0.51.2
    - tao 🦀: 0.33.0
    - @tauri-apps/api : 2.4.0 (outdated, latest: 2.5.0)
    - @tauri-apps/cli : 2.4.0 (outdated, latest: 2.5.0)

[-] Plugins
    - tauri-plugin-process 🦀: 2.2.1
    - @tauri-apps/plugin-process : 2.2.0 (outdated, latest: 2.2.1)
    - tauri-plugin-dialog 🦀: 2.2.1
    - @tauri-apps/plugin-dialog : 2.2.0 (outdated, latest: 2.2.1)
    - tauri-plugin-single-instance 🦀: 2.2.3
    - @tauri-apps/plugin-single-instance : not installed!
    - tauri-plugin-opener 🦀: 2.2.6
    - @tauri-apps/plugin-opener : 2.2.6
    - tauri-plugin-fs 🦀: 2.2.1
    - @tauri-apps/plugin-fs : 2.2.0 (outdated, latest: 2.2.1)
    - tauri-plugin-clipboard-manager 🦀: 2.2.2
    - @tauri-apps/plugin-clipboard-manager : 2.2.2
    - tauri-plugin-deep-link 🦀: 2.2.1
    - @tauri-apps/plugin-deep-link : 2.2.1
    - tauri-plugin-os 🦀: 2.2.1
    - @tauri-apps/plugin-os : 2.2.1
    - tauri-plugin-log 🦀: 2.4.0
    - @tauri-apps/plugin-log : not installed!
    - tauri-plugin-http 🦀: 2.4.3
    - @tauri-apps/plugin-http : 2.4.2 (outdated, latest: 2.4.3)
    - tauri-plugin-window-state 🦀: 2.2.2
    - @tauri-apps/plugin-window-state : 2.2.1 (outdated, latest: 2.2.2)

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../out
    - devUrl: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace


Additional context

No response

@UNIkeEN UNIkeEN added type: bug status: needs triage This issue needs to triage, applied to new issues labels May 16, 2025
@gschier
Copy link

gschier commented May 17, 2025

I just ran into this too. I'm looking to use invisible windows to avoid the initial JS/React init time when showing my settings window, for example.

I'd love to just have it always ready in the background and show it when needed.

@UNIkeEN
Copy link
Author

UNIkeEN commented May 19, 2025

I encountered another issue that I’d like to report:

After creating the window and manually calling hide(), events sent via emit_to do not seem to be received by the frontend (the Rust side logs indicate the events were successfully sent). When the window is shown again via show(), the frontend does not print the received events as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

3 participants