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] External window does not load properly on Windows #3597

Closed
lpturmel opened this issue Mar 2, 2022 · 4 comments
Closed

[bug] External window does not load properly on Windows #3597

lpturmel opened this issue Mar 2, 2022 · 4 comments
Assignees

Comments

@lpturmel
Copy link

lpturmel commented Mar 2, 2022

Describe the bug

Creating a new window from the AppHandle struct with the create_window function results in a blank window on Windows.

Example:

#[tauri::command]
fn spawn_window(app: tauri::AppHandle) {
  let external_url = Url::parse("https://google.com").unwrap();

  app.create_window("command_window".to_string(), tauri::WindowUrl::External(external_url), 
  move |window_builder, webview_attributes| {
      (window_builder, webview_attributes)
  });
}

Results in:
image

Calling the same function from the setup function like so creates the window successfully:

fn main() {
  tauri::Builder::default()
  .setup(|app| {
    let external_url = Url::parse("https://google.com").unwrap();

    app.create_window("window_from_main".to_string(), tauri::WindowUrl::External(external_url), move |window_builder, webview_attributes| {
        (window_builder, webview_attributes)
    });
    Ok(())
  })
  .invoke_handler(tauri::generate_handler![
    spawn_window
  ])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

The exact same project works as expected on MacOS (version 12.2.1).

No console errors are present on the main window and the Dev Tools of the spawned window cannot be accessed (could be possible if there is another way than right click > inspect or F12).

Reproduction

  1. Clone the reproduction repo
  2. cd tauri-window-issue
  3. yarn install or npm install
  4. yarn tauri dev or npm run tauri dev

The secondary window that pops up on load will successfully load the link.

The window spawned with the button: create window does not load the link on Windows.

OR

Create a window from a Tauri command invoked by JS.

Expected behavior

The window should successfully load the link when created from the AppHandle struct (?) on Windows.

Platform and versions

Windows:
Operating System - Windows, version 10.0.22000 X64
Webview2 - 98.0.1108.62
Visual Studio Build Tools:
   - Visual Studio Build Tools 2019

Node.js environment
  Node.js - 17.6.0
  @tauri-apps/cli - 1.0.0-rc.5
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 8.5.1
  pnpm - Not installed
  yarn - 1.22.17

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-pc-windows-msvc

App directory structure
/.git
/node_modules
/src
/src-tauri

App
  tauri - 1.0.0-rc.3
  tauri-build - 1.0.0-rc.3
  tao - 0.6.3
  wry - 0.13.3
  build-type - bundle
  CSP - unset
  distDir - ../public
  devPath - http://localhost:3000/


MacOS:

Operating System - Mac OS, version 12.2.1 X64

Node.js environment
  Node.js - 16.3.0
  @tauri-apps/cli - 1.0.0-rc.5
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 7.17.0
  pnpm - 6.14.5
  yarn - 1.22.11

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-aarch64-apple-darwin 

App directory structure
/node_modules
/src-tauri
/.git
/src

App
  tauri - 1.0.0-rc.3
  tauri-build - 1.0.0-rc.3
  tao - 0.6.3
  wry - 0.13.3
  build-type - bundle
  CSP - unset
  distDir - ../public
  devPath - http://localhost:3000/

Stack trace

No response

Additional context

The behaviour has already been replicated on different environments (this was initially reported by a colleague).

@lucasfernog
Copy link
Member

Seems like it's a deadlock, changing the command to be async fixes it. I'll keep investigating.

@lucasfernog
Copy link
Member

I've opened an issue on wry to track this issue: tauri-apps/wry#583
I'll try a different window creation approach in the meantime.

@lucasfernog lucasfernog self-assigned this Mar 12, 2022
@lucasfernog
Copy link
Member

PR fixing this: #3684

lucasfernog added a commit that referenced this issue Mar 15, 2022
 #3645 #3597 (#3684)

* refactor(core): window id

* fixes

* reintroduce send_tao_window_event

* cleanup code

* add change file

* fix: windows build

* add getter

* fix windows build
@lucasfernog
Copy link
Member

FYI we'll revert the fix so commands will need to be async in other to create a webview on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@lucasfernog @lpturmel and others