Skip to content

Geometry & Path WinUI parity for Skia: close all known gaps #23156

Closed

Description

@MartinZikmund

Summary

Close the gap between Uno Platform's Skia rendering of Microsoft.UI.Xaml.Media.Geometry / Microsoft.UI.Xaml.Shapes.Path and native WinUI 3. Investigation in branch dev/mazi/pending/geometry identified one app-breaking crash (#2228), several NotImplementedException cliffs in StreamGeometryContext, two missing static members on Geometry, an SVG path mini-language conformance bug, and a generator-metadata inconsistency on EllipseGeometry. This issue tracks all of them as one body of work.

A mid-investigation discovery: CombinedGeometry, GeometryCombineMode, Geometry.Combine, GetFlattenedPathGeometry, GetWidenedPathGeometry, FillContainsWithDetail, StrokeContains, GetRenderBounds, Pen, ToleranceType are WPF-only (System.Windows.Media) and do not exist in WinUI 3. They are explicitly out of scope for this work.

Scope decision: changes to the shared PathStreamGeometryContext are confined to the __SKIA__ #if branch; iOS/Android/WASM behavior is unchanged.

Root causes / gaps

Phase 1 — Critical Skia fixes (unblock real apps)

  1. ArcTo does not seems correctly supported for Path Data #2228 — SVG paths with elliptical arcs (rx ≠ ry) throw NotImplementedException. PathStreamGeometryContext.ArcTo rejected non-uniform radii and used a circle-only center-from-points-and-radius computation. SkiaSharp's SKPath.ArcTo(rx, ry, rotation, arcSize, direction, x, y) natively supports SVG-style elliptical arcs.
  2. StreamGeometryContext.PolyBezierTo and PolyQuadraticBezierTo throw NotImplementedException on Skia. Any code reaching StreamGeometry via those entry points crashes.
  3. GeometryHelper.Write(EllipseGeometry) is commented out due to historical iOS regression Support for EllipseGeometry #6849. EllipseGeometry → StreamGeometry conversion silently dropped the geometry on Skia.

Phase 2 — Real WinUI 3 surface gaps

  1. Geometry.Empty and Geometry.StandardFlatteningTolerance are [NotImplemented] stubs in Generated/3.0.0.0/Microsoft.UI.Xaml.Media/Geometry.cs. These are the only static members WinUI exposes on Geometry.
  2. PathGeometry.ComputeBounds and StreamGeometry.ComputeBounds were not overridden on Skia, so accessing Bounds threw the base NotImplementedException.

Phase 3 — SVG path mini-language fidelity

  1. PathMarkupParser smooth-curve reflection violates SVG spec. A single _previousControlPoint was shared across cubic and quadratic, and was never cleared by non-bezier commands. Result: S after Q (or L/H/V/M) reflected a stale control point. SVG spec says S/s reflect only after C/c/S/s and T/t reflect only after Q/q/T/t; otherwise the implicit control point coincides with the current point.

Phase 4 — Generator metadata inconsistency

  1. EllipseGeometry was annotated [Uno.NotImplemented] for __SKIA__ in the generated metadata file, even though EllipseGeometry.skia.cs rendered correctly via CompositionGeometry.BuildEllipseGeometry. Root cause: the DP declarations and constructor lived only in EllipseGeometry.Properties.wasm.cs, so the generator did not detect a hand-written partial covering Skia.

Phase 5 — Visual parity sample pages

  1. No side-by-side visual-parity coverage for Skia vs native WinUI rendering of the geometry surface.

Acceptance

  • All 41 runtime tests in Given_Path, Given_Geometry, Given_PathMarkupParser pass on Skia Desktop.
  • The pre-existing repro test Given_Path.When_Path_ArcTo_Multiple_Arcs_Does_Not_Throw (commit 73742f30a3) passes.
  • EllipseGeometry no longer carries [Uno.NotImplemented] for __SKIA__ in the generated metadata.
  • Seven Geometry_*_Showcase sample pages exist under src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/ and render without errors on Skia.

Test plan

  • Given_Path.When_Path_ArcTo_Multiple_Arcs_Does_Not_Throw (pre-existing) passes on Skia.
  • Given_Path.When_SvgPath_String_With_Elliptical_Arc_Parses (new) passes.
  • Given_Path.When_StreamGeometry_PolyBezierTo_Renders and When_StreamGeometry_PolyQuadraticBezierTo_Renders (new) pass.
  • Given_Path.When_EllipseGeometry_To_StreamGeometry_Round_Trips (new) passes.
  • Given_Geometry.EmptyGeometry_CheckBounds, Geometry_Empty_Is_Cached_Singleton, Geometry_StandardFlatteningTolerance_Is_QuarterPixel (new/updated) pass.
  • All 13 Given_PathMarkupParser tests pass (new file): linear commands, implicit-repeat after M, Z-then-command, S/T reflection both with and without matching prior segment, F0/F1.
  • Geometry_AllSegments_Showcase, Geometry_SimpleTypes_Showcase, Geometry_PathMarkup_Showcase, Geometry_Stroke_Showcase, Geometry_Transforms_Showcase, Geometry_GeometryGroup_FillRule_Showcase, Geometry_StreamGeometry_Showcase render on Skia and visually match native WinUI.
  • dotnet build src/Uno.UI/Uno.UI.Skia.csproj and dotnet build src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.Skia.csproj succeed with 0 errors.
  • dotnet build src/SamplesApp/SamplesApp.Skia.Generic/SamplesApp.Skia.Generic.csproj succeeds.
  • dotnet xstyler -d src/SamplesApp -r -p reports no formatting drift on the new XAML.

Out of scope

  • WPF-only APIs: CombinedGeometry, GeometryCombineMode, Geometry.Combine, GetFlattenedPathGeometry, GetWidenedPathGeometry, GetOutlinedPathGeometry, FillContainsWithDetail, StrokeContains, GetRenderBounds, GetArea, Pen, ToleranceType. None exist in Microsoft.UI.Xaml.Media.
  • iOS, Android, WASM branches of PathStreamGeometryContext.
  • Composition-level CompositionPathGeometry.SetSegmentFlags TODO at src/Uno.UI.Composition/Composition/CompositionPathGeometry.skia.cs:97 — not surfaced by any XAML API; defer.
  • Replacing the Avalonia-derived PathMarkupParser with a WinUI-faithful rewrite — only the divergence found above is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions