Skip to content

Cache shared text shaping and glyph blobs independently of WebGPU - #50

Merged
danwalmsley merged 5 commits into
mainfrom
codex/isolated-text-shaping-cache
Sep 9, 2026
Merged

danwalmsley merged 5 commits into
mainfrom
codex/isolated-text-shaping-cache

Conversation

@danwalmsley

@danwalmsley danwalmsley commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Repeated text measurement and drawing rerun HarfBuzz shaping and recreate Skia text blobs. Cache origin-relative shaped runs and short-run text blobs so repeated labels reuse glyph data while positioning, color and rasterization remain correct. NativeTextShaping is shared by Avalonia and Uno, including CPU rendering and macOS.

Shaped runs are bounded to 2,048 entries / an estimated 4 MiB, keyed by typeface identity, text, size, scale and encoding. Short text blobs use a 512-entry LRU with styling and rasterization keys. Active readers pin blobs while drawing outside the cache lock; eviction disposes a blob after its final reader returns. Spaced/scaled drawing retains the existing positioning path. This builds on #49 and adds no WebGPU, frame-pacing or canvas-checkpoint changes.

The Linux native-package failure also exposed a GC test assumption: offering V8 idle time does not guarantee collection. Tests now complete script setup before explicitly requesting GC, observe detached nodes in scene counters before requesting collection, and verify that the count falls afterward. They avoid the five-second heap snapshot refresh interval. Low-memory notifications reschedule bounded detached-node cleanup, including batches below the 512-node mutation threshold. Certification checks wait for fresh diagnostic counters while preserving the existing batch limits. This native fix is in a separate commit.

Validation:

  • macOS: all 75 NativeTextShapingTests / ShapedRunCacheTests pass on both .NET 8 and .NET 10, including blob disposal, active-reader lifetime, LRU eviction, rasterization separation and concurrent pixel equivalence during eviction.
  • macOS: focused native detached-DOM GC tests pass with certification enabled, covering small batches, 2,048 detached nodes, reachable-wrapper identity and bounded release slices.
  • macOS CPU warm-label probe: median shaping 3.70 → 0.15 µs; shaping plus bitmap drawing 6.96 → 2.14 µs. Both cached operations report zero managed allocations.
  • Original Windows validation at 0d32a5c: 71 focused tests on each framework, clean Uno Release build, and warm-label medians of 3.00 → 0.15 µs shaping and 7.07 → 3.26 µs drawing.
  • git diff --check passes. Updated Linux/Windows/macOS CI is running.

Probe code, methodology and raw samples are in docs/validation/text-cache.md, text-cache-windows.json and text-cache-macos.json. These are warm microbenchmark results; cold workloads, concurrent throughput and application frame rates remain unmeasured.

@danwalmsley
danwalmsley merged commit 5c953d6 into main Sep 9, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant