Skip to content

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

Open
Razshy wants to merge 4 commits into
tauri-apps:devfrom
Razshy:fix/ico-largest-entry
Open

fix(codegen): select largest ICO entry instead of first#15241
Razshy wants to merge 4 commits into
tauri-apps:devfrom
Razshy:fix/ico-largest-entry

Conversation

@Razshy
Copy link
Copy Markdown

@Razshy Razshy commented Apr 15, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

Package Changes Through 55d4be5

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

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.10.1 2.11.0
tauri-utils 2.8.3 2.9.0
tauri-macos-sign 2.3.3 2.3.4
tauri-bundler 2.8.1 2.9.0
tauri-runtime 2.10.1 2.11.0
tauri-runtime-wry 2.10.1 2.11.0
tauri-codegen 2.5.5 2.5.6
tauri-macros 2.5.5 2.5.6
tauri-plugin 2.5.4 2.6.0
tauri-build 2.5.6 2.6.0
tauri 2.10.3 2.11.0
@tauri-apps/cli 2.10.1 2.11.0
tauri-cli 2.10.1 2.11.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
Copy link
Copy Markdown
Author

Razshy commented Apr 20, 2026

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 Outdated
let entry = icon_dir
.entries()
.iter()
.min_by_key(|e| e.width().abs_diff(32))
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.

I just opened #15274, with that, I think we might be able to remove this limit here


#[cfg(windows)]
{
if let Ok(resource_icon) = TaoWindowIcon::from_resource(32512, None) {
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.

Not sure if this is a good default, the task bar icon seems to fallback from ICON_BIG > ICON_SMALL > exe icon 🤔

And I don't think this belongs to here, it should be in the build method

@Legend-Master Legend-Master added this to the 2.11 milestone Apr 29, 2026
@FabianLars FabianLars modified the milestones: 2.11, 2.12 May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] [Windows] Window icon appears blurry - question about ICO multi-size handling

4 participants