Repository navigation
fix(composition): Match WinUI dash and trim semantics - #25202
Conversation
|
Claude finished @MartinZikmund's task in 20s —— View job Review of #25202Verdict: ship. I found no blocking issues and posted no inline comments. I reviewed this by reading the diff, and I did not build or run any tests. The PR describes runtime results on Skia desktop that I have not reproduced. Findings by severity: 0 blocking, 0 major, 2 minor (below). What I checked:
Minor, non-blocking:
Process notes: commit messages follow Conventional Commits, and no new warnings or |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25202/wasm-skia-net9/index.html |
|
The build 238853 found UI Test snapshots differences: Details
|
|
|
|
Claude finished @MartinZikmund's task in 19s —— View job Review of #25202Verdict: ship. I found no blocking issues and posted no inline comments. I read the current Findings: 0 blocking, 0 major, 2 minor.
CI. The Uno.UI CI build failed, and the screenshot diffs are large: 118 on Linux and 2458 of 2486 on Windows. A change this narrow shouldn't alter nearly every sample, so the Windows number looks like a baseline or infrastructure problem. Please check the build failure and the screenshot comparison before merging. I didn't investigate the failed build log. The unchecked docs and screenshot-compare checklist items are yours to confirm. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25202/wasm-skia-net9/index.html |
|
The build 238892 found UI Test snapshots differences: Details
|
|
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Verified the XAML side against the WinUI source (microsoft-ui-xaml @188f602b2). The rest is not verifiable from this repo.
Matches WinUI source:
- XAML
EllipseGeometrystarts at 3 o'clock and winds clockwise:CEllipseGeometry::VisitSinkInternal(dxaml/xcp/core/core/elements/ellipse.cpp, lines 401-448). The newEllipseFigureStart.Rightmatches.Ellipsealready gets 3 o'clock from its Skia oval path. - XAML rounded
Rectanglestarts at the top-left arc:CRectangleGeometry::VisitSinkInternalbegins at (X, Y + radiusY) (rectangle.cpp, around lines 850-860).startAtTopLeftArc: truematches. Plain rectangles still start at (X, Y), as in WinUI. - XAML dashes scale by the declared thickness:
CDasher::CDashSequence::Setmultiplies dashes and offset by the pen width (strokefigure.cpp, lines 2291-2300). The pen width is the rawStrokeThickness(shape.cpp, line 29). TheShape.cschange (array and offset timesStrokeThickness) matches. TheUnicodeTextchange keeps decoration output the same. - Composition dash units are absolute:
CShape::PopulateCompositionSpriteShape(shape.cpp, around lines 1667-1676) multiplies the XAML array by thickness before handing it to composition, which only makes sense if composition takes absolute lengths. The ground-truth table'scomp-dash-t6-o5row shows the same thing for the offset. - The WUC shapes path is not what ships.
Feature_WUCShapes::IsEnabled()returns false in this snapshot (dxaml/xcp/inc/FeatureFlags.h, lines 75-82), andUseWUCShapesis true only for test modes. So shipping XAML shapes go through the softwareCDasherpath. That resolves the discrepancy the PR notes:PopulateCompositionSpriteShapepasses the raw offset, which does not affect shipping builds. Caveat: this snapshot may be older than the WinAppSDK 2.4 used for the ground truth.
Not verifiable from this repo (the composition engine ships in the OS; microsoft-ui-xaml has only forward declarations): TrimEnd default 1, trim wrapping, trim-first-then-dash, the dash origin of CompositionEllipseGeometry (9 o'clock) and of CompositionRoundedRectangleGeometry (top-left arc), and the out-of-range ArgumentException. These rest on the PR's runtime probes. I could not reproduce them.
Validation: code review only. I did not build, and I did not run the new runtime tests or the pixel comparisons.
Findings, most severe first:
-
A test's expected coordinates are probably wrong (medium).
When_Rectangle_Rounded_Dashed_Then_Pattern_Starts_At_Top_Left_Arc(When_Shape.cs) assumes the 84pxRectangleis centred in the 100pxGrid, which puts the arc start at (10, 30). ARectanglewith explicit Width and Height and default Stretch alignment sits at the origin, which puts the arc start near (2, 22). With that placement, the sample points (10, 27) and (33, 10) fall outside the dash. Please setHorizontalAlignmentandVerticalAlignmentto Center, or correct the coordinates, and confirm the test fails on master and passes after. -
The composition-level semantics rest on probes alone (medium, validation gap). The PR table gives only percentages. Please attach the probe output, or the WinAppSDK and Uno images, for the composition scenes: the 9 o'clock ellipse origin, the rounded-rect origin, trim wrapping, and the TrimEnd default. Without them, reviewers cannot check these against WinUI.
-
Full-window trim with an offset (low, question).
TryResolveTrimtreats any window withTrimEnd - TrimStart >= 1as untrimmed, ignoringTrimOffset. If WinUI's trim-first semantics start the dash pattern at the offset point for a full window, this differs. Did the probes cover a full window with a non-zero offset? If not, add a row. -
Per-paint cost (low, question). Dashed strokes now measure at 16x device scale (
SkiaGeometrySource2D.Stroke.cs,DashMeasureResolution). Trimmed dashed strokes also computePathLengthand a union for wrapped windows. Neither is cached:GetTrimmedStrokeGeometryruns on every paint. The untrimmed branch also callsdashSource.Transform(_geometryTransform)on every paint, which allocates. Caching it next to_geometryWithTransformationswould avoid that. Please measure a dashed, Lottie-heavy scene, or say why the cost is acceptable. -
Contract change (note).
StrokeStyle.DashArrayandDashOffsetare now absolute. I found no caller in the composition orUno.UIsource trees that still passes multiples of thickness;ManagedSvg,UnicodeTextandShapewere all updated. The breaking-change note is accurate.
WinUI Composition dash intervals and offset are in geometry units; only XAML Shape.StrokeDashArray/StrokeDashOffset are multiples of StrokeThickness. The strokers now take absolute values, Shape and the text decoration dashes scale by thickness themselves, and ManagedSvg no longer divides to compensate. Fixes #25199 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Composition dashes are absolute; XAML Shape dashes stay relative to StrokeThickness and follow thickness changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
WinUI reports TrimEnd = 1 at runtime (the docs say 0). Untrimmed now means the window covers the whole path, so an explicit TrimEnd = 0 (or any empty window) draws nothing instead of the full path. Fixes #25200 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
WinUI wraps a trim window whose start is past its end through the path origin even when TrimOffset is 0, and throws ArgumentException for a TrimStart/TrimEnd outside [0, 1]. Animated values are clamped instead. Refs #25200 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Skia summed the dash and trim effects, drawing the full dashed path plus a solid trimmed one. WinUI trims first and dashes what is left, the pattern starting at the trim start and running on across a wrap. Refs #25199 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
WinUI trims a CompositionEllipseGeometry from 12 o'clock but starts its dash pattern at 9 o'clock, and starts a rounded rectangle's pattern where the top-left arc begins. Untrimmed dashed strokes now use a path that starts there. Skia also measures dashed curves at a finer resolution, as the default one comes out short on small arcs and shifts the pattern. Refs #25199 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
XAML dashes scale by the declared StrokeThickness, not the layout-rounded one. EllipseGeometry starts at 3 o'clock and a rounded Rectangle where its top-left arc begins, as on WinUI, which is where dashes start. The managed backend still recognises that rounded rectangle analytically. Refs #25199 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
422c312 to
d1d5380
Compare
|
Claude finished @MartinZikmund's task in 21s —— View job Review of #25202 (update after new commits)Verdict: ship, with one open question for the author. I found no blocking issues. I read the diff only. I did not build or run tests, so the runtime and pixel-diff results in the PR description are unverified by me. Findings: 0 blocking, 0 major, 2 minor. Trim resolution. Dashed and trimmed strokes. Earlier review comment on the rounded-rectangle test. An earlier review said Minor, non-blocking
Open question for the author: Do the WinUI probes cover a full trim window ( Not verified
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25202/wasm-skia-net9/index.html |
|
The build 239524 found UI Test snapshots differences: Details
|
GitHub Issue: closes #25199, closes #25200
PR Type:
🐞 Bugfix
What changed? 🚀
This PR makes Composition (and XAML Shape) dashes and trims match real WinUI. Every behaviour was checked against a WinAppSDK 2.4 app: the same scenes rendered on WinUI and on Uno at identical sizes, then pixel-diffed (see the ground-truth table below). The work started from LottieGen output, which renders differently on Uno than on WinUI.
Dashes (#25199)
StrokeDashArray/StrokeDashOffsetare absolute in Composition.StrokeThickness, which is the XAMLShapeconvention.Shapeand the text decoration dashes scale by thickness themselves, andManagedSvgno longer divides to compensate. Skia also repeats an odd-length list.StrokeThickness.StrokeThickness="1"dash came out 1.2× too long.PopulateCompositionSpriteShapeandCDasher::CDashSequence::Setboth use the raw thickness.CompositionEllipseGeometryfrom 12 o'clock, but starts its dash pattern at 9 o'clock.CompositionRoundedRectangleGeometry, trims start where the top-left arc ends; dashes start where it begins.EllipseGeometrystarts at 3 o'clock (CEllipseGeometry::VisitSinkInternal), and a rounded XAMLRectangleat its top-left arc.GetFillPath(..., resScale)at 16× the device scale.Trims (#25200)
TrimEnddefaults to 1.TrimStart=0, TrimEnd=1, TrimOffset=0for every geometry type. The Microsoft Learn page saysTrimEnddefaults to 0, which is wrong.TrimEnd = 0(a LottieGen draw-on at frame 0) draws nothing instead of everything.TrimStart > TrimEnd, WinUI draws through the origin even withoutTrimOffset. Uno drew nothing.ArgumentException("Value must be in the range of 0.0f to 1.0f") forTrimStart/TrimEndoutside [0, 1]. Uno now does the same in the setters and clamps animated values.WinUI ground truth
Scenes were rendered on WinAppSDK 2.4 and on Uno (Skia desktop, 250% scale) in 120×120 cells.
masterfor these files.Values are the % of pixels with no match within 1px (max channel diff ≤ 40) in the other image. This tolerates antialiasing; an untrimmed ring measures 0.11% against WinUI.
Composition ellipse r=44 with dashes
{4, 14}, plus other shapes. XAML cells use dashes"4 14"unless noted.comp-dash-t1-o0-Flatcomp-dash-t1-o0-Roundcomp-dash-t1-o0-Squarecomp-dash-t1-o5-Flatcomp-dash-t1-o5-Roundcomp-dash-t1-o5-Squarecomp-dash-t6-o0-Flatcomp-dash-t6-o0-Roundcomp-dash-t6-o0-Squarecomp-dash-t6-o5-Flatcomp-dash-t6-o5-Roundcomp-dash-t6-o5-Squarecomp-dash-t12-o0-Flatcomp-dash-t12-o0-Roundcomp-dash-t12-o0-Squarecomp-dash-t12-o5-Flatcomp-dash-t12-o5-Roundcomp-dash-t12-o5-Squarecomp-dash-rect-t6comp-dash-rrect-t6comp-dash-line-t6comp-dash-trim-0.1-0.6comp-dash-trim-0-0.5-o0.3comp-dash-oval-t6comp-dash-rrect-t6-o9comp-trim-rrect-0-0.25comp-trim-0.9-0.1-0comp-trim-0.2-1.2-0comp-trim-neg0.2-0.3-0comp-trim-defaultcomp-trim-0-0-0comp-trim-0-1-0comp-trim-0.25-0.25-0comp-trim-0.8-0.2-0comp-trim-0-0.25-0.5comp-trim-0.6-0.9-0.5comp-trim-0-0-0.5comp-trim-start0.5-onlycomp-trim-0.25-0.75-0comp-trim-rect-0-0.25comp-trim-anim-end-to-0comp-trim-anim-end-to-0.5xaml-ellipse-t1-o0xaml-ellipse-t1-o0.5xaml-ellipse-t6-o0xaml-ellipse-t6-o0.5xaml-ellipse-t12-o0xaml-ellipse-t12-o0.5xaml-ellipse-t6-Roundxaml-ellipse-t6-Squarexaml-path-t6xaml-rect-radius-t3xaml-path-oval-t3xaml-line-t6-solidxaml-rect-radius-t3-solidxaml-line-t6-o0.5Remaining XAML residuals:
xaml-rect-radius-t3(0.50%): its solid controlxaml-rect-radius-t3-soliddiffers more (1.29%) and equally before and after. The cause is not dashes: Uno insets and strokes by the layout-rounded thickness (3 → 3.2 at 250%), whereas WinUI'sCShape::GetOutlineRectuses the raw thickness. Out of scope here.xaml-line-t6-o0.5(0.19%): matches its solid controlxaml-line-t6-solid(0.28%). It's a one-pixel row of stroke placement.Runtime-probed WinUI defaults:
TrimStart=0 TrimEnd=1 TrimOffset=0CompositionSpriteShape:StrokeDashCap=Flat,StrokeMiterLimit=1. Uno reports 0 for the miter limit, which is a separate gap.WinUI source vs runtime:
CShape::PopulateCompositionSpriteShape(shape.cpp) passesStrokeDashOffsetunscaled. At runtime, though, XAML dash offsets are scaled by thickness (thexaml-ellipse-*-o0.5cells only match that way), so that WUC shapes path isn't what renders today.LottieGen: same generated class on Uno vs WinUI
Same metric. The sunrise animation is the original dashed one.
{4,14}Tests
Runtime tests, run on Skia desktop. Each fails on the commit before its fix and passes after:
Given_CompositionSpriteShape:When_StrokeDashArray_Then_Absolute_Units(2 rows)When_Dashed_And_Trimmed_Then_Dashes_Start_At_TrimWhen_Ellipse_Dashed_Then_Pattern_Starts_At_Nine_OClockWhen_RoundedRectangle_Dashed_Then_Pattern_Starts_At_Top_Left_ArcGiven_CompositionGeometry:When_Default_Trim_ValuesWhen_Only_TrimStart_Set_Then_Draws_To_EndWhen_Trim_Window_Is_Empty_Then_Nothing_DrawnWhen_TrimStart_Greater_Than_TrimEnd_Then_WrapsWhen_Trim_Out_Of_Range_Then_ThrowsWhen_Shape:When_StrokeThickness_Fractional_Then_Dashes_Use_Declared_ThicknessWhen_EllipseGeometry_Dashed_Then_Pattern_Starts_At_Three_OClockWhen_Rectangle_Rounded_Dashed_Then_Pattern_Starts_At_Top_Left_ArcWhen_StrokeDashArray_Then_Relative_To_StrokeThickness(a guard that also passes before)Regression runs, all green except 4 pre-existing failures:
Given_Rectangle.When_StrokeThickness_Is_GreaterThan_Or_Equals_Widthhas 4 rows that fail identically onmasterat 250% scale.ProgressRing,AnimatedVisuals,AnimatedVisualPlayer,Given_SvgImageSource_ManagedEngine,Given_TextBlock_TextDecorations, the RichEditBox underline styles,Given_Border,Given_Geometry: 146 passed, 0 failed.PR Checklist ✅
Screenshots Compare Test Runresults.Code that relied on Uno-only behaviour will render differently: thickness-relative Composition dashes,
TrimEnddefaulting to 0, or out-of-range trims being accepted. All of these now match WinUI.🤖 Generated with Claude Code
https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7