Skip to content

feat(nsgotest): render native drawings without a macOS window - #1871

Merged
houko merged 1 commit into
mainfrom
feat/windowless-render-565
Nov 23, 2026
Merged

houko merged 1 commit into
mainfrom
feat/windowless-render-565

Conversation

@houko

@houko houko commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Headless tests can now measure native text, register fonts and render a recorded canvas on macOS without creating a window. nsgotest.PlatformTextEngine, RegisterFont and Render reuse CoreText and the existing Apple canvas player; Render returns owned transparent RGBA pixels suitable for PNG export or golden comparisons.

Rendering uses a private synchronous image resolver, including nested offscreen drawings, instead of the view caches or main queue. It releases native resources per call, preserves output scale and premultiplied alpha, and reports image failures, offscreen cycles, unresolved view paints/animations and invalid sizes. Image loading has a 30-second context and output is bounded to 16 Mi pixels. Concurrent renders keep independent image state.

Refs #565. This is its macOS test-utility stage. Windows/Linux native helpers and the runtime scope service on devices remain explicit roadmap work; other targets return ErrNoPlayer and have no platform text engine from this helper. The dependency graph explicitly allows nsgotest to reach the shared Apple player while core remains independent of backends. Public testing docs and the app-author skill are updated.

Targets

  • Shared code (nsgotest helpers and dependency rules)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None; no app interface changes. Native bitmap probes cover the output.

Verification

Rebased onto main 782a97b2f and migrated the release note into a dedicated changelog.d fragment, preserving the tested implementation. Earlier CI failures below describe historical runs; current checks run on the rebased head.

  • go tool nsgo test ./nsgotest -- -count=1: 163 passed, one existing skip.
  • Five focused windowless tests pass without -target or a window: all five shared canvas sample groups, scale equivalence, transparent premultiplied pixels, nested and malformed images, cycle/size failures, concurrent PNG rendering, native metrics and registered-font PUA glyphs distinct from fallback output.
  • go tool nsgo test ./internal/platform/apple -run '^(TestCanvasSamples|TestRegisteredFontsLayOut|TestAFontRegisteredLaterReplacesItsFallback)$' -- -count=1: three passed, no skips, including all six existing Apple canvas sample groups.
  • go tool nsgo check -target all -jobs 2 passed with a task-owned cache after unrelated shared-cache removal interrupted the first attempt; all targets selected by the tool passed.
  • The completed general CI job fails only the inherited TestPublicAPINamesNoInternalType ImageSampling allowance and TestMinimalAppLinks on macOS/Linux, tracked by fix(platform): keep net/http out of minimal apps #1797.
  • CI Build and vet and the Windows job pass. The three CodeQL jobs failed on GitHub installation API rate limits (HTTP 403), and dependency review reports that this repository does not support it; no dependency changed.
  • All 26 dependency-layer variants and the skill checks pass. The API guard fails only the inherited missing driver.ImageSampling allowance; temporarily applying that existing one-line correction from fix(platform): keep net/http out of minimal apps #1797 makes it pass. That separate correction is excluded from this PR.

Checklist

  • Conventional Commit title.
  • Updated changed documentation, public testing guide, skill and changelog fragment.
  • No new third-party code, assets or dependencies; font and canvas fixtures already belong to NSGo.

@github-actions github-actions Bot added documentation Improvements or additions to documentation macOS iOS enhancement New feature or request size/M labels Nov 22, 2026
@houko
houko force-pushed the feat/windowless-render-565 branch 2 times, most recently from abb9178 to 1e62d48 Compare November 22, 2026 04:56
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. Checked the windowless resolver (per-render image cache keyed by source and ratio, offscreen cycle detection, release of every CGImage and bitmap, premultiplied RGBA copy out of CGBitmapContextGetData) and that the canvas player's only image path honors CanvasHost.image, so no view cache or main-queue work is reached; the size/scale bounds and the non-macOS ErrNoPlayer stubs look right.

@houko
houko enabled auto-merge November 22, 2026 05:28
@houko
houko force-pushed the feat/windowless-render-565 branch from 1e62d48 to 11bba43 Compare November 22, 2026 08:15
@houko
houko added this pull request to the merge queue Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 22, 2026
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko
houko force-pushed the feat/windowless-render-565 branch from 11bba43 to 3c4ea6e Compare November 22, 2026 10:36
@houko
houko enabled auto-merge November 22, 2026 10:36
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko
houko added this pull request to the merge queue Nov 22, 2026
@houko
houko force-pushed the feat/windowless-render-565 branch from 3c4ea6e to 456c133 Compare November 23, 2026 00:42
@houko
houko merged commit cc77b23 into main Nov 23, 2026
18 of 19 checks passed
@houko
houko deleted the feat/windowless-render-565 branch November 23, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request iOS macOS size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant