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] System tray icon cause app to crash on Ubuntu linux #6117

Closed
kurdin opened this issue Jan 20, 2023 · 4 comments
Closed

[bug] System tray icon cause app to crash on Ubuntu linux #6117

kurdin opened this issue Jan 20, 2023 · 4 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@kurdin
Copy link

kurdin commented Jan 20, 2023

Describe the bug

I could not find any working combination of icon size / color in config that could work with system tray on linux systems (Ubuntu)

"tauri": {
"systemTray": {
"iconPath": "icons/32x32.png",
"iconAsTemplate": true
}

I tried 32x32, 64x64, etc. Nothing can be used with tauri 1.2.4.
I bet it was working before with tauri 1.1, it has problem with grayscale image but specifying png image with colors worked
fine, after upgrade to tauri 1.2.4 I could not make it work at all.

I see 2 type of errors using different size icons

  1. thread 'main' panicked at 'data.len() must fit the width, height, and row_stride', /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdk-pixbuf-0.15.11/src/pixbuf.rs:52:13

  2. thread 'main' panicked at 'called Result::unwrap() on an Err value: Parameter(ParameterError { inner: ImageBufferSize { expected: 16384, actual: 4096 } })', /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.15.8/src/platform_impl/linux/icon.rs:59:40

Window and macos work fine

Platform and versions

Environment
› OS: Ubuntu 22.04 X64
› Node.js: 16.19.0
› npm: 8.19.3
› pnpm: Not installed!
› yarn: Not installed!
› rustup: 1.25.1
› rustc: 1.66.1
› cargo: 1.66.1
› Rust toolchain: stable-x86_64-unknown-linux-gnu

Packages
› @tauri-apps/cli [NPM]: 1.2.3
› @tauri-apps/api [NPM]: 1.2.0
› tauri [RUST]: 1.2.4,
› tauri-build [RUST]: 1.2.1,
› tao [RUST]: 0.15.8,
› wry [RUST]: 0.23.4,

App
› build-type: bundle
› CSP: unset
› distDir: ../dist
› devPath: http://localhost:5173/
› framework: React
› bundler: Webpack

App directory structure

├─ dist
├─ node_modules
├─ assets
├─ public
├─ src-tauri
└─ src

Stack trace

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parameter(ParameterError { inner: ImageBufferSize { expected: 16384, actual: 4096 } })', /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.15.8/src/platform_impl/linux/icon.rs:59:40
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
   2: core::result::unwrap_failed
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1791:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1113:23
   4: tao::platform_impl::platform::icon::PlatformIcon::write_to_png
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.15.8/src/platform_impl/linux/icon.rs:59:5
   5: tao::platform_impl::platform::system_tray::SystemTrayBuilder::build
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.15.8/src/platform_impl/linux/system_tray.rs:48:5
   6: tao::system_tray::SystemTrayBuilder::build
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tao-0.15.8/src/system_tray.rs:87:5
   7: tauri_runtime_wry::system_tray::create_tray
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-runtime-wry-0.12.2/src/system_tray.rs:117:14
   8: <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::system_tray
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-runtime-wry-0.12.2/src/lib.rs:1973:25
   9: tauri::app::tray::SystemTray::build
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.2.4/src/app/tray.rs:419:40
  10: tauri::app::Builder<R>::build
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.2.4/src/app.rs:1618:9
  11: tauri::app::Builder<R>::run
             at /home/kurdin/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.2.4/src/app.rs:1666:5
  12: my_app::main
             at ./src/main.rs:291:3
  13: core::ops::function::FnOnce::call_once
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/ops/function.rs:251:5

Additional context

No response

@kurdin kurdin added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jan 20, 2023
@getneil
Copy link

getneil commented Jan 22, 2023

this is happening to one of my projects too. but not on mac.

@kurdin
Copy link
Author

kurdin commented Jan 23, 2023

@getneil, mac works fine, I have this error on linux. Strangely, I found that default installation of tauri with fresh system tray setup works just fine on linux, no build errors. I copied Cargo.lock and Cargo.toml to my project, along with tauri.conf.json and icons, after that my project still throw same error on build. I don't understand why this is happening.

@kurdin kurdin changed the title [bug] Any system tray icon cause app to crash on Ubuntu linux [bug] System tray icon cause app to crash on Ubuntu linux Jan 23, 2023
@FabianLars
Copy link
Member

Can you try regenerating your icons with the tauri icon command? If you don't use that command and want to do it yourself, make sure your icons are width=height (error 1) and RGBA = rgb + transparency (error 2)

If that doesn't help, or if you tried that already, i'd appreciate if you could share your icons so we can try to reproduce it on our end.

@kurdin
Copy link
Author

kurdin commented Jan 25, 2023

@FabianLars thank you for a tip about using tauri icon cli. I did not know about that, it does work and it fixed the problem I had. Seems like this is the best and right way to generate tauri icons specially for linux. Thanks again!

Anyone who has an icons error with tauri, just create your png image file with transparency with big size like 512x512 pixels and convert it to tauri icons with tauri cli:
# tauri icon /your-project/app-icon-512x512.png -o /your-project/src-tauri/icons

tauri cli will generate all icons you need for your app in src-tauri/icons folder:

128x128.png
128x128@2x.png
32x32.png
Square107x107Logo.png
Square142x142Logo.png
Square150x150Logo.png
Square284x284Logo.png
Square30x30Logo.png
Square310x310Logo.png
Square44x44Logo.png
Square71x71Logo.png
Square89x89Logo.png
StoreLogo.png
icon.icns
icon.ico
icon.png

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

3 participants