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

Fyne errors on startup (0.2.0 release on macOS and Linux) #155

Closed
whorfin opened this issue May 5, 2023 · 11 comments
Closed

Fyne errors on startup (0.2.0 release on macOS and Linux) #155

whorfin opened this issue May 5, 2023 · 11 comments
Assignees

Comments

@whorfin
Copy link
Contributor

whorfin commented May 5, 2023

Continued thanks for the development of supersonic

I noticed this on the 0.1.0 beta on macOS; since I continue to see it on both macOS and Linux with 0.2.0 it seemed worth reporting.

This is not noticed when launching from a GUI [finder/linux launcher] but on both platforms, if launched via the cli in a shell, ie by typing supersonic in a terminal, one sees many pages of this repeating error:

2023/05/05 13:00:48 Fyne error:  could not load SVG, falling back to static content:
2023/05/05 13:00:48   Cause: XML syntax error on line 3: invalid character entity & (no semicolon)
2023/05/05 13:00:48   At: /home/dravin/supersonic/vendor/fyne.io/fyne/v2/internal/svg/svg.go:27

(The offending svg.go path is different on linux vs macOS, the rest of the messages are the same)

@dweymouth
Copy link
Owner

Yeah I've seen that, I guess some SVG must be malformed but all the SVG resources I actually use seem to be loaded properly, so I've just ignored it for now.

@davidhaymond
Copy link
Contributor

davidhaymond commented May 18, 2023

I did some debugging on this issue. The error is rooted in fyne.io/fyne/v2/theme/icons.go. There are several resource types that wrap fyne.Resource:

  • theme.ThemedResource
  • theme.InvertedThemedResource
  • theme.ErrorThemedResource
  • theme.PrimaryThemedResource
  • theme.DisabledResource

Each wrapper type's Content() method calls the underlying resource's Content() and passes the returned byte slice to svg.Colorize() without first checking to see if the resource is SVG. This causes an error to occur for PNG resources when svg.Colorize() tries to parse the contents as XML.

An IsResourceSVG() function exists in fyne.io/fyne/v2/internal/painter/image.go, but importing fyne.io/fyne/v2/internal/painter from the theme package causes an import cycle, and probably breaks principles of loose coupling. Perhaps IsResourceSVG() should become a method of fyne.Resource, so it can easily be called in the various Resource wrapper types. If the resource is not SVG, it would return the underlying resource's content unmodified.

Thoughts, @dweymouth? I would be happy to submit a PR in your Fyne fork to fix this.

@dweymouth
Copy link
Owner

dweymouth commented May 18, 2023

Thanks for tracking this down, nice work! I'd be glad to have it fixed in my fork but might be worth opening an issue in Fyne directly and seeing if we can submit the PR there. They are welcoming of new contributors and are glad to accept bug fix PRs. (And I can cherry pick it in to my fork to get the fix before it lands on a Fyne release)

Side note - Fyne really recommends SVGs used for icon resources but the source I grabbed the navigation bar icons from didn't have a freeware license for using the SVG versions so I'm using PNG, for now at least. When SVG resources are used, they can change color depending on whether the button is disabled, etc. That's what all those ThemedResource wrappers do. I had to make a kind-of custom ThemedResource-like wrapper for the PNG icons to swap in a black or white version depending on the theme being Light or Dark

@dweymouth
Copy link
Owner

dweymouth commented May 18, 2023

Another FYI if you look into fixing this in Fyne - the develop branch is the branch to use as baseline in Fyne PRs. They use main master for releases. In my fork, the current baseline I'm building against is supersonic-base-2.3.4

@davidhaymond
Copy link
Contributor

Thanks for the input and advice. It would be great to fix this issue in upstream. I feel like the resource system should support themed bitmap resources because, as you've said, SVG isn't always an an available option. Would it be worth pushing for adding something like your custom themed resource to upstream?

@dweymouth
Copy link
Owner

I think we should start with just suppressing these SVG errors when PNGs are used as themeable icons (eg in buttons). I suspect there will be a philosophical difference with the Fyne devs on the idea of adding a PNG themed resource to the API. There are definitely valid reasons for strongly pushing SVG - the themed wrapper can automatically colorize a single (monochromatic) SVG to the different theme colors but that can't really work (easily at least) with a raster image, esp. because of the complexity around edges.

@davidhaymond
Copy link
Contributor

Sounds good; I'll just focus on the SVG errors for now, and link the issue here once I've created it.

@davidhaymond
Copy link
Contributor

Upstream bug report: fyne-io/fyne#3896.

@dweymouth
Copy link
Owner

Actually I might be able to find SVGs with compatible licenses to use for all the navigation bar icons. I discovered svgrepo.com after having already downloaded those PNG resources (from flaticon.com) and some quick searching seems like I can probably find freely licensed SVG versions of all of them, there was even a theater masks one like the image I use for the genres button.

@dweymouth
Copy link
Owner

I encountered another Fyne bug, moving to all-SVG icons is blocked for the moment by fyne-io/fyne#3900

@dweymouth
Copy link
Owner

Fixed by #306

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

No branches or pull requests

3 participants