Skip to content

[SVG] TypeLoadException with Uno.Sdk 6.2.29: SVGs fail to render #21372

Closed
1 of 1 issue completed
unoplatform/uno.templates
#1753

Description

@agneszitte

Current behavior 🐛

After updating to Uno.Sdk 6.2.29 (or latest 6.3.0-dev vesions), SVG images no longer display, and the app logs a TypeLoadException from Uno.UI.Svg. The same sample project provided as an example works properly with Uno.Sdk 6.1.23.

fail: Uno.UI.Svg.SvgProvider[0]
      Failed to load SVG image.
      System.TypeLoadException: Method 'GetFontMetrics' in type 'Uno.Svg.Skia.SkiaAssetLoader' from assembly 'Uno.UI.Svg, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null' does not have an implementation.
         at Uno.Svg.Skia.SKSvg..ctor()
         at Uno.UI.Svg.SvgProvider.<>c__DisplayClass23_0.<LoadSvgAsync>b__0() in C:\a\1\s\src\AddIns\Uno.UI.Svg\SvgProvider.cs:line 165
         at System.Threading.Tasks.Task`1.InnerInvoke()
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
      --- End of stack trace from previous location ---
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
      --- End of stack trace from previous location ---
         at Uno.UI.Svg.SvgProvider.TryLoadSvgDataAsync(Byte[] svgBytes) in C:\a\1\s\src\AddIns\Uno.UI.Svg\SvgProvider.cs:line 119

Expected behavior 🎯

SVG renders properly even after 6.2.x or above version update.

How to reproduce it (as minimally and precisely as possible) 🔬

  • Create a new Uno Blank app, for example, with Uno.Sdk 6.2.29 (or latest 6.3.0-dev vesions)
  • Enable the Svg; UnoFeature in the ProjectName.csproj (following the SVG documentation)
  • Add an SVG file under Assets/Svg/ (e.g., Assets/Svg/logo.svg).
  • Add <Image Source="ms-appx:///Assets/Svg/logo.svg" /> in the StackPanel in MainPage.xaml

OR

Then:

  • Launch the app for any platform (e.g., Desktop)
  • Notice the System.TypeLoadException, and the SVG is not displayed using Uno.Sdk 6.2.29
    (Compare using Uno.Sdk 6.1.23 and notice no exception, and the SVG logo is properly displayed.)

Workaround 🛠️

Override the Svg.Skia version to 3.0.3 by adding <SvgSkiaVersion>3.0.3</SvgSkiaVersion> to your ProjectName.csproj.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

All platforms 🌍

Uno.Sdk version (and other relevant versions) 📦

6.2.29, 6.3.0-dev latest versions

IDE version 🧑‍💻

VS 2022 - 17.14.13

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    triage/untriaged
    difficulty/tbd
    on Aug 28, 2025
  2. added theissue type on Aug 28, 2025
  3. changed the title [-][SVG] TypeLoadException with Uno.Sdk 6.2.29: SkiaAssetLoader.GetFontMetrics missing implementation → SVGs don’t render[/-] [+]SVG] TypeLoadException with Uno.Sdk 6.2.29: SVGs fail to render[/+] on Aug 28, 2025
  4. changed the title [-]SVG] TypeLoadException with Uno.Sdk 6.2.29: SVGs fail to render[/-] [+][SVG] TypeLoadException with Uno.Sdk 6.2.29: SVGs fail to render[/+] on Aug 28, 2025
  5. agneszitte commented on Aug 28, 2025

    @agneszitte
    MemberAuthor

    This issue seems related to the Svg.Skia version used by the Templates/SDK.

    • Uno.Sdk 6.1.23 is using Svg.Skia version 3.0.3
    • Uno.Sdk 6.2.29 is using Svg.Skia version 3.0.5

    When overriding the Svg.Skia version here are the results:

    • ✅ Version 3.0.3: No exceptions
    • ❌ Version 3.0.4: System.TypeLoadException (and even started with 3.0.4-beta.1)
    • ❌ Version 3.0.5: System.TypeLoadException
    • ❌ Version 3.0.6: System.TypeLoadException
  6. agneszitte commented on Aug 28, 2025

    @agneszitte
    MemberAuthor

    Digging further, here is a summary of the details:

    • This issue started with Svg.Skia PR – "Use SKIA text metrics" : Use SKIA text metrics wieslawsoltes/Svg.Skia#318

      Starting with Svg.Skia 3.0.4-beta.1, the ISvgAssetLoader interface gained two new methods:

      • GetFontMetrics(SKPaint paint)
      • MeasureText(string? text, SKPaint paint, ref SKRect bounds)
    • In Svg.Skia 3.0.4-beta.2, an additional method was introduced (Add text path conversion wieslawsoltes/Svg.Skia#326):

      • GetTextPath(string? text, SKPaint paint, float x, float y)
    • Uno’s current SkiaAssetLoader only implements LoadImage and FindTypefaces.
      When running against Svg.Skia 3.0.4 or later, these new methods are missing, which leads to a TypeLoadException.

    Impact

    • ✅ Works with Svg.Skia 3.0.3 (last version before the interface change)
    • ❌ Fails with Svg.Skia 3.0.4, 3.0.5, 3.0.6 (missing GetFontMetrics / MeasureText / GetTextPath)

    What this means for Uno

    • Quick Workaround:
      Override the Svg.Skia version to 3.0.3 by adding <SvgSkiaVersion>3.0.3</SvgSkiaVersion> to your ProjectName.csproj.
    • Short-term solution:
      Templates/SDK should constrain to Svg.Skia 3.0.3 to avoid breaking new apps.
    • Long-term solution:
      Update Uno’s SkiaAssetLoader to implement the new APIs (GetFontMetrics, MeasureText, and GetTextPath) so it works with Svg.Skia ≥ 3.0.4.
  7. self-assigned this
    on Aug 28, 2025
  8. agneszitte commented on Aug 28, 2025

    @agneszitte
    MemberAuthor

    Final details and next steps ✅

  9. MartinZikmund commented on Sep 3, 2025

    @MartinZikmund
    Member

    @agneszitte the update of Svg.Skia was merged in master

  10. khaskoul commented on Sep 8, 2025

    @khaskoul

    Fixed with latest SDK version 6.2.36
    Tested with:
    Templates/SDK: 6.2.36
    Platform(s): Desktop
    IDE: Rider 2025.2, VS Code 1.102.3
    OS: Linux

  11. jhanvi03 commented on Sep 8, 2025

    @jhanvi03

    Issue resolved in latest sdk/template 6.2.36 svg image is visible on all TFMs

    tested with:
    Sdk/Template: 6.2.36
    OD: Mac, Windows
    IDE: Rider, VS
    TFMs: All

    Snapshots

    Desktop:
    Image

    Image

    WebAssembly:

    Image Image

    Android

    Image Image

    iOS:

    Image Image

  12. agneszitte commented on Sep 8, 2025

    @agneszitte
    MemberAuthor

    Fix available with 6.2.36

  13. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  14. locked as resolved and limited conversation to collaborators on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/tbdtriage/untriaged

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions