fix: PolyLineSegment not rendering on Skia backend#22757
fix: PolyLineSegment not rendering on Skia backend#22757
Conversation
…priteShape Co-authored-by: MartinZikmund <1075116+MartinZikmund@users.noreply.github.com>
|
@copilot add runtime test coverage |
…9957) Co-authored-by: MartinZikmund <1075116+MartinZikmund@users.noreply.github.com>
Added |
|
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22757/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22757/wasm-skia-net9/index.html |
|
The build 199072 found UI Test snapshots differences: Details
|
|
|
There was a problem hiding this comment.
Pull request overview
Fixes Skia rendering of stroke-only PathGeometry segments (e.g., PolyLineSegment after the first segment) by balancing the canvas save/restore stack around stroke clipping, and adds a runtime test to prevent regressions.
Changes:
- Balance Skia stroke rendering clip state by adding a missing
Canvas.Save()beforeClipPath(). - Add a runtime screenshot test validating that both
LineSegmentand subsequentPolyLineSegmentportions render when stroked.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI.Composition/Composition/CompositionSpriteShape.skia.cs | Fixes unbalanced Skia canvas state management in the stroke paint path by adding Save() before ClipPath(). |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Shapes/Given_Path.cs | Adds a regression runtime test ensuring stroked PolyLineSegment points render (Skia + WinUI). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22757/wasm-skia-net9/index.html |
PolyLineSegment(and any stroke-only path segment beyond the first) was silently dropped on the Skia backend. APathGeometrywith aLineSegmentfollowed by aPolyLineSegmentwould only render theLineSegment.Root cause
In
CompositionSpriteShape.Paint()(Skia), the stroke rendering block appliedClipPath→Paint→Restorewithout a matchingSave. The fill block correctly wrapped its clip in aSave/Restorepair, but the stroke block was missing theSave.With no prior
Save, theRestorecall either popped the wrong level from the enclosing canvas save-stack (corrupting clip/transform state for the recorded picture during playback) or was a no-op, leaving a persistent clip that affected subsequent rendering. Either way, stroke-only shapes rendered incorrectly.Fix
CompositionSpriteShape.skia.cs: Addsession.Canvas.Save()immediately beforesession.Canvas.ClipPath(strokeFillPath, …)in the stroke block, matching the established pattern in the fill block.PR Type:
What is the current behavior? 🤔
PolyLineSegmentsegments in aPathGeometrydo not render on the Skia (desktop) backend. Only the first segment (LineSegment) is visible.What is the new behavior? 🚀
All segments in a
PathGeometry—includingPolyLineSegment—render correctly on Skia, matching WinUI behavior.PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️
The
CompositionSpriteShape.Paintfill block already had the correctSave/Restorepattern. The stroke block was simply missing theSave, which is a one-line addition.A runtime test
When_PolyLineSegment_Is_Stroked_Renders_All_Pointshas been added toGiven_Path.cs. It builds a stroke-onlyPathGeometrywith aLineSegmentfollowed by aPolyLineSegment(the exact scenario from the issue), takes a screenshot, and asserts that pixels along both theLineSegmentandPolyLineSegmentportions are rendered with the stroke color. The test runs on Skia and WinUI.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.