Skip to content

Paths in a Canvas not rendering correctly #4563

Closed

Description

@mikernet

Current behavior

The rendering of the path objects is not done correctly in WASM (untested on other platforms). It looks like this:

image

Expected behavior

It should render the same as UWP, i.e. like this:

image

How to reproduce it

Create a user control with the following XAML content:

<UserControl
    x:Class="iRatio.Client.Icon"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <Grid>
        <Viewbox>
            <Canvas Name="layer1" Width="53" Height="53">
                <Canvas Name="g958">
                    <Canvas.RenderTransform>
                        <MatrixTransform Matrix="1.1048446, 0, 0, 1.1959561, -67.035883, -96.098854"/>
                    </Canvas.RenderTransform>
                    <Canvas Name="g920">
                        <Canvas.RenderTransform>
                            <TranslateTransform X="3.6170566" Y="26.121871"/>
                        </Canvas.RenderTransform>
                        <Path Name="path882" Fill="#FFFFFFFF" Data="m 89.844925 86.908932 -5.484915 -9.50015 -5.484913 -9.500149 10.969828 -10e-7 10.969825 0 -5.484911 9.50015 z">
                            <Path.RenderTransform>
                                <MatrixTransform Matrix="0.99974084, 0, 0, 1.0590767, 0.02096173, -5.1400261"/>
                            </Path.RenderTransform>
                        </Path>
                        <Path Name="path8822" Fill="#FFFFFFFF" Data="m 71.890129 -67.818339 -5.484914 -9.500151 -5.484915 -9.50015 10.969829 0 10.969829 -10e-7 -5.484915 9.500151 z">
                            <Path.RenderTransform>
                                <MatrixTransform Matrix="0.99974084, 0, 0, -1.0590767, 0.02096173, -5.0997423"/>
                            </Path.RenderTransform>
                        </Path>
                    </Canvas>
                    <Rectangle Canvas.Left="68.170586" Canvas.Top="85.901428" Width="38.119644" Height="2.9399648" Name="rect9016" Fill="#FFFFFFFF"/>
                    <Rectangle Canvas.Left="62.953873" Canvas.Top="117.08479" Width="38.119358" Height="2.9422779" Name="rect90161" Fill="#FFFFFFFF"/>
                </Canvas>
            </Canvas>
        </Viewbox>
    </Grid>
</UserControl>

Environment

Nuget Package:

  • Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Other:

Nuget Package Version(s):

