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

Minor incorrect triggering of "Failed to convert systray icon" error #5389

Open
2 tasks done
dixieflatline76 opened this issue Jan 10, 2025 · 5 comments
Open
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@dixieflatline76
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Using 118x118 px a png file as a system tray icon on Windows 11 using desktop.App.SetSystemTrayIcon(trayIcon) causes a error message on stdout

2025/01/09 21:28:05 Fyne error: Failed to convert systray icon 2025/01/09 21:28:05 Cause: image: unknown format 2025/01/09 21:28:05 At: C:/Users/karlk/development/Go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/driver_desktop.go:174

The applications functions normally and tray icon is rendered correctly

How to reproduce

  • Download asset from https://github.com/dixieflatline76/Spice
  • Run the spice-service.exe asset via terminal (spice.exe is window'ized without console)
  • Observe the error output, also note tray icon does render properly

Screenshots

2025/01/09 21:28:05 Fyne error: Failed to convert systray icon 2025/01/09 21:28:05 Cause: image: unknown format 2025/01/09 21:28:05 At: C:/Users/karlk/development/Go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/driver_desktop.go:174

Example code

https://github.com/dixieflatline76/Spice/blob/5c147fbd952ece84e0f0c22a64043339968249e8/ui/ui.go#L50

Fyne version

v2.5.3

Go compiler version

go version go1.23.3 windows/amd64

Operating system and version

Windows 11

Additional Information

No response

@dixieflatline76 dixieflatline76 added the unverified A bug that has been reported but not verified label Jan 10, 2025
@andydotxyz
Copy link
Member

It likely isn't wrong - the icon appearing does not mean that it worked, it could mean that the icon fell back to the app icon which is the default if no system tray icon is set.

@dixieflatline76
Copy link
Author

As I am still actively developing, I didn't use fyne package, just building with flags to gen my binary. So the fact the icon shows properly can only mean the conversion worked. The icon is stored in a custom config dir, so no way the app can pick it up automatically

More interestingly, I suspected a conversion problem so tried a svg but that failed completely with tray showing empty icon.

Not a big issue, figure I just track it.

@andydotxyz
Copy link
Member

I didn't use fyne package, just building with flags to gen my binary. So the fact the icon shows properly can only mean the conversion worked.

I'm not sure that's the only explanation. You could have placed the file as Icon.png in the current directory which would have the same effect.

More interestingly, I suspected a conversion problem so tried a svg but that failed completely with tray showing empty icon.

That is an interesting point, thanks.

Looking at the code:

	img, err := toOSIcon(resource.Content())
	if err != nil {
		fyne.LogError("Failed to convert systray icon", err)
		return
	}

	if _, ok := resource.(*theme.ThemedResource); ok {
		systray.SetTemplateIcon(img, img)
	} else {
		systray.SetIcon(img)
	}

You can see that if the error occurs then it will not apply the system tray icon - so it must be defaulting.

I have tried to replicate the issue with the icon from your repository but so far I have not managed to do so.

So I tried one more thing, to look at your code - I wonder it something strange is happening in your asset manager:

func (am *AssetManager) GetIcon(name string) (fyne.Resource, error) {
...

    return fyne.NewStaticResource("app-icon.png", iconData), nil
}

In this method I see that it is always returning an asset with the same name. This means you could be getting cache collisions and possible undefined behaviour. If you use the file name in the name of the resource that you load we will get a more accurate picture of what is actually happening...

@dixieflatline76
Copy link
Author

i am sorry, i must have paste link from an old branch, i updated that a while back, link must have been from old branch. here's the update code

https://github.com/dixieflatline76/Spice/blob/9d472e582e5fa50de7bb2c1e9b81320f5bd33f72/ui/asset.go#L39

i saw that the error said something about gl, could this be a lower level problem? my dev machine is running a amd 6900xt. could this be a weird gl related amd vs nvidia problem?

@andydotxyz
Copy link
Member

andydotxyz commented Jan 12, 2025

That link has the same problem (and so does the main branch).

i saw that the error said something about gl, could this be a lower level problem?

No, the error is reported in an image parse line of code - not rendering related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants