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] Tauri crashes when using create_window with float number as label #3544

Closed
varholak-peter opened this issue Feb 23, 2022 · 5 comments
Closed

Comments

@varholak-peter
Copy link

varholak-peter commented Feb 23, 2022

Describe the bug

When I call AppHandle.create_window() or Window.create_window() with a floating number parsed into a String as the label the app crashes.

Reproduction

window.create_window(
    // Ouch here!
    String::from("1.0"),
    tauri::WindowUrl::External(url),
    |win, webview| {
        let win = win
            .title(String::from("Whatever"))
            .resizable(true)
            .inner_size(750.0, 500.0)
            .min_inner_size(400.0, 200.0);
        return (win, webview);
    },
)

Expected behavior

Either accept strings like "1.0" as valid label identifiers or if that's impossible return a Result with an error that specifies that we provided an unsupported label.

Platform and versions

Operating System - Mac OS, version 12.2.1 X64

Node.js environment
  Node.js - 16.13.2
  @tauri-apps/cli - 1.0.0-rc.4 (outdated, latest: 1.0.0-rc.5)
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 8.1.2
  pnpm - 6.26.1
  yarn - 1.22.0

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

App directory structure
/node_modules
/static
/scripts
/src-tauri
/.svelte-kit
/build
/.git
/src

App
  tauri - 1.0.0-rc.3
  tauri-build - 1.0.0-beta.4
  tao - 0.6.2
  wry - 0.13.2
  build-type - bundle
  CSP - unset
  distDir - ../build
  devPath - http://localhost:7024/
  framework - Svelte

Stack trace

No response

Additional context

  • I am executing this inside a #[tauri::command]. I don't think that's relevant, but mentioning just in case.
  • Using an integer such as String::new("5555") works as expected.
@amrbashir
Copy link
Member

you can't have . in the label. I think it was implemented like that as part of the audit. Why would you want to use a float number as the window label anyway? seems odd.

@varholak-peter
Copy link
Author

@amrbashir it's not that I need to have a . in the label, but the application should not crash. Instead I would expect a proper Result error to be thrown.

The API specifies a label needs to be a string. I can imagine people namespacing their labels with . and should get a proper error if this is impossible due to internal logic.

@amrbashir
Copy link
Member

cc @lucasfernog

@FabianLars
Copy link
Member

FabianLars commented Mar 1, 2022

create_window already does return a Result which should give an error like this:

" Window label must include only alphanumeric characters, -, /, : and _ "

Edit: opened by accident. Nvm you're right, it panics.
The tokio runtime worker also panics if you create the window in javascript (not crashing the whole application). Furthermore it suggests that the creation was succesul (no error in the console but instead the same output you'd get on succesful runs)

Edit2: Like amr said, check the audit report for the reasoning behind this.

@varholak-peter
Copy link
Author

Glad to see this resolved. 🎉
I didn't need a floating number as a label really, I just used a stringified Math.random() as a temporary measure and my app kept crashing so that's the story behind the bug. ¯\_(ツ)_/¯

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