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] open_devtools doesn't work in setup #4170

Closed
rming opened this issue May 19, 2022 · 3 comments
Closed

[bug] open_devtools doesn't work in setup #4170

rming opened this issue May 19, 2022 · 3 comments

Comments

@rming
Copy link
Contributor

rming commented May 19, 2022

Describe the bug

similar code like below, open_devtools does nothing

fn main() {
  tauri::Builder::default()
    .setup(|app| {
      WindowBuilder::new(app, "main", WindowUrl::default()).build().expect("error build main window");
      #[cfg(debug_assertions)]
      app.get_window("main").unwrap().open_devtools();
      Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

Reproduction

No response

Expected behavior

open devtools programmably

Platform and versions

Environment
  › OS: Mac OS 12.3.1 X64
  › Node.js: 16.14.0
  › npm: 8.3.1
  › pnpm: Not installed!
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain: stable-aarch64-apple-darwin

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.11
  › @tauri-apps/api [NPM]: 1.0.0-rc.5
  › tauri [RUST]: 1.0.0-rc.11,
  › tauri-build [RUST]: 1.0.0-rc.9,
  › tao [RUST]: 0.8.4,
  › wry [RUST]: 0.16.2,

App
  › build-type: bundle
  › CSP: script-src 'unsafe-eval' 'self'; default-src blob: data: filesystem: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; img-src 'self' data: https:;
  › distDir: ../dist
  › devPath: http://127.0.0.1:8080/
  › framework: Vue.js (Vue CLI)
  › bundler: Webpack

App directory structure
  ├─ dist
  ├─ patches
  ├─ node_modules
  ├─ public
  ├─ scripts
  ├─ .github
  ├─ src-tauri
  ├─ .git
  └─ src
✨  Done in 10.37s.

Stack trace

No response

Additional context

No response

@lucasfernog
Copy link
Member

This issue happens because we're not creating the window immediately, but sending a message to the event loop. I'll change that, but this type of code still won't work on a command handler due to tauri-apps/wry#583
Thanks for the report!

@rming
Copy link
Contributor Author

rming commented May 20, 2022

@lucasfernog
but we can still get_window from manager immediately, this is confusing.
sometimes we need modify window properties programmatically when the app starts.
maybe we can add some hooks if there was a window created event for good performance.

@lucasfernog
Copy link
Member

Hopefully we can fix this internally. At least for this usage (creating a window in the setup hook) I've fixed it.

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

2 participants