Skip to content

fix(codegen): select largest ICO entry instead of first - #15241

Merged
lucasfernog merged 15 commits into
tauri-apps:devfrom
Razshy:fix/ico-largest-entry
Sep 19, 2026
Merged

lucasfernog merged 15 commits into
tauri-apps:devfrom
Razshy:fix/ico-largest-entry

Conversation

@Razshy

@Razshy Razshy commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Closes #14596

new_ico() in tauri-codegen uses entries()[0] to select which image from an ICO file to embed as the window icon. Since ICO files conventionally store entries smallest-first, this picks the 16x16 image. When the OS needs a larger size (taskbar, alt-tab), it scales up from 16x16, resulting in a blurry icon.

This selects the largest entry instead, giving the OS a high-resolution source to downscale from.

  • One line changed in crates/tauri-codegen/src/image.rs
  • No new dependencies
  • Passes rustfmt --check and cargo check -p tauri-codegen

@Razshy
Razshy requested a review from a team as a code owner April 15, 2026 03:36
@github-actions

github-actions Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through 08f17d6

There are 14 changes which include tauri-cli with minor, @tauri-apps/cli with minor, tauri with minor, tauri-build with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, @tauri-apps/api with minor, tauri-bundler with minor, tauri-macos-sign with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master

Copy link
Copy Markdown
Contributor

Thanks for contributing! Using the biggest image in the .ico is probably the correct thing to do, but I am a bit worried about people will now ship raw bytes of a large image by default (256 × 256 × 4 = 262,144 bytes for example)

It seems like the way this was somewhat tackled way back in a80d5b7 by putting the 32x32 one to be the first entry 😂

Perhaps we could make it select the biggest entry under say 32x32 or 64x64 (64 × 64 × 4 = 16,384 bytes) for now, this should be a sufficient sized icon for the taskbar icons on most devices, and ideally we could add support of using the embedded resource icons as mentioned in #14596 (comment)

@FabianLars

Copy link
Copy Markdown
Member

we should also look into using tao's https://docs.rs/tao/latest/x86_64-pc-windows-msvc/tao/platform/windows/trait.WindowExtWindows.html#tymethod.set_taskbar_icon for large icons since you mentioned alt-tab which will use this one.
We currently only set the small icon, which as it name suggests should be somewhat small (as it's used in the window titlebar for example)

@Razshy

Razshy commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Ok so Instead of using a decoded RGBA buffer, tauri-runtime-wry loads both ICON_SMALL and ICON_BIG directly from the exe embedded Ico resource IconExtWindows::from_resource so Windows picks the right size for (titlebar, taskbar, alt-tab). It falls back to the existing RGBA path if resource loading fails. @Legend-Master @FabianLars

Comment thread crates/tauri-runtime-wry/src/lib.rs Resolved
Comment thread crates/tauri-codegen/src/image.rs Resolved
Comment thread crates/tauri-runtime-wry/src/lib.rs Resolved
@Legend-Master
Legend-Master force-pushed the fix/ico-largest-entry branch from aa984be to 50c2cef Compare June 2, 2026 03:37
Legend-Master
Legend-Master previously approved these changes Jun 2, 2026

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will merge this one after #15274 so we don't embed huge images

#15241 (comment)

…the post-tauri-apps#15274 scope

Compare width*height (with bits_per_pixel as tie-breaker) instead of
width alone, and panic with the icon path instead of a bare unwrap when
the ICO has no entries. Since tauri-apps#15274 the Windows default window icon is
read from the exe resource, so this only affects .ico files embedded via
include_image! or as the tray icon; update the change file accordingly.
Comment thread crates/tauri/src/image/mod.rs Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants