maui
maui copied to clipboard
No errors or warnings generated when svg cannot be parsed by Resizetizer/Svg2VectorDrawable
Description
Hi Everyone, including a complex svg in the MauiIcon element for an icon, and the result is a completely transparent image. I traced the issue down to some unsupported svg elements in the source file by manually running it through Svg2VectorDrawable
In C:\Users***\app-icon\app-icon-foreground.svg:
I'm not here to lament on the lack of support for SVG primitives in VectorDrawable (Why Google, Why?) but that our tools don't expose this in any way to the developer using Maui. There should be something in the error or warning list if the output is not going to be what I expect.
Steps to Reproduce
- Create a new project (File > New .NET MAUI App)
- Replace the default appiconfg.svg with one that contains invalid elements such as a drop shadow containing svg attached.
- Clean & Rebuild. Observe the output icon is incorrect with no forground now. Digging into the obj folder and looking at the output, the foreground is completely transparent.
Link to public reproduction project repository
https://github.com/ThreeSevenths/MauiApp5
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Targeting Android 21 or 33
Did you find any workaround?
Use a simpler SVG, or pre-rasterize to a png and include that instead.
Relevant log output
No response
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 6.0. Can repro on android platform with sample project.
MauiApp5-main.zip
When using SVG as plain MauiImage there is Exception
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.92/targets/Microsoft.Maui.Resizetizer.targets(531,9):
error MAUI0000: System.Exception: Unable to allocate pixels for the bitmap.
Repro sample:
Is there a useful workaround? Like doing the PNG conversion on my own. How would I use the @2x and @3x PNGs in MAUI?
I've found that reducing the complexity of the SVG usually solves the problem. SOME gradients seem to be supported. In my particular case, Illustrator was also exporting an embedded PNG from an effect which was causing an issue. I hand-edited the SVG to remove a few things and the compiler did work in the end.