Repository navigation
Description
Current behavior 🐛
A freshly created CompositionSpriteShape reports StrokeMiterLimit == 0 on Uno. The backing field in CompositionSpriteShape has no initializer, so the default is 0f, and that value is passed straight to the Skia stroker (MiterLimit = StrokeMiterLimit in GetStrokeStyle).
Expected behavior 🎯
On WinUI / Windows App SDK a new sprite shape reports StrokeMiterLimit == 1. Microsoft Learn documents the value as "always a positive number that is greater than or equal to 1", so 0 is not a valid state for it.
The other stroke defaults already match (StrokeThickness=1, StrokeDashOffset=0, StrokeDashCap/StartCap/EndCap=Flat, StrokeLineJoin=Miter).
How to reproduce it (as minimally and precisely as possible) 🔬
- Create a Uno Skia Desktop app.
- Run:
var anchor = new Border { Width = 1, Height = 1 };
Content = anchor;
var compositor = ElementCompositionPreview.GetElementVisual(anchor).Compositor;
var shape = compositor.CreateSpriteShape();
Debug.WriteLine(shape.StrokeMiterLimit); // WinUI: 1, Uno: 0Verified with this runtime test on Skia Desktop (net11.0-desktop), which fails with Expected:<1>. Actual:<0>:
[TestMethod]
[RunsOnUIThread]
public async Task When_Default_StrokeMiterLimit()
{
var anchor = new Border { Width = 1, Height = 1 };
await UITestHelper.Load(anchor);
var compositor = ElementCompositionPreview.GetElementVisual(anchor).Compositor;
var shape = compositor.CreateSpriteShape();
Assert.AreEqual(1f, shape.StrokeMiterLimit);
}I did not check the rendered difference for a sharp-angle Miter join. The impact is expected from the value reaching the stroker, but that is not proven here.
Workaround 🛠️
Set shape.StrokeMiterLimit = 1f (or the value you want) explicitly.
Works on UWP/WinUI
Yes. The WinUI value comes from a runtime probe of compositor.CreateSpriteShape() on Windows App SDK 2.4 (StrokeMiterLimit=1). The Learn page for the property gives the >= 1 range but no explicit default, so the probe is the evidence for the default.
Affected platforms 📱💻🖥️
All platforms 🌍 (the property lives in the shared CompositionSpriteShape).
Uno.Sdk version (and other relevant versions) 📦
master at 0599dad (net11.0-desktop).
IDE version 🧑💻
N/A
Anything else we need to know? 💬
Root cause: the field has no initializer, unlike _strokeThickness, which defaults to 1.0f right above it.
| private float _strokeMiterLimit; |
Suggested fix: private float _strokeMiterLimit = 1.0f;, plus a runtime test like the one above. It should also be checked that the stroker treats a limit of 1 like WinUI for sharp-angle miter joins.
Related: the composition stroke default fixes in #25199, #25200 and #25202. #25202 notes the miter limit as a separate gap and does not change the default.
Activity