Skip to content

Build fails when appicon is an empty (but valid) svg after upgrade to 10.0.60 #35293

Description

@3sRykaert

Description

When using Maui 10.0.60 the following error occurs when building an app with an empty appicon:

'C:\Projects\MauiMemoryleak\MauiMemoryleak\Resources\AppIcon\appicon.svg'. System.InvalidOperationException: Cannot draw SVG file 'C:\Projects\MauiMemoryleak\MauiMemoryleak\Resources\AppIcon\appicon.svg'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions.
   at Microsoft.Maui.Resizetizer.SkiaSharpSvgTools.DrawUnscaled(SKCanvas canvas, Single scale) in /_/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs:line 41
   at Microsoft.Maui.Resizetizer.SkiaSharpTools.Draw(SKBitmap tempBitmap, Double additionalScale, SKSize originalSize, Single scale, SKSizeI scaledSize) in /_/src/SingleProject/Resizetizer/src/SkiaSharpTools.cs:line 201
   at Microsoft.Maui.Resizetizer.SkiaSharpTools.Resize(DpiPath dpi, String destination, Double additionalScale, Boolean dpiSizeIsAbsolute) in /_/src/SingleProject/Resizetizer/src/SkiaSharpTools.cs:line 127
   at Microsoft.Maui.Resizetizer.AndroidAdaptiveIconGenerator.ProcessBackground(List`1 results, DirectoryInfo fullIntermediateOutputPath) in /_/src/SingleProject/Resizetizer/src/AndroidAdaptiveIconGenerator.cs:line 84
   at Microsoft.Maui.Resizetizer.AndroidAdaptiveIconGenerator.Generate() in /_/src/SingleProject/Resizetizer/src/AndroidAdaptiveIconGenerator.cs:line 44
   at Microsoft.Maui.Resizetizer.ResizetizeImages.ProcessAppIcon(ResizeImageInfo img, ConcurrentBag`1 resizedImages) in /_/src/SingleProject/Resizetizer/src/ResizetizeImages.cs:line 179
   at Microsoft.Maui.Resizetizer.ResizetizeImages.<>c__DisplayClass34_0.<ExecuteAsync>b__0(ResizeImageInfo img) in /_/src/SingleProject/Resizetizer/src/ResizetizeImages.cs:line 66	MauiMemoryleak (net10.0-android)	C:\Users\3s\.nuget\packages\microsoft.maui.resizetizer\10.0.60\buildTransitive\Microsoft.Maui.Resizetizer.After.targets	633	

If I revert back to 10.0.51, the build works (this is the only difference between the build that works and the one that fails).
I think this is the cause: #33194
When I see the code changes on https://github.com/dotnet/maui/pull/33194/changes#diff-8f1fb2ce6396a186e797eb6f7f184f5b61e9afc6165f63bb102d566f68b91905 I think this is the correct fix:
(line 38-42 has to be moved to line 50 (so put it in the else))
Image

note this is a duplicate from #35247 but I was able to add a reproduceable scenario, so the other issue may be closed & marked as duplicate.

Steps to Reproduce

  1. build the project from https://github.com/3sRykaert/MauiMemoryleak/tree/EmptyAppicon
  2. Watch the build fails

Link to public reproduction project repository

https://github.com/3sRykaert/MauiMemoryleak/tree/EmptyAppicon

Version with bug

10.0.60

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

10.0.50

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Every Android version I tested (and I think all other platforms also)

Did you find any workaround?

2 options found:

  1. Revert back to older Maui versions
  2. Instead of an empty (but valid!) appicon, use one with 1 transparent pixel:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
</svg>

becomes

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
  <rect x="0" y="0" width="1" height="1" fill="transparent"/>
</svg>

Relevant log output

System.InvalidOperationException: Cannot draw SVG file 'C:\Projects\MauiMemoryleak\MauiMemoryleak\Resources\AppIcon\appicon.svg'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions.
   at Microsoft.Maui.Resizetizer.SkiaSharpSvgTools.DrawUnscaled(SKCanvas canvas, Single scale) in /_/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs:line 41

Metadata

Metadata

Assignees

No one assigned

    Labels

    i/regressionThis issue described a confirmed regression on a currently supported versionp/0Current heighest priority issues that we are targeting for a release.partner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androidregressed-in-10.0.60s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions