Repository navigation
Description
Current behavior 🐛
On the Uno 6.x Skia renderers (release/stable/6.7 and servicing/6.8), the per-frame damage region is accumulated with SKPath.Op(..., SKPathOp.Union, ...):
DamageRegion.Union(SKPath):_exact.Op(addition, SKPathOp.Union, _exact)DamageRegion.SnapshotAndReset:destination.Op(_exact, SKPathOp.Union, destination)and the clampIntersect
The return value of Op is ignored. Skia's PathOps can return true with a wrong union: when two contours have near-coincident edges (for example x = 536.2001 and x = 536.19995), it keeps both overlapping contours and marks the result EvenOdd, so the overlap cancels into a hole. Any area dropped this way is excluded from the present clip, so it is never repainted and whatever was drawn there last stays on screen.
Observed symptom: a Path that moves (Canvas.SetLeft each frame) and changes geometry in the same frames (a Pac-Man-style mouth animation) leaves thin stale slivers (1-9 px wide, 50-66 px tall) and wedges of the old shape behind. It is intermittent because the geometry depends on frame timing: on Skia desktop Win32 at 250% scale with the software backend, 15 of 22 six-second runs left 2-934 clearly wrong device pixels, and 7 runs left none. The OpenGL backend is affected too, so this is not a GPU clip issue. Replacing only this union with an exact device-pixel SKRegion union removed the symptom in 6/6 runs (unpatched: 4/6 runs with stale pixels).
What was verified how: the app-level symptom was observed at runtime on Uno 6.7.103. The branch heads were confirmed by source inspection only (same accumulation code). The PathOps defect itself is confirmed at runtime with the standalone repro below.
master is not affected. The damage region there is built from rect bookkeeping without path booleans (DamageRegion.skia.cs). This issue is about the 6.7 / 6.8 servicing branches.
Expected behavior 🎯
The accumulated damage region always covers every contribution (union semantics), so every changed pixel is repainted and no stale content stays on screen.
How to reproduce it (as minimally and precisely as possible) 🔬
Standalone PathOps repro (no Uno involved): operands captured from the damage accumulation of a running app. Save as drop.cs and run dotnet run drop.cs (.NET 10 file-based app).
#:property ManagePackageVersionsCentrally=false
#:package SkiaSharp@3.119.0
#:package SkiaSharp.NativeAssets.Win32@3.119.0
#pragma warning disable CS0618
// accumulation (DamageRegionExtensions.Union) while a Pac-Man-style Path moved and changed geometry.
using SkiaSharp;
SKPath before = new() { FillType = (SKPathFillType)1 };
before.MoveTo(581.93396f, 108.69202f);
before.LineTo(536.2001f, 108.69202f);
before.LineTo(536.2001f, 121.76621f);
before.QuadTo(532.6f, 127.146095f, 532.6f, 134.40001f);
before.QuadTo(532.6f, 141.65407f, 536.2001f, 147.034f);
before.LineTo(536.2001f, 160.10791f);
before.LineTo(581.93396f, 160.10791f);
before.LineTo(581.93396f, 108.69202f);
before.Close();
before.MoveTo(355.13394f, 253.89197f);
before.LineTo(309.3999f, 253.89197f);
before.LineTo(309.3999f, 305.30798f);
before.LineTo(325.61688f, 305.30798f);
before.QuadTo(331.92606f, 307.37723f, 338.78003f, 305.30798f);
before.LineTo(355.13394f, 305.30798f);
before.LineTo(355.13394f, 253.89197f);
before.Close();
SKPath addition = new() { FillType = (SKPathFillType)0 };
addition.MoveTo(582.2374f, 108.08533f);
addition.LineTo(536.19995f, 108.08533f);
addition.LineTo(536.19995f, 160.71466f);
addition.LineTo(582.2374f, 160.71466f);
addition.LineTo(582.2374f, 108.08533f);
addition.Close();
addition.MoveTo(355.4373f, 253.28528f);
addition.LineTo(309.3999f, 253.28528f);
addition.LineTo(309.3999f, 305.91467f);
addition.LineTo(355.4373f, 305.91467f);
addition.LineTo(355.4373f, 253.28528f);
addition.Close();
SKPath result = new();
var ok = before.Op(addition, SKPathOp.Union, result);
// Expected: every point of `before` and `addition` is inside the union. Sample the rect interiors.
int missing = 0, sampled = 0;
foreach (var p in new[] { before, addition })
{
var b = p.TightBounds;
for (var y = b.Top + 0.25f; y < b.Bottom; y += 0.5f)
{
for (var x = b.Left + 0.25f; x < b.Right; x += 0.5f)
{
if (p.Contains(x, y))
{
sampled++;
if (!result.Contains(x, y)) missing++;
}
}
}
}
System.Console.WriteLine($"SkiaSharp 3.119.0: Op returned {ok}; points inside an operand but outside the union: {missing}/{sampled}; result bounds {result.TightBounds}; addition bounds {addition.TightBounds}; before bounds {before.TightBounds}");
System.Console.WriteLine($"result fill={result.FillType} svg={result.ToSvgPathData()}");
foreach (var (name, p) in new[] { ("rectA center", new SKPoint(559, 134)), ("rectB center", new SKPoint(332, 280)) })
{
System.Console.WriteLine($"{name}: in before={before.Contains(p.X, p.Y)} in addition={addition.Contains(p.X, p.Y)} in union={result.Contains(p.X, p.Y)}");
}Expected: points inside an operand but outside the union: 0/..., and the centre of the first rect inside the union. Actual with SkiaSharp 3.119.0 (the version the 6.7 and 6.8 branches reference; 3.119.2 and 4.151.1 give identical results): Op returned True, 18746/38472 sampled points missing, the result fill is EvenOdd, and rectA center (559,134) is in before=True in addition=True in union=False.
In an Uno app (intermittent):
- On Uno 6.7 / 6.8, create a Skia desktop app with a
Canvascontaining aPathwhoseDatais a pie/wedge (a "mouth" opening and closing) updated every frame, while also moving it withCanvas.SetLeftevery frame. - Run at a non-100% display scale (reproduced at 250%), software or OpenGL backend, for a few seconds.
- Stale slivers of the old shape remain along the path of motion in a fraction of runs. Moving-only or geometry-change-only paths did not reproduce it.
Workaround 🛠️
None found at app level, other than keeping geometry static while moving (moving-only and geometry-only Paths left 0 stale pixels).
Works on UWP/WinUI
Yes
Renderer 🎨
- Skia
- Native
Affected platforms 📱💻🖥️
Skia on all heads (observed on Skia desktop Win32; the code is shared by every Skia head).
Uno.Sdk version (and other relevant versions) 📦
Observed with Uno.Sdk 6.7.22 (Uno.WinUI 6.7.103, SkiaSharp 3.119.2). Same accumulation code at the heads of release/stable/6.7 (b55c8ae) and servicing/6.8 (630ab44). Not present on master (bfc8dff).
IDE version 🧑💻
N/A (reproduced from the command line)
Anything else we need to know? 💬
- Other damage paths on 6.7.103 use the same unchecked
Oppattern (outset for antialiasing, clip intersect, carried-damage union, present outset). NoOpcall ever returnedfalse, so the failure mode is a wrong result, not a reported failure. - A bounds check on the result would not catch this case (the result bounds are correct; only interior area is missing).
- Suggested fix for the servicing branches: accumulate an
SKRegionin device pixels (rasterise each contribution withSKRegion.SetPathor round its bounds out, union withSKRegion.Op, present withcanvas.ClipRegion), or at minimum fall back to a union of bounding rects instead of trustingOp. - Related but distinct: Scroll frames pay O(realized visuals) Skia path booleans for damage #23984 is about the cost of per-visual path booleans, not their correctness.
- This looks like an upstream Skia PathOps defect (
trueresult with a wrongEvenOddunion for near-coincident edges). The standalone repro has no Uno code in it.
Activity