Skip to content

fix(skia): Draw text through Skia's text pipeline again - #24654

Merged
MartinZikmund merged 9 commits into
masterfrom
dev/mazi/text-glyph-blob
Oct 2, 2026
Merged

MartinZikmund merged 9 commits into
masterfrom
dev/mazi/text-glyph-blob

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #24652

PR Type:

🐞 Bugfix

What changed? 🚀

Since #24153, GlyphRunRenderer has drawn every glyph as a filled outline path (SKFont.GetGlyphPath, then SkiaDrawingSession.DrawPaths). That skips Skia's text pipeline, so there is no glyph cache and no scaler hinting. Text became much slower to draw and blurrier at small sizes. Details are in #24652.

This PR:

  • Adds IDrawingSession.DrawGlyphRun, following the same pattern as IGeometry: the backend type-checks the font and falls back to logic that works with any IFont.
    • The default implementation is the existing outline renderer, which moves from Uno.UI to Uno.UI.Composition.Drawing as a public GlyphRunRenderer. WebGPU and the managed backend keep this path unchanged.
    • SkiaDrawingSession overrides it. A SkiaFont run is drawn as an SKTextBlob via DrawText, which is the pre-feat!: pluggable drawing backend abstraction (WebGPU renderer + managed engines) #24153 path and covers both the present and recording sessions. Any other IFont goes to GlyphRunRenderer.Draw.
  • Text callers (ParsedText, UnicodeText, FrameRenderHelper) now call session.DrawGlyphRun.- Windows only: switches SkiaFontProvider to grayscale Antialias edging. No Uno surface sets a pixel geometry, so SubpixelAntialias never produced LCD text. On DirectWrite it only made the grayscale masks about 18% lighter and softer than WinUI. Other scalers (FreeType, CoreText) keep their current edging because I haven't measured them.

Performance

Measured in SamplesApp through the real GlyphRunRenderer and Skia sessions. The page is 60 lines × 67 glyphs of the default font. Numbers are median ms per frame. GPU is a private OpenGL context in the app process, since both GL and Vulkan use Skia's Ganesh backend.

Case Record (before → after) CPU raster GPU (GL)
14px @1x 0.761 → 0.039 11.72 → 0.33 1.076 → 0.097
14px @1.5x 0.649 → 0.038 16.14 → 0.60 1.866 → 0.102
12px @1x 0.480 → 0.024 10.67 → 0.32 1.647 → 0.092
24px @1x 0.431 → 0.024 10.46 → 0.33 1.362 → 0.062

That is roughly 18–20× faster recording, 25–35× faster CPU raster and 11–22× faster GPU playback.

Full-page frame cost

The table above isolates the text draw call. This section measures whole frames on real SamplesApp pages on the Win32 Vulkan host.

Setup:

  • Same binary for both sides: a measurement-only env var (UNO_TEXT_OUTLINES=1) restores master's outline path.
  • Metric: Uno's own UNO_LOG_FRAME_PHASES breakdown, with UNO_FORCE_CONTINUOUS_RENDER=1. Each cell is the median of 3 interleaved runs of 12 s, with warm-up seconds dropped.
  • Machine: 32-core desktop, RTX 4090, 120 Hz display.
  • Null test: identical builds differ by 0.8% in CPU per frame.

CPU per frame is record (UI thread) plus draw (render thread's submit to Vulkan), master → this PR:

Page Static full repaint Scrolling Full re-record (resize / theme / text change)
Sample chooser (home) 0.44 → 0.34 ms (−23%) 0.62 → 0.63 (noise) 1.06 → 0.93 (−13%)
TextBlock_JustifiedText (dense text) 0.24 → 0.24 (0%) – (page doesn't scroll) 2.77 → 0.48 (−83%); frame interval 12.0 → 8.4 ms
ItemsViewSummaryPage (~400 controls) 0.71 → 0.66 (−7%) 0.46 → 0.43 (−8%) 3.56 → 3.35 (−6%)
NavigationViewPage 0.89 → 0.73 (−18%) 1.08 → 0.41 (−62%); frames over 20 ms 8.9% → 0.4% 2.45 → 2.08 (−15%)

Reading it:

  • On control-heavy pages in steady state, text is a small share of the frame (−6 to −8% on ItemsView). This is the "text is a small fraction of any given page" case, and on this machine it's invisible because every frame fits the 8.3 ms vsync budget either way.
  • It is not small when text has to be redrawn. Re-recording a text-dense page costs 2.3 ms more per frame on master, enough to push it past a 120 Hz budget on a top-end desktop. Scrolling NavigationView has 22× more over-budget frames on master.
  • These are the fastest-case numbers. The per-glyph cost is CPU-side, so on laptops, Android and WASM the same deltas scale up with slower CPUs. I haven't measured those.
  • Time to first frame: no measurable difference (−2.1% to +0.8% across the four pages, inside the ~3% run-to-run spread).

Fidelity vs WinUI

Measured against Direct2D/DirectWrite with grayscale AA, the same text stack WinUI uses, with the same font in both renderers. The metric is the mean absolute coverage difference after best alignment; lower is closer.

Renderer Segoe UI @1x Segoe UI @1.5x Open Sans @1x Open Sans @1.5x
Pre-#24153 (text blob, subpixel edging) 0.031 0.022 0.030 0.023
Current master (outline fill) 0.025 0.022 0.028 0.021
This PR (text blob, grayscale edging) 0.019 0.012 0.018 0.013

Note on fonts: WinUI's default is Segoe UI, while Uno targets default to Open Sans. The table compares rasterizers with the font held constant. It is not an Uno-vs-WinUI app comparison. Comparing Uno with Open Sans to WinUI with Segoe UI gives ~0.14–0.15 for every variant, 8–10× the differences above. In a real side-by-side, the different font dominates; this PR only removes the rendering part of the gap.

The share of fully covered stem pixels now matches WinUI: 20/24/29% vs WinUI's 20/24/27% at 11/12/14px @1x with Segoe UI. The outline fill had 2/7/16%. Remaining gap: text is still about 10–15% lighter in total ink than DirectWrite. SkiaSharp doesn't expose text gamma/contrast to tune further.

Validation

  • Runtime (Skia Desktop, Windows): the new Given_GlyphRunRenderer test fails on master (1030–1815 differing pixels) and passes with the fix. A second test draws a non-Skia IFont through SkiaDrawingSession and checks it matches the outline renderer pixel for pixel. 4/4 pass after the rebase on master.
  • Runtime sweep: Given_TextBlock*, Given_RichTextBlock*, Given_TextBox*, Given_PasswordBox, Given_Run, Given_Hyperlink, Given_FontFamily, Given_IFont_AlternativeBackend: 604/608 passed. The 4 failures also fail on unmodified master on the same machine, so they are pre-existing and unrelated:
    • When_Inlines_Transitively_Change
    • When_IsTextSelectionEnabled_CRLF
    • When_Caret_Line_Straddles_Viewport_Edge_Grippers_Are_Hidden
    • When_Multiline_Pointer_TripleTap_With_Wrapping
  • Not validated locally: WASM, macOS, Linux, mobile. Those get the text-blob path with unchanged edging, which is the pre-feat!: pluggable drawing backend abstraction (WebGPU renderer + managed engines) #24153 behaviour.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01WHQGrdpD7nu5qU71pqPwiC

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 28s —— View job


Review complete

  • Gather context (diff, changed files, AGENTS.md rules)
  • Review IDrawingSession.TryDrawGlyphRun default interface method
  • Review SkiaDrawingSession glyph run drawing implementation
  • Review SkiaFont / SkiaFontProvider edging change
  • Review GlyphRunRenderer.Draw fallback logic
  • Review new runtime test Given_GlyphRunRenderer
  • Post inline findings
  • Post summary

Verdict: ship (1 minor finding, non-blocking)

Findings: 1 minor / informational — flagged inline on Given_GlyphRunRenderer.cs (Assert.Inconclusive guards could let the regression test for #24652 silently no-op instead of asserting, per the explicit test-coverage checklist item).

What checked out:

  • IDrawingSession.TryDrawGlyphRun is a correctly-shaped default interface method (=> false) — additive, non-breaking for WebGPU/managed backends that don't override it, consistent with the "no breaking changes" checklist item.
  • SkiaDrawingSession.TryDrawGlyphRun is reached by both the live-canvas and SKPictureRecorder-backed recording session (same class backs both), matching the PR's claim.
  • Colour glyphs (COLR/CBDT/sbix/SVG): SkiaFont.RasterizeColorGlyph already relies on SKTextBlobBuilder + SKCanvas.DrawText to get correct per-glyph colour from the typeface regardless of the paint's colour — the same mechanism TryDrawGlyphRun now uses for live drawing, so colour-glyph runs aren't silently mis-rendered by the fast path.
  • SkiaFont.BuildGlyphRun isn't dead code post-change: it's still exercised independently for glyph geometry (Given_Geometry.cs), so the fallback/geometry path stays live even though GlyphRunRenderer.Draw now short-circuits before reaching it on Skia.
  • SkiaFontProvider.TextEdging is the single source of truth for SKFontEdging (both SKFont construction sites use it; no other hardcoded SubpixelAntialias site was missed), and OperatingSystem.IsWindows() is the correct runtime-check idiom for this Skia-generic (netX.0) project per platform-targeting.md.
  • The Vector2→SKPoint reinterpret via MemoryMarshal.Cast (rather than the per-element new SKPoint(x,y) loop used elsewhere in the file) is a deliberate, safe hot-path optimization given both structs are two sequential blittable floats — consistent with the PR's stated perf goals.
  • The non-Windows SubpixelAntialias edging choice, now live again for the first time since feat!: pluggable drawing backend abstraction (WebGPU renderer + managed engines) #24153 (it was inert while glyphs were manually outline-filled), restores the pre-feat!: pluggable drawing backend abstraction (WebGPU renderer + managed engines) #24153 default rather than introducing new unvalidated behaviour — the PR body already discloses this as "not validated locally," which is accurate self-reporting per the debugging-discipline evidence protocol.
  • Test follows repo conventions: correctly scoped with [PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.Skia)] and #if __SKIA__ (the latter is required here for Skia-only type references — this dual-guard pattern is the established convention elsewhere, e.g. Given_Geometry.cs, not the "wrap [TestMethod] in #if" anti-pattern the rule warns about).

Note: Code-review by inspection only — I did not compile or run the test suite in this session (no build was attempted here); the PR description's own runtime-test evidence (red on master, green with the fix) is the validation basis for this review.

@MartinZikmund
MartinZikmund marked this pull request as ready for review September 25, 2026 07:18
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 49s —— View job


Review complete

  • Gather context (diff, changed files, AGENTS.md rules)
  • Review IDrawingSession.TryDrawGlyphRun default interface method
  • Review SkiaDrawingSession glyph run drawing implementation
  • Review SkiaFont / SkiaFontProvider edging change
  • Review GlyphRunRenderer.Draw fallback logic
  • Review new runtime test Given_GlyphRunRenderer
  • Post inline findings
  • Post summary

Verdict: ship (minor nits only, no correctness or architectural blockers found)

Issues by severity: 0 high, 0 medium, 3 low — all posted as inline comments.

What I checked

  • TryDrawGlyphRun's baseline/position math matches the pre-existing outline-fill path exactly (per-glyph Y + baselineY, with X untouched), so the two code paths are semantically equivalent, not just visually similar.
  • SkiaCommandRecorder and SkiaPresentSession both derive from SkiaDrawingSession without shadowing TryDrawGlyphRun, so recording and present sessions both get the native path, matching the PR description's claim.
  • SkiaRenderRecord.Replay replays the underlying native SKPicture directly — recorded DrawText calls replay correctly regardless of which draw API produced them.
  • Color/emoji glyph handling (SkiaFont.BuildGlyphRun's GlyphImage/HasColorGlyphs path) is bypassed on the native path, but that's expected: Skia's own text-blob pipeline renders COLR/CBDT/sbix color glyphs natively, and BuildGlyphRun remains directly exercised by Given_Geometry/Given_IFont_AlternativeBackend, so it isn't dead code — just no longer on the Skia hot path.
  • The Windows-only edging change is a runtime check (OperatingSystem.IsWindows()) inside a Skia-only project, consistent with .claude/rules/platform-targeting.md rule 4 (no #if needed here).
  • MemoryMarshal.Cast<Vector2, SKPoint> relies on the two structs having identical blittable layout (they do, and SkiaSharp's SKPoint has been stable), so the allocation-free cast is a reasonable choice, if slightly implicit.

Cross-cutting notes (non-blocking)

  • The #if __SKIA__ wrapping the entire [TestMethod] in the new test looks like it contradicts the runtime-tests rule ("wrapping [TestMethod] in #if breaks test discovery, use [PlatformCondition] instead"), but this is actually the established pattern in this codebase for tests that reference Skia-only internal composition types unavailable to other TFMs (Given_AlphaMask, Given_Visual_Damage, etc.) — not a real violation.
  • No event Action, no DependencyProperty changes, no blocking async/.Result calls, no new #pragma/NoWarn growth introduced by this diff.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235618 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DisplayInformation.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
  • skia-windows-screenshots: 2310 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppWindowPresenters.png
    • ArcSegment.png
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithrightmargin.png
    • AutoSizedPathCentered.png-dark
    • AutoSuggestBox_BitmapIcon.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • Battery.png-dark
    • Battery.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • BitmapIcon_Sizing.png-dark
    • BitmapIcon_Sizing.png
    • Border_AntiAlias.png-dark
    • Border_AntiAlias.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 235618 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/text-glyph-blob branch from 04cd5ed to 0e549c4 Compare September 28, 2026 13:50
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 35s —— View job


Review complete

  • Gather context (diff, changed files, AGENTS.md rules)
  • Review changes since last review pass (redesign from TryDrawGlyphRun/bool to a DrawGlyphRun default-interface method, GlyphRunRenderer moved to Uno.UI.Composition.Drawing)
  • Review IDrawingSession.DrawGlyphRun / SkiaDrawingSession implementation
  • Review SkiaFontProvider edging change
  • Review GlyphRunRenderer.Draw fallback logic
  • Review runtime test Given_GlyphRunRenderer
  • Post inline findings
  • Post summary

Verdict: ship (3 low-severity findings, no blockers)

Issues by severity: 0 high, 0 medium, 3 low — all posted inline.

What changed since the last review pass

The API was reworked from IDrawingSession.TryDrawGlyphRun(...) : bool (default => false) to IDrawingSession.DrawGlyphRun(...) : void with a default interface implementation that calls GlyphRunRenderer.Draw. GlyphRunRenderer itself moved from Microsoft.UI.Xaml.Documents (in Uno.UI) into Uno.UI.Composition.Drawing, alongside IDrawingSession. This is a real improvement: callers (FrameRenderHelper, ParsedText, UnicodeText) now just call session.DrawGlyphRun(...) and get the native-vs-fallback branching for free, instead of each caller needing to know about the split; and the class doc on GlyphRunRenderer now correctly scopes its "the font never touches the render backend" claim to the fallback path only, which resolves the doc-drift concern from the earlier review pass. The earlier "static field written by instance method" code-quality bot flag on the [ThreadStatic] _textBlobBuilder cache is still a false positive — it's the same reuse-per-render-thread pattern already used for _sparePaint in the same class.

Findings (inline)

  • src/Uno.UI/Helpers/FrameRenderHelper.cs:431 — the using Microsoft.UI.Xaml.Documents; this line's rework leaves behind is now dead (nothing else in the file references that namespace); flagged as a build-cleanliness nit.
  • src/Uno.UI.RuntimeTests/.../Given_GlyphRunRenderer.cs:96 — the Assert.Inconclusive guards in TryCreateDefaultFont (carried over unchanged from the prior review) still let the sole [Skia] Text drawn as glyph paths since #24153: 6-40x slower, blurrier at small sizes #24652 regression test silently no-op instead of failing loudly.
  • src/Uno.UI.RuntimeTests/.../Given_GlyphRunRenderer.cs:31 — still missing the [GitHubWorkItem] traceability attribute called for by .claude/rules/runtime-tests.md, also carried over unaddressed.

Cross-cutting concern (not inline — no single line)

The latest Azure DevOps build (235618) failed, and the screenshot-compare bot reports very large diff counts — 2310/2500 on skia-windows-screenshots (~92%), 57/2348 on Linux, 11/1076 on WASM. Given the Windows-only edging switch (SubpixelAntialias → Antialias) plus the outline-fill → native-text-blob pipeline swap, widespread diffs across nearly every screenshot with any text are plausible and consistent with the PR's own fidelity/perf methodology — but I don't have access to the Azure DevOps job logs to confirm the build failure is only the (expected, to-be-rebaselined) screenshot mismatch and not a separate compile/test failure. Worth confirming that before merge, and checking the "Validated PR Screenshots Compare Test Run results" checklist item, which is currently unchecked.
· branch

Comment thread src/Uno.UI/Helpers/FrameRenderHelper.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236010 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • DisplayInformation.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Image_AnimatedWebP.png-dark
    • Image_AnimatedWebP.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
  • skia-windows-screenshots: 2310 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • Accessibility_ScreenReader.png
    • AppBar_KeyBoard.png-dark
    • AppBarButtonTest.png
    • ApplicationViewSpanningRectsPage.png
    • ApplicationViewMode.png
    • AppWindowTitleBar Properties.png-dark
    • AppWindowPositionAndSize.png-dark
    • Arrange_Performance01.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AuthenticationBroker_Demo.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutoBorderStretchwithtopmargin.png-dark
    • AutomationPropertiesExtensions_Role.png-dark
    • AutoSizedTopLeft.png
    • AutoSizedPathCentered.png-dark
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_Description.png
    • AutoSuggestBox_Keyboard.png
    • AutoSuggestBox_Icons.png-dark
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@MartinZikmund

Copy link
Copy Markdown
Member Author

@ramezgerges Thanks, good call! Done in e61ee9f:

  • IDrawingSession.DrawGlyphRun(IFont, ...) has a default implementation that draws outlines for any IFont. The GlyphRunRenderer logic moved into Uno.UI.Composition.Drawing for this.
  • SkiaDrawingSession.DrawGlyphRun checks for SkiaFont and draws an SKTextBlob. Any other font goes to the fallback.

C# has no base. call for a default interface method, so the Skia override's "base" is GlyphRunRenderer.Draw(this, ...). That is why GlyphRunRenderer is now public: the Skia backend has no InternalsVisibleTo into the Drawing assembly. The text callers now just call session.DrawGlyphRun(...).

I also added a runtime test (0e549c4) that draws a non-Skia IFont through SkiaDrawingSession and checks it matches the outline renderer pixel for pixel. The branch is rebased on latest master.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 236010 has failed on Uno.UI - CI.

MartinZikmund and others added 6 commits October 1, 2026 14:34
Since #24153 text was filled as glyph outline paths, skipping the glyph
cache and scaler hinting: 10-40x slower and blurry at small sizes.
Skia sessions now draw glyph runs as text blobs; other backends keep
the outline path. On Windows, grayscale edging matches DirectWrite.

Fixes #24652

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WHQGrdpD7nu5qU71pqPwiC
The outline fallback moves to Uno.UI.Composition.Drawing as the default
DrawGlyphRun, mirroring the IGeometry pattern: SkiaDrawingSession draws
SkiaFont runs as text blobs and hands any other IFont to the fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XsXGjEmwzEK5r2KvcdhYTT
Load a bundled font through the Skia provider directly instead of
skipping as inconclusive, and link the tests to #24652.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:40
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 9s —— View job


Review complete

  • Gather context (diff since last review, AGENTS.md rules)
  • Review changes since last pass (rebase + e61ee9f3cfd / 0e549c43001, plus latest 5f007bcc / cd3cf7e7)
  • Check whether prior findings (dead using, Assert.Inconclusive, missing [GitHubWorkItem]) were addressed
  • Review new/changed code for other issues
  • Post inline findings
  • Post summary

Verdict: ship — no new findings

All three outstanding low-severity items from the previous review passes have now been resolved in this branch's latest commits:

  • Dead using Microsoft.UI.Xaml.Documents; in src/Uno.UI/Helpers/FrameRenderHelper.cs — removed in 5f007bcc.
  • Stale doc comment on GlyphRunRenderer.Draw ("the font never touches the render backend") — reworded in 5f007bcc to scope the claim to the fallback path only ("On this path the font never touches...").
  • Assert.Inconclusive silently no-opping the [Skia] Text drawn as glyph paths since #24153: 6-40x slower, blurrier at small sizes #24652 regression test — cd3cf7e7 replaces the SKTypeface.Default.OpenStream/FontProvider.Current guards with a bundled Roboto-Regular.ttf asset loaded directly through new SkiaFontProvider(), and asserts the result IsInstanceOfType<SkiaFont> instead of returning/skipping. The test can no longer go inconclusive — it fails loudly if the precondition isn't met.
  • Missing [GitHubWorkItem] — added to When_Skia_Draws_GlyphRun_Then_Matches_Skia_Text_Pipeline in the same commit.

I re-checked the rest of the diff against origin/master (IDrawingSession.DrawGlyphRun, SkiaDrawingSession.DrawGlyphRun, SkiaFont.NativeFont, SkiaFontProvider.TextEdging, the three call-site updates in FrameRenderHelper/ParsedText/UnicodeText) — no regressions introduced by the latest commits, and no new issues found:

  • SkiaFontProvider/SkiaDrawingSession/SkiaFont are all internal but covered by [assembly: InternalsVisibleTo("Uno.UI.RuntimeTests")] in Uno.UI.Composition.Skia, so the test's direct instantiation of SkiaFontProvider and reference to SkiaDrawingSession/SkiaFont compiles cleanly.
  • No dangling using Microsoft.UI.Xaml.Documents; left in ParsedText.cs/UnicodeText.cs after the GlyphRunRenderer move — both already import Uno.UI.Composition.Drawing for IDrawingSession.
  • [ThreadStatic] _textBlobBuilder in SkiaDrawingSession follows the same established reuse-per-thread pattern as _sparePaint in the same class (the earlier code-quality bot "static field written by instance method" flag is a false positive, as previously confirmed).

Cross-cutting note (unchanged, not newly introduced)

The CI screenshot-compare bot still reports very large diff counts on the latest build (236010): 2310/2500 skia-windows-screenshots, 57/2348 Linux, 11/1076 WASM — consistent with the PR's own stated Windows-only edging change (SubpixelAntialias → Antialias) plus the outline-fill → native-text-blob swap affecting nearly every screenshot containing text. Build 236010 itself is reported as failed; worth confirming before merge that the failure is only the (expected, to-be-rebaselined) screenshot mismatch and not a separate compile/test failure, and checking the "Validated PR Screenshots Compare Test Run results" checklist item, which is still unchecked.
· branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The edging test oracle is coupled to its implementation, and one updated caller retains contradictory documentation.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Restores Skia’s cached, hinted text pipeline for issue #24652 while retaining outline rendering for unsupported backends and fonts.

Changes:

  • Adds a backend-extensible DrawGlyphRun drawing primitive.
  • Uses SKTextBlob for Skia fonts with portable fallback rendering.
  • Applies grayscale edging on Windows and adds runtime coverage.
File Description
UnicodeText.cs Routes glyphs through DrawGlyphRun.
ParsedText.cs Uses the new drawing primitive.
FrameRenderHelper.cs Updates diagnostic text rendering.
Given_GlyphRunRenderer.cs Tests Skia and fallback paths.
SkiaFontProvider.cs Selects Windows grayscale edging.
SkiaFont.cs Exposes the native font internally.
SkiaDrawingSession.cs Implements text-blob rendering.
IDrawingSession.cs Adds DrawGlyphRun with fallback.
GlyphRunRenderer.cs Moves portable outline rendering into the drawing layer.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Uno.UI/Helpers/FrameRenderHelper.cs Resolved
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:53
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 6s —— View job


Review complete

  • Gather context (diff vs origin/master, AGENTS.md rules, prior review history)
  • Review changes since the last pass (5f007bcc, cd3cf7e7, 2b16d08a, 33fed19c)
  • Verify the two open Copilot findings (edging-oracle coupling, stale FrameRenderHelper comment) were actually addressed
  • Re-review full diff (IDrawingSession.DrawGlyphRun, SkiaDrawingSession, SkiaFontProvider, GlyphRunRenderer, call sites, runtime test)
  • Post inline findings
  • Post summary

Verdict: ship — no new findings

Issues by severity: 0 high, 0 medium, 0 low (nothing new to post inline).

What I confirmed since the last review pass

Both findings from Copilot's review are resolved in the two latest commits:

  • Edging-oracle coupling (33fed19c) — When_Skia_Draws_GlyphRun_Then_Matches_Skia_Text_Pipeline no longer reads SkiaFontProvider.TextEdging for its expected-pixels oracle. It now spells out OperatingSystem.IsWindows() ? SKFontEdging.Antialias : SKFontEdging.SubpixelAntialias independently, so a future regression in the production edging policy (e.g. SkiaFontProvider.TextEdging accidentally reverting to subpixel on Windows) would make the duplicated test expression diverge from the actual rendering and fail, instead of moving in lockstep with it.
  • Stale FrameRenderHelper comment (2b16d08a) — the comment above DrawText now says the overlay draws "a glyph run, the same way a TextBlock renders (natively where the backend can, outlines otherwise)", replacing the old "draw the glyph outlines through the neutral path verb" wording that no longer matched session.DrawGlyphRun(...).

Re-verified across the whole diff (no regressions, no new issues)

  • SkiaDrawingSession.DrawGlyphRun: type-checks SkiaFont, short-circuits on empty glyphs before touching SKTextBlobBuilder, and falls back to GlyphRunRenderer.Draw for any other IFont — matches the description exactly.
  • GlyphRunRenderer is now public in Uno.UI.Composition.Drawing (moved from Microsoft.UI.Xaml.Documents/Uno.UI), which is consistent since the GlyphRunElement/GlyphOutline/GlyphOutlineRef types it operates on were already public in IFont.cs — no new encapsulation leak.
  • SkiaFont.NativeFont is internal, consumed only within the same assembly (SkiaDrawingSession) plus the runtime test via the existing [assembly: InternalsVisibleTo("Uno.UI.RuntimeTests")] in Uno.UI.Composition.Skia — compiles cleanly, no visibility widening needed.
  • [ThreadStatic] _textBlobBuilder follows the same established reuse-per-render-thread pattern as _sparePaint/_recorderPool in the same class (the CodeQL "static field written by instance method" flag was already correctly dismissed as a false positive).
  • ParsedText.cs/UnicodeText.cs/FrameRenderHelper.cs call sites all now go through session.DrawGlyphRun(...) uniformly; no leftover direct GlyphRunRenderer.Draw(...) calls or dangling using Microsoft.UI.Xaml.Documents; directives remain.
  • All 8 commit messages are Conventional-Commits-compliant (fix, test, refactor, chore, docs, each scoped (skia)).
  • Runtime test (Given_GlyphRunRenderer.cs) carries [GitHubWorkItem("...issues/24652")], uses async Task correctly (it awaits LoadFontData()), loads the bundled Roboto-Regular.ttf directly through new SkiaFontProvider() rather than depending on environment-registered state, and no longer has any Assert.Inconclusive escape hatch — both tests fail loudly if their precondition isn't met.

No cross-cutting concerns beyond what was already raised in earlier passes (the expected screenshot-diff volume from the rendering-pipeline swap, already explained by the author as expected and to be rebaselined).
· branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation and regression coverage are coherent; only a minor stale documentation comment remains.

Review effort: Balanced
Findings: None

Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Low severity Update outdated comment about glyphs always becoming outlines

src/​Uno.UI/​UI/​Xaml/​Documents/​UnicodeText.cs:1247

The nearby comment still says these glyphs are always converted to outline paths/images, but this call now deliberately uses a backend-native text pipeline for recognized fonts. Update it so it does not document the behavior this PR removes.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236703 found UI Test snapshots differences: skia-linux-screenshots: 2300, skia-windows-screenshots: 2454, wasm: 0

Details
  • skia-linux-screenshots: 2300 changed over 2502

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png
    • AppBarButtonTest.png
    • AppBarToggleButtonTest.png
    • ApplicationViewMode.png-dark
    • ApplicationViewSizing.png
    • AppWindowClosing.png
    • AppWindowPositionAndSize.png
    • AppWindowTitleBar Properties.png
    • Arrange_Performance01.png-dark
    • Arrange_Performance01.png
    • Attributed_text_Simple.png-dark
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutomationProperties_Name.png
    • AutoSuggestBox_BitmapIcon.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
  • skia-windows-screenshots: 2454 changed over 2502

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppWindowFeatures.png
    • ArcSegment.png
    • Attributed_text_Supserscript.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_AutomationId.png-dark
    • AutoSizedTopLeft.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • BackGesture.png-dark
    • BasicEnability.png-dark
    • BasicEnability.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderImageBrush.png-dark
    • BorderImageBrush.png
    • Border_CornerRadius.png-dark
    • Border_CornerRadius.png
  • wasm: 0 changed over 1076

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 236703 has failed on Uno.UI - CI.

Thin Arabic strokes drawn via SKTextBlob on Android peak at FEFF0202,
never exact FFFF0000, so the alignment check failed on ink saturation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xy53m3SipMNh8gPt7cbXDE
Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:50
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 25s —— View job


Review complete

  • Gather context (diff since last review, AGENTS.md rules)
  • Review changes since last pass (latest commits: f6eea33a, 33fed19c, 2b16d08a, cd3cf7e7, 5f007bcc)
  • Check whether prior findings were addressed
  • Investigate the Linux screenshot-diff jump (57 → 2300) reported on build 236703
  • Post inline findings
  • Post summary

Verdict: ship (1 low finding, no blockers)

Issues by severity: 0 high, 0 medium, 1 low — posted inline.

What's new since the last review pass

The only non-test/doc commit since the prior pass is none — cd3cf7e7/5f007bcc/2b16d08a/33fed19c/f6eea33a are all test hardening or comment wording (already covered in the previous review). Confirmed resolved: the GlyphRunRenderer doc comment, the dead using Microsoft.UI.Xaml.Documents;, the Assert.Inconclusive guards (now load Roboto-Regular.ttf via a direct SkiaFontProvider and fail loudly), the missing [GitHubWorkItem], and the edging-oracle coupling Copilot raised (the test now spells out OperatingSystem.IsWindows() ? Antialias : SubpixelAntialias independently instead of reading SkiaFontProvider.TextEdging).

New finding

  • src/Uno.UI/UI/Xaml/Documents/UnicodeText.cs:1238 — the comment above the DrawGlyphRun call ("Outline glyphs are assembled into a path (drawn neutrally); color glyphs (emoji) become images.") is stale: it still describes the pre-PR behavior. Copilot's last review flagged this exact spot as "previously missed," and the equivalent comment in FrameRenderHelper.cs was already rewritten in 2b16d08a — this one just wasn't touched.

Cross-cutting concern (escalated from prior passes)

The latest screenshot-compare run (build 236703) shows a much larger Linux diff than previous builds on this same branch: 2300/2502 (92%), up from 57/2348 on build 236010 two commits ago — while every commit in between is test-only (cd3cf7e7, 2b16d08a, 33fed19c, f6eea33a), none of which touch production rendering code, and the Windows-only edging change (SubpixelAntialias → Antialias) was already in place before that jump. A jump from ~2% to ~92% of all screenshots on a platform that didn't get an edging change, with no intervening rendering-code commit, doesn't match "expected because this PR changes text rasterization" — that explanation fit the earlier, smaller numbers. It's more consistent with the Oct 1 rebase pulling in unrelated master drift that hasn't been rebaselined, but I can't confirm that from the PR branch alone (no access to the Azure DevOps job logs). Worth confirming, before merge, that build 236703's failure and the 92% Linux diff are accounted for by the rebase/rebaseline rather than a real Linux-specific regression in the native text path, and checking the still-unchecked "Validated PR Screenshots Compare Test Run results" checklist item.
· branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation and regression coverage are sound; the sole finding is a non-blocking stale comment.

Review effort: Balanced
Findings: None

Previously missed (1)

In code that hasn't changed since last review

Low severity Update comment to document native text rendering and fallback

src/​Uno.UI/​UI/​Xaml/​Documents/​UnicodeText.cs:1247

The comment immediately above this call still states that glyphs are always assembled into outline paths and images. This call now deliberately delegates to the backend, so Skia uses its native text pipeline; update the comment to describe both native rendering and the portable fallback.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237041 found UI Test snapshots differences: skia-linux-screenshots: 107, skia-windows-screenshots: 2454

Details
  • skia-linux-screenshots: 107 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DisplayInformation.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
  • skia-windows-screenshots: 2454 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedIconPage.png-dark
    • AndroidWindowInsets.png-dark
    • Accessibility_ScreenReader.png-dark
    • Accessibility_ScreenReader.png
    • AndroidWindowInsets.png
    • AppBarToggleButtonTest.png
    • AnimatedVisualsTestbedPage.png
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewMode.png-dark
    • AppWindowFeatures.png-dark
    • AppBarButtonTest.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSizing.png-dark
    • Application_DispatcherShutdownMode.png
    • AppWindowTitleBar Properties.png-dark
    • AppBarButtonTest.png
    • AppWindowPositionAndSize.png
    • ApplicationViewSizing.png

@mergify

mergify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@MartinZikmund
MartinZikmund merged commit a3ce577 into master Oct 2, 2026
56 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/text-glyph-blob branch October 2, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Skia] Text drawn as glyph paths since #24153: 6-40x slower, blurrier at small sizes

5 participants