maui icon indicating copy to clipboard operation
maui copied to clipboard

No errors or warnings generated when svg cannot be parsed by Resizetizer/Svg2VectorDrawable

Open ThreeSevenths opened this issue 2 years ago • 4 comments

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: is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported is not supported

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

  1. Create a new project (File > New .NET MAUI App)
  2. Replace the default appiconfg.svg with one that contains invalid elements such as a drop shadow containing svg attached. appiconfg
  3. 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

ThreeSevenths avatar Feb 09 '23 15:02 ThreeSevenths

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.

ghost avatar Feb 09 '23 19:02 ghost

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 6.0. Can repro on android platform with sample project. MauiApp5-main.zip Screenshot 2023-08-11 141530

Zhanglirong-Winnie avatar Aug 11 '23 06:08 Zhanglirong-Winnie

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:

MauiApp5-main.zip

moljac avatar Aug 14 '23 11:08 moljac

Is there a useful workaround? Like doing the PNG conversion on my own. How would I use the @2x and @3x PNGs in MAUI?

pkurzok avatar Jan 12 '24 10:01 pkurzok

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.

ThreeSevenths avatar Jan 19 '24 16:01 ThreeSevenths