Uno.UI.WebAssembly: v3.3.0

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • Visual Studio 2019 (version: 16.8)
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Activity

  1. added
    kind/bug
    triage/untriaged
    on Nov 19, 2020
  2. added
    project/shapes-brushes 🔶
    and removed
    triage/untriaged
    on Nov 19, 2020
  3. jeromelaban commented on Nov 19, 2020

    @jeromelaban
    Member

    Note for contributors

    Here's a playground sample: https://playground.platform.uno/#9e419e77

    The second shape does not appear, yet is present in the DOM.

    Update: There are issues:

    • The second path is provided directly to the browser SVG path element, and m 71.890129 -67.818339 -5.484914 -9.500151 -5.484915 -9.50015 10.969829 0 10.969829 -10e-7 -5.484915 9.500151 z does not show anything useful. Could be related to a difference in interpretation of the XAML path spec and the SVG path spec.
    • Nesting Canvas controls is behaving incorrectly, this could be related to the measuring of canvas elements.
  4. mikernet commented on Nov 20, 2020

    @mikernet
    ContributorAuthor

    The two rectangles on the bottom are also not rendering and they seem to be lacking any spacial info in the DOM such as width, height, or coordinates within the Canvas for some reason.

  5. jeromelaban commented on Nov 20, 2020

    @jeromelaban
    Member

    @mikernet as a workaround for this issue, can you merge all the layers into one path ? Also, how did you create this Xaml ?

  6. mikernet commented on Nov 20, 2020

    @mikernet
    ContributorAuthor

    We generate XAML from our SVG files using Inkscape. There's a lot of them and some are more complex than others. I don't know enough about path syntax at the moment to be hand manipulating them and I imagine the various transforms might make that a bit of a challenge.

  7. jeromelaban commented on Nov 20, 2020

    @jeromelaban
    Member

    Thanks, this will help reproducing those issues.

  8. jeromelaban commented on Nov 20, 2020

    @jeromelaban
    Member

    Note that you can use SVG directly for Wasm and UWP now.

  9. mikernet commented on Nov 20, 2020

    @mikernet
    ContributorAuthor

    Using the SVG file directly was a horrible fail so I don't know what's going on there, renders it entirely wrong in UWP.

    EDIT: Seems that a lot of people have issues with UWPs SVG renderer so I'm not going to hold my breath there, haha.

  10. mikernet commented on Nov 21, 2020

    @mikernet
    ContributorAuthor

    There are obviously still underlying issues that need to be resolved, but with the motivation of @jeromelaban 's suggestion to merge layers into one path, I played around with Inkscape to see what I could do. This works to merge simple one-color SVG icons in Inkscape into a single path that renders correctly:

    1. Select all the shapes that make up the icon
    2. Path => Object To Path, just to make sure they are all paths (and not something else like rectangles)
    3. Path => Union, to combine them all into a single path
    4. Path => Simplify, to reduce transforms and layers and such into the simplest possible representation

    When I exported that to XAML, the above user control could be reduced to this, which renders just fine:

    <UserControl
        x:Class="iRatio.Client.Icon"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="100"
        d:DesignWidth="100">
    
        <Grid>
            <Viewbox>
                <Canvas Name="g958" Opacity="1" Width="53" Height="53">
                    <Canvas.RenderTransform>
                        <MatrixTransform Matrix="1.1048446, 0, 0, 1.1959561, -67.035883, -96.098854"/>
                    </Canvas.RenderTransform>
                    <Path Name="path882" Fill="#FFFFFFFF" StrokeThickness="0.430069" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="m 68.170731 85.901237 c 0 0.979987 0 1.959974 0 2.939961 12.706551 0 25.413101 0 38.119649 0 0 -0.979987 0 -1.959974 0 -2.939961 -12.706548 0 -25.413098 0 -38.119649 0 z m 7.338618 6.945895 c -3.655394 6.707615 -7.310983 13.415138 -10.966767 20.122578 7.311334 0 14.622668 0 21.934002 0 -3.655745 -6.70753 -7.311489 -13.415054 -10.967235 -20.122578 z m 6.983146 0.05531 c 3.655746 6.707525 7.311492 13.415048 10.967236 20.122568 3.655782 -6.70743 7.311369 -13.414954 10.966769 -20.122568 -7.311337 0 -14.622671 0 -21.934005 0 z M 62.953718 117.08496 c 0 0.98071 0 1.96141 0 2.94212 12.706551 0 25.413102 0 38.119652 0 0 -0.98071 0 -1.96141 0 -2.94212 -12.70655 0 -25.413101 0 -38.119652 0 z"/>
                </Canvas>
            </Viewbox>
        </Grid>
    </UserControl>
  11. added
    difficulty/tbd
    on Feb 15, 2021
  12. added
    difficulty/medium 🤔
    and removed
    difficulty/tbd
    on Jun 7, 2021
  13. 7 remaining items

  14. added theissue type on Jul 17, 2025
  15. MartinZikmund commented on Apr 7, 2026

    @MartinZikmund
    Member

    Repro generator

    Runtime test(s) added in branch dev/mazi/repro/4563:

    • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Shapes/Given_Path.cs → When_Paths_In_Canvas_With_MatrixTransform_Render_Without_Exception

    ⚠️ The test(s) pass on current master (Skia Desktop) — paths in nested Canvases with MatrixTransform and TranslateTransform render without exceptions and have non-zero size. The original visual mismatch was on WASM (DOM-based rendering path). The branch provides a regression guard for the Skia path and ensures the XAML structure parses correctly.

  16. morning4coffe-dev commented on May 31, 2026

    @morning4coffe-dev
    Member

    Seems to be fixed with the referenced changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/medium 🤔has-repro-branchkind/bugplatform/wasm 🌐project/shapes-brushes 🔶

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions