Skip to content

Workaround libpng crash on macos by not creating NSImage from png data#7252

Merged
Wumpf merged 1 commit intomainfrom
fix-icon-setting-crash-maybe
Jun 19, 2025
Merged

Workaround libpng crash on macos by not creating NSImage from png data#7252
Wumpf merged 1 commit intomainfrom
fix-icon-setting-crash-maybe

Conversation

@Wumpf
Copy link
Collaborator

@Wumpf Wumpf commented Jun 17, 2025

On some Macs (OS version dependent?) NSImage may load user installed libpng and subsequently crash (likely if they don't expected symbols). This PR works around this by not encoding back to png but instead sending the image over directly. This is strictly speaking better anyways since we don't have to re-encode icons, but is also a bit more cumbersome to do

@Wumpf Wumpf added bug Something is broken native-mac labels Jun 17, 2025
@github-actions
Copy link

Preview available at https://egui-pr-preview.github.io/pr/7252-fix-icon-setting-crash-maybe
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin
Copy link
Collaborator

Should we decide to merge this, we have to remember to also handle the default icon differently (by including it as a raw image or using the image crate to decode it?)

@Wumpf
Copy link
Collaborator Author

Wumpf commented Jun 17, 2025

If I'm not reading this wrong we so far decoded the default icon and then encoded it again...
I'd rather keep the default icon encoded just out of size consideration. Even better though would be to generate it from code: I mean it's a lil rounded rectangle with an 'e' in it 😆
Counter point: this could mean that we don't have to depend on the png feature of image 💡

@Wumpf Wumpf added crash crash, panic, segfault, freeze, … eframe Relates to epi and eframe labels Jun 17, 2025
@emilk emilk added this to the 0.32.0 milestone Jun 17, 2025
@Wumpf
Copy link
Collaborator Author

Wumpf commented Jun 17, 2025

Fix got confirmed! 🥳

@Wumpf Wumpf marked this pull request as ready for review June 17, 2025 17:19
@lucasmerlin
Copy link
Collaborator

Not related to your PR, but I noticed that the icon will switch to the terminal icon for a split second when closing the app 🤔

Untitled.mov

Not a huge problem but it's a bit odd

Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Nice!

@Wumpf Wumpf merged commit 98add13 into main Jun 19, 2025
47 of 51 checks passed
@Wumpf Wumpf deleted the fix-icon-setting-crash-maybe branch June 19, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken crash crash, panic, segfault, freeze, … eframe Relates to epi and eframe native-mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Basic egui stripped down example breaks

3 participants