-
Notifications
You must be signed in to change notification settings - Fork 743
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
[SVG - Android] Failed to load SVG image - System.Xml.XmlException: Invalid character in the given encoding. #15866
Comments
The encoding mentioned in the error might be the pointer to the problem. Is it this specific SVG that does not work? Or all SVGs throw? |
@MartinZikmund let me try with another more simple SVG (that does not use style or other additional specific data to see) |
@MartinZikmund I did more tests with multiple SVGs, and even for the simpler one that uses only one path data, I still get the same exception on Android (working well on the other platforms). Here are the tests that I did + the sample solution attached here is ready for you so you can test it on your side
|
@agneszitte @pictos So after quite a bit of debugging I finally have some answers 😂 . In the end Resizetizer is indeed causing the problem. If you build the sample above and extract the But Resizetizer also generates This is unfortunately a big problem because our code does the following:
|
@MartinZikmund, @pictos, @nickrandolph [Scenario 1] VS [Scenario 2] |
@agneszitte @MartinZikmund @pictos can we confirm what the normal behavior is for Resizetizer. My understanding is that if you have an SVG it will be automatically picked up as UnoImage. The SVG shouldn't be included in the package, instead the corresponding png files generated by resizetizer are. @pictos can you confirm this is the correct behaviour? Assuming the above behaviour is correct, then we need to ensure that if someone changes the build action on an SVG to Content, then we respect this. We should not be generating PNG files (since it shouldn't be included as UnoImage) and the SVG should be packaged as the user would expect. We shouldn't be using the way they reference the file to determine how the file is packages. However, it maybe that we can have an analyzer as part of Resizetizer that detects when user is referencing an SVG for a file that's being resizetized. |
Svgs used as |
After some investigation that behavior (pack the svg on final app) only happens if the The workaround that I found is to not add Here's the binlog if anyone wants to take a look. |
This would be a result of the template (probably in csproj of the application) including the svg as Content, as well as being included as UnoImage. This image shows the back.svg being included as both Content and UnoImage @pedrojesus-work when you're attaching bin log, please don't use binlog generated by the Build Logging window in VS, as this is missing half the useful information required to diagnose most issues. In the following image there should be a Find in Files tab, which is useful for diagnosing the root cause of build related issues but is missing from the binlog generated by the Build Logging window |
Resizetizer should clean the |
@jeromelaban, @pedrojesus-work (cc @MartinZikmund / @nickrandolph ) |
@pedrojesus-work will know. |
I thought I closed this issue already... As I mentioned here the work and progress will be on Resizetizer project.
@agneszitte The latest package (dev) should be good to test it. Any further updates, please use the linked issue |
Thank @pedrojesus-work for the update, appreciated! @Darsh0307 if you can help test with the latest version please Important
|
the linked PR will be breaking, so it has to wait for a major release, But it is not crucial one right now anyway. |
This issue is now fixed on all platforms, no more I created the sample app using the Blank template with Visual Studio Wizard.
I tested the following platforms:
The zip file for the sample app I used for the tests: While during my tests, I also noticed this other issue for Windows Package/Unpackaged: #16571 |
Current behavior
Failed to load SVG image - System.Xml.XmlException: Invalid character in the given encoding
happening when loading the MainPage of the sample app on Android.Expected behavior
The application should not throw an exception while using an SVG file for Image control like it is currently working on Windows, WASM, Skia, and iOS.
How to reproduce it (as minimally and precisely as possible)
In MainPage.xaml
In UnoSvgSample.csproj
Workaround
N/A
Works on UWP/WinUI
Yes
Environment
Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
NuGet package version(s)
Uno.WinUI : 5.1.87
Affected platforms
Android
IDE
Visual Studio 2022
IDE version
17.9.2
Relevant plugins
No response
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: