Repository navigation
Description
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)
ArcTodoes not seems correctly supported for Path Data #2228 — SVG paths with elliptical arcs (rx ≠ ry) throwNotImplementedException.PathStreamGeometryContext.ArcTorejected non-uniform radii and used a circle-only center-from-points-and-radius computation. SkiaSharp'sSKPath.ArcTo(rx, ry, rotation, arcSize, direction, x, y)natively supports SVG-style elliptical arcs.StreamGeometryContext.PolyBezierToandPolyQuadraticBezierTothrowNotImplementedExceptionon Skia. Any code reachingStreamGeometryvia those entry points crashes.GeometryHelper.Write(EllipseGeometry)is commented out due to historical iOS regression Support forEllipseGeometry#6849.EllipseGeometry → StreamGeometryconversion silently dropped the geometry on Skia.
Phase 2 — Real WinUI 3 surface gaps
Geometry.EmptyandGeometry.StandardFlatteningToleranceare[NotImplemented]stubs inGenerated/3.0.0.0/Microsoft.UI.Xaml.Media/Geometry.cs. These are the only static members WinUI exposes onGeometry.PathGeometry.ComputeBoundsandStreamGeometry.ComputeBoundswere not overridden on Skia, so accessingBoundsthrew the baseNotImplementedException.
Phase 3 — SVG path mini-language fidelity
PathMarkupParsersmooth-curve reflection violates SVG spec. A single_previousControlPointwas shared across cubic and quadratic, and was never cleared by non-bezier commands. Result:SafterQ(orL/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
EllipseGeometrywas annotated[Uno.NotImplemented]for__SKIA__in the generated metadata file, even thoughEllipseGeometry.skia.csrendered correctly viaCompositionGeometry.BuildEllipseGeometry. Root cause: the DP declarations and constructor lived only inEllipseGeometry.Properties.wasm.cs, so the generator did not detect a hand-written partial covering Skia.
Phase 5 — Visual parity sample pages
- 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_PathMarkupParserpass on Skia Desktop. - The pre-existing repro test
Given_Path.When_Path_ArcTo_Multiple_Arcs_Does_Not_Throw(commit73742f30a3) passes. EllipseGeometryno longer carries[Uno.NotImplemented]for__SKIA__in the generated metadata.- Seven
Geometry_*_Showcasesample pages exist undersrc/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_RendersandWhen_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_PathMarkupParsertests pass (new file): linear commands, implicit-repeat afterM,Z-then-command,S/Treflection 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_Showcaserender on Skia and visually match native WinUI. -
dotnet build src/Uno.UI/Uno.UI.Skia.csprojanddotnet build src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.Skia.csprojsucceed with 0 errors. -
dotnet build src/SamplesApp/SamplesApp.Skia.Generic/SamplesApp.Skia.Generic.csprojsucceeds. -
dotnet xstyler -d src/SamplesApp -r -preports 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 inMicrosoft.UI.Xaml.Media. - iOS, Android, WASM branches of
PathStreamGeometryContext. - Composition-level
CompositionPathGeometry.SetSegmentFlagsTODO atsrc/Uno.UI.Composition/Composition/CompositionPathGeometry.skia.cs:97— not surfaced by any XAML API; defer. - Replacing the Avalonia-derived
PathMarkupParserwith a WinUI-faithful rewrite — only the divergence found above is fixed.
Activity