Repository navigation
Description
What would you like to be added? 💡
During a scroll, damage accumulation on Skia costs O(realized visuals) Skia path booleans per frame, and the result is degenerate.
Visual.ContributeDamageOnPaint early-outs only when !contentChanged && !moved && !shadowSilhouetteChanged. While scrolling, moved = matrix != _lastRenderMatrix is true for every visual in the scrolled subtree, so the early-out never fires. Each visual then pays, on the UI thread, inside Render():
OutsetForAntialiasing—SKPaint.GetFillPath(stroke-to-fill) plusOp(Union)contentPath.Op(clipPath, SKPathOp.Intersect, contentPath)damage.Union(regionPath)against a monotonically growing accumulatordamage.UnionRect(_lastRenderBounds)— a nativeCreateRectPathallocation plus anotherOp(Union)
For a ListView with ~200 realized visuals that is roughly 800 Skia path booleans per frame, each more expensive than the last as the accumulator grows.
The key observation: when everything in the subtree moved, the union is the scroll port's clip rect — an O(1) answer being computed in O(n) with the most expensive primitive available.
Why is this needed? 🤔
This is the single largest per-frame cost in Uno's scroll path on Skia. It is invisible on a desktop CPU and decisive on a phone, which is why scroll smoothness degrades sharply on Android/iOS and mobile-browser WebAssembly relative to Desktop.
Because the cost scales with the number of realized visuals, it penalises exactly the case users notice most: long, content-rich lists.
Renderer 🎨
- Skia
- Native
For which platforms 📱💻🖥️
All platforms 🌍 (Skia targets)
Anything else we need to know? 💬
Proposed invariant:
A frame whose only change is an ancestor transform contributes
oldSubtreeRect ∪ newSubtreeRect, clamped to the scroll port clip, and skips the per-visual pathops entirely.
This is a self-contained rendering change with its own failure mode (missed repaints / visual artifacts), independent of scroll feel. It is being tracked separately from the frame-clock and scroll-physics work so it can be reviewed by rendering eyes on its own merits.
Activity
mikernet commentedon Sep 7, 2026
Adding a data point from a real app, since this regressed noticeably for us moving from Uno.WinUI 6.5.237 to 6.7.103 (Uno.Sdk 6.5.36 → 6.7.22), Skia desktop head on Win32/OpenGL, .NET 10.
Scenario: an
ItemsRepeater+UniformGridLayoutgrid of ~2800 items inside aScrollViewer, ~155 realized item visuals (each aButtonwith the default Fluent template containing aGrid, aFontIconand aTextBlock). Test harness scrolls 60 steps of 40 px at ~16 ms intervals viaScrollViewer.ChangeView(disableAnimation: true)and measures process CPU time (Process.TotalProcessorTime) around the loop. Virtualization, realized counts and layout times are identical on both versions; the difference is entirely in rendering.A sampled CPU trace (dotnet-trace, 25 s covering a longer scroll) on 6.7.103 shows where the extra time goes:
Visual.TryGetPaintDamageRegion→Visual.OutsetForAntialiasing(SKPaint.GetFillPath+SKPath.Op) andDamageRegionExtensions.Union/UnionRect: ~10.8 s inclusive on the UI thread, i.e. the per-visual path booleans described in this issue.ContributeDamageOnPaintnever early-outs because every visual in the scrolled subtree hasmoved == true.SkiaSharp.SKRoundRect.DisposeNativeunderSKNativeObject.Finalize: ~19 s on the finalizer thread. TheButtontemplates' rounded clips hand out new native objects every frame (this is [Skia] Rounded clips rebuild a native SKPath on every frame #24221 / perf(composition): Cache the rounded-clip paths #24230). Replacing theButtonwith a plainBorderin the item template brings the 60-step CPU from ~3200 ms to ~1170 ms, and a bare item to ~610 ms, which is roughly the 6.5 figure for the full template.Neither
TryGetPaintDamageRegionnorOutsetForAntialiasingexist in the 6.5.237 composition assembly, so this is new cost introduced with the damage-region tracking.Since #23986 was merged into
feature/breakingchangesonly, is a backport tomaster/ a 6.7.x service release feasible? For a virtualized list this is the difference between smooth and visibly laggy wheel scrolling on 6.7 stable, and the workaround (avoidButton/rounded-clip visuals in item templates) is not something most apps can do.mikernet commentedon Sep 12, 2026
Two clarifications to my comment above, plus new data.
The workaround is not sufficient in practice. My earlier numbers can be read as "replace the
Buttonand you're back to 6.5 levels", which isn't the case. The plainBorderand bare-item rows were diagnostic strips, not shippable UI. What we actually shipped is a stripped-downButtontemplate (rectangularBorderroot +ContentPresenter, hover/pressed via VSM, noCornerRadius, no ripple). On the same 60-step harness that measures ~1500 ms, against 688 ms for the full Fluent template on 6.5.237. So after applying the workaround we are still roughly 2.2x the 6.5 cost with visibly worse scrolling, and there is no further simplification left that keeps a usable control.ButtonButtonButtonBorder(diagnostic only)The cost is dominated by realized-but-offscreen visuals. Reducing
ItemsRepeater.VerticalCacheLengthfrom its default2.0to0.5, which roughly halves the realized visual count and changes nothing else, is a clearly perceptible improvement in scroll smoothness. (That one is qualitative, on the WebAssembly head; the table above is the desktop harness.) The direction is worth noting: a smaller cache buffer increases realization and recycling churn, and it still feels smoother, which points at per-frame cost dominating realization cost. It also means much of the cost is paid by visuals sitting in the cache buffer, entirely outside the viewport clip, contributing nothing visible.That suggests a cheaper partial mitigation than #23986: could
ContributeDamageOnPaint/TryGetPaintDamageRegionearly-out for visuals whose bounds fall outside the current clip? Every visual in a scrolled subtree hasmoved == true, so as far as I can tell nothing culls them before theSKPaint.GetFillPath+SKPath.Opwork. There may be a reason that's unsafe that I'm not seeing.Scope, and ruling things out:
TryGetPaintDamageRegion/OutsetForAntialiasingdon't exist in the 6.5.237 composition assembly at all.Finally, a triage request: this is currently labelled
kind/enhancement. It's a measured regression between two stable releases (6.5.237 → 6.7.103) that affects any virtualized list, so it would be good to see it re-triaged as a regression. I assume that classification is also what determines whether #23986 can be backported to a 6.7.x service release.Trim the icon grid cache buffer to work around unoplatform/uno#23984
mikernet commentedon Sep 19, 2026
Note: On WASM, this also appears to cause (or at least significantly contribute to) occasional sporadic crashes when scrolling - mono GC enters a collection while scrolling (which it does very often now) and sometimes something happens where it doesn't finish (my best guess right now is a JS stack overflow during GC that triggers while in a deep recursive measure/arrange), which then causes it to panic and exit the runtime on the next GC start.
agneszitte commentedon Sep 23, 2026
Hi @mikernet, thanks again for the detailed data points, they were really helpful.
To answer your question about backporting #23986, it's in progress.
While preparing to merge it into a 6.7 stable service release, we want to make sure it's properly fixed in your app as well.
Could you try Uno.Sdk 6.8.0-dev.49 (Uno.WinUI 6.8.0-dev.183) with your 60-step harness, ideally with the full Fluent Button template, and share the numbers compared to your Uno.WinUI 6.5.237 / 6.7.103 results, please? Anything you notice on WASM while scrolling would be welcome too.
We're doing internal testing on our side in parallel. Thanks a lot in advance for your help and feedback!
mikernet commentedon Sep 24, 2026
Thanks @agneszitte. I re-ran the same 60-step harness on Uno.Sdk 6.8.0-dev.49 (Uno.WinUI 6.8.0-dev.183), and re-measured 6.5.237 and 6.7.103 on the same machine and day so the numbers are directly comparable. Same setup as before:
ItemsRepeater+UniformGridLayout, 2837 items, 155 realized tiles, default cache lengths, 60 steps of 40 px at ~16 ms viaScrollViewer.ChangeView(disableAnimation: true), Skia desktop head on Win32/OpenGL, .NET 10. CPU isProcess.TotalProcessorTimeacross the loop (so it includes finalizer and GC threads), reported as the median of the runs with the min–max range.ButtonButtonButtonButtonButtonButtonTakeaways:
SKRoundRectfinalization from the FluentButtontemplate's rounded clips ([Skia] Rounded clips rebuild a native SKPath on every frame #24221 / perf(composition): Cache the rounded-clip paths #24230), which this fix does not address.WASM: subjectively a big improvement. On our real app (the same grid, Skia WebAssembly head, Chrome, using the lightweight button template), scrolling on 6.8.0-dev.183 feels at least twice as smooth as 6.7.x, with far fewer stutters. I don't have a CPU metric in the browser, so that one is qualitative.
agneszitte commentedon Oct 7, 2026
Hi @mikernet, a new 6.8-dev Uno.Sdk with the remaining scrolling and rendering fixes is now available: Uno.Sdk 6.8.0-dev.60.
Since 6.8.0-dev.49, it adds:
ProgressRing,AnimatedIconor Lottie animation no longer repaints the whole windowIn our tests, scrolling is back to the 6.5 level or better.
Could you try it with your harness and your app, on Win32 and WASM, and let us know how it goes? It would also help to know whether the WASM crash while scrolling still happens.
Once you confirm, we'll bring the same fixes to the next 6.7 service release.
Thanks again for your detailed reports!
mikernet commentedon Oct 7, 2026
@agneszitte Will give it a try, thanks!
Regarding the crash - it has been extremely difficult to trace. I put all sorts of crash instrumentation into the app but I still can't pin down what is causing the runtime to exit exactly, and it also happens on AOT builds, albeit much less often, and with slightly varying conditions each time, so I am suspecting some kind of mono bug at this point, perhaps something to do with interpreted stack frame unrolling when an exception happens under some specific condition, or god knows what else it could be. I keep adding more and more instrumentation to try to get closer to the reason it is crashing, but no luck so far, lol...it's an elusive little bugger.
If it is some kind of GC bug then hopefully the lower allocation rate now during paints will make it much less frequent either way :)
Will report back!
mikernet commentedon Oct 8, 2026
Performance is 👌
After some very long debugging and a lot of hair pulling, I finally figured out what was causing the crashes - filed issues for them, will submit PRs in a bit. Couple compounding "leaky memory" type issues were pushing the WASM app over the 2GB memory limit, unrelated to anything in this issue.
mikernet commentedon Oct 9, 2026
In case anyone wants the detailed results of my new perf runs:
Uno.WinUI 6.5.237, 6.7.103 and 6.8.0-dev.212 compared on scroll smoothness, desktop and WebAssembly.
Setup
ItemsRepeaterwith aUniformGridLayoutand 2837 items, using the full Fluent Button template.FrameRateset to 120.requestAnimationFramerecorder.Desktop: frames actually displayed
In 6.5 and 6.7, every frame recorded is presented, since rendering and presenting happen on the UI thread. In 6.8 they're on separate threads: the UI thread records a Skia picture, and a dedicated render thread replays and presents it. 6.8's row counts actual presents, read from Uno's own frame rate counter on the render thread.
6.5.237 desktop at a quarter of the window area
6.5 is capped at about 64 fps on desktop regardless of
FrameRateor workload. Its render timer can't fire faster than the default 15.625 ms Windows timer resolution.6.8 dev.212 desktop: recorded vs presented
6.8 removed 6.5's timer cap. At this window size, its render thread becomes the limit, and about a third of recorded frames are replaced before they can be presented.
WebAssembly, interpreted. One page load per version. Finalizer counts aren't available in WASM.
WebAssembly, AOT (
RunAOTCompilation=true). Two page loads per version."New frames/s" counts distinct scroll offsets that were laid out. In the browser, painting happens in the browser's own frame callback on the same thread, so displayed frames are at most the smaller of new frames and browser frames.
* 6.7's median looks deceptively low. Between its 450 to 800 ms stalls, the browser runs a handful of idle frames at full speed.
** 6.8's interpreted browser frames alternate between an idle 8.4 ms frame and a 33 to 50 ms frame doing layout and render. The median lands on the idle frames.
Takeaways
Update Icon Pack Builder to Uno.Sdk 6.8 and drop the scrolling workar…