Skip to content

Check HiDPI sharpness on the Windows and Linux renderers in CI (FR-82, #18) - #726

Draft
b-re-w wants to merge 13 commits into
developfrom
feat/18-fr82-ci
Draft

b-re-w wants to merge 13 commits into
developfrom
feat/18-fr82-ci

Conversation

@b-re-w

@b-re-w b-re-w commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs #18

Builds on #808 (the Compose fork's 1.11.1-ext.4). This branch merges feat/compose-ext4, which moves the Compose pin to the fork's v1.11.1-ext.4 tag (cadc5984) and the window pin (WINDOW_REVISION) to the tip of extended at a13a6289, all published as 1.11.1-ext.4. That window carries fork PR #216: after an Xft.dpi change the Kotlin/Native X11Window (extended/window/native/linux/src/X11Window.kt, scaleChanged) and the GraalVM x11_window.c resize the window to its size in points times the new scale (X11Scale.sizeAtScale in extended/window/common), state the size hints again and measure at the new size and scale before the frame. The Linux live-scale check, fr82_scale_change_redraws_at_the_new_scale, which was expected red at ext.3 because the window kept its size in pixels, is now expected green. Merge #808 first; this diff then shows only the FR-82 work.

The CI-checkable acceptance criteria of FR-82 as fr82_* checks. The renderer checks its own window: it draws a marker scene (white, 1 dp black bars at whole dp, a 40 dp circle, a 12 dp rounded clip, "Hg" at 16 sp), reads the screen and the drawn frame back, and prints one compose-rust: fr82_<check> scale=<s>: ok|FAILED <measurements> line per check.

  • Shared (renderer/desktop/src/HiDpiCheck.kt, symlinked into the Windows and Linux renderers): the scene, offscreen Compose at a density, a bilinear stretch for the negative control, the measurements and the order of the checks (criteria 1 to 6). HiDpiCheckTest (JVM) runs the measurements on pictures whose answer is known: Compose at 1, 1.25, 1.5 and 2 passes, while a stretched 1x frame, an aliased copy, a soft stroke and pictures past the 0.1% limit fail.
  • Windows (Fr82WindowsCheck.kt): GetDpiForWindow, GetClientRect, the composed desktop after DwmFlush, the swapchain buffer read back, plus per-monitor v2 awareness (criterion 7). Win32Window.run()'s loop body is now step(). The reference is drawn on the window's own Direct3D context. A windows-hidpi job in the native renderer test takes the windows-static kit, builds compose-rust/tests/fixtures/hidpi with and without the manifest, and .github/scripts/hidpi-windows-check.sh runs it at 100, 125, 150 and 200% (set-display-scale), then from 200% to 125% and back while it runs.
  • Linux (Fr82LinuxCheck.kt): Xft.dpi from RESOURCE_MANAGER, the window's attributes, XGetImage. LinuxWindow now redraws on onScaleChanged; before this, nothing redrew after an Xft.dpi change. The fork's window asks for a frame on a scale change, but the renderer's loop draws only on its own conditions, so the redraw stays here. .github/scripts/hidpi-linux-check.sh runs in the Linux job of the Kotlin/Native desktop test at Xft.dpi 96, 120, 144 and 192, then from 192 to 120 and back.
  • macOS: .github/scripts/macos-display-modes.c reports whether the runner offers a HiDPI mode (criterion 8's first step). The macOS sharpness check itself is not written in this PR.
  • CHANGELOG.md gains an entry.

CI design

Development CI is now one manually dispatched workflow, ci.yml, calling reusable suites. The merge took the develop side of both trigger conflicts: test-native-renderer.yml and test-kn-desktop-renderer.yml are workflow_call only (the native one also keeps its v* tag push), with no pull_request, schedule or concurrency of their own. The PR's own jobs and steps (windows-hidpi, the Linux HiDPI steps, the macOS display modes step) sit inside those suites, so the leader's ci.yml dispatch runs them; the run-heavy-ci label no longer starts anything. The changed job builds on any dispatched run, and its path list for tag-less pushes now names the HiDPI fixture and scripts.

Checked here (script tests, no build)

ci-on-demand, ci-pr-gate, native-needs-macos, needs-macos, no-em-dash, no-spec-citations, renderer-symlinks, spec-cites-real-tests, desktop-c-symbols, linux-native-window, x11-window-frames, x11-window-layout, x11-key-codes, win32-renderer-parity, windows-kotlin-native, compose-fork, fork-versions, fork-dependencies, naming-conventions, planning-docs, linux-window-default, fr53-windows-backend, with the window sources at a13a6289 from scripts/fetch-fork-window.sh. All pass.

Merge gate for the builder

  • JVM tests: the desktop module, including HiDpiCheckTest.
  • iosSimulatorArm64 compile, dx Android app build, macOS tests.

Only CI can prove (Windows, Linux)

  • A ci.yml dispatch on this head: the Linux job of the Kotlin/Native desktop test (hidpi-linux-check.sh under Xvfb, now including fr82_scale_change_redraws_at_the_new_scale at 1.25 and 2.00) and the windows-hidpi job (four scales, with and without the manifest, and the 200% to 125% change). Every fr82_* line is expected green; a red is a real finding.
  • The Linux and Windows Kotlin/Native renderers compiling and linking against the ext.4 window modules.
  • The macOS job's display modes report, which decides whether a macOS check can run on the runner.

The renderer's own HiDPI check, shared by the Kotlin/Native Windows and
Linux renderers and the JVM tests: the marker scene (white, 1 dp black
bars at whole dp, a 40 dp circle, a 12 dp rounded clip and "Hg" at
16 sp), Compose's offscreen drawing of it at a density, a bilinear
stretch for the negative control, and the measurements each criterion
makes (criteria 1 to 6): surface against client size and density, the
screen against the drawn frame (mean <= 1 level, <= 0.1% over 8), whole
pixel bars at s = 1 and 2, the screen against offscreen Compose at
fractional scales with a stretched 1x frame that must fail, the width of
curved and glyph edges, and the redraw after a scale change.

HiDpiCheckTest runs the measurements on pictures whose answer is known:
Compose's scene at 1, 1.25, 1.5 and 2 passes; the 1x scene stretched,
an aliased copy, a soft stroke and pictures past the 0.1% limit fail.
The Kotlin/Native Windows renderer runs the HiDPI check in its own
window when COMPOSE_RUST_FR82_CHECK is set, in place of the
application: it reads the scale with GetDpiForWindow, the client area
with GetClientRect, and the screen from the composed desktop after
DwmFlush, and reads each frame back from the swapchain buffer (or the
CPU resize frame) to compare. It also checks that the window's DPI
awareness context is per-monitor v2 and its DPI 192 at 200%
(criterion 7). Win32Window's loop body becomes step(), which run()
calls, so the check drives the real loop.

compose-rust/tests/fixtures/hidpi is the program it runs in, built with
and without compose-rust's manifest. The windows-hidpi job of the
native renderer test takes the windows-static kit, builds both, and
.github/scripts/hidpi-windows-check.sh runs them at 100, 125, 150 and
200% (set-display-scale.exe), then once from 200% to 125% and back
while it runs (criterion 6, WM_DPICHANGED), asserting every check named
for each scale said ok. Covers criteria 1 to 7 on Windows; not run yet.
The Kotlin/Native Linux renderer runs the same HiDPI check in its own
X11 window when COMPOSE_RUST_FR82_CHECK is set. On a connection of its
own it finds the window by name, reads Xft.dpi from the root window's
RESOURCE_MANAGER for the scale, the window's attributes for its size,
and XGetImage for the screen; each frame is read back from the GL
canvas before it is presented.

LinuxWindow now redraws when the window reports a scale change
(onScaleChanged, forwarded by the handoff listener): the fork's X11
window follows Xft.dpi, but nothing in the scene invalidates, so the
old frame stayed on the screen until something else asked for one.

The Linux job of the Kotlin/Native desktop renderer test builds the
hidpi fixture and .github/scripts/hidpi-linux-check.sh runs it under
Xvfb at Xft.dpi 96, 120, 144 and 192 (xrdb -merge), then once from 192
to 120 and back while it runs. Covers criteria 1 to 6 on Linux; not
run yet.
…R-82, #18)

Criterion 8 runs on CI only if the runner's virtual display can be
switched to two pixels to a point with CGConfigureDisplayWithDisplayMode.
macos-display-modes lists every mode CGDisplayCopyAllDisplayModes
returns with kCGDisplayShowDuplicateLowResolutionModes and says whether
one has a pixel width twice its point width. The macOS job of the
Kotlin/Native desktop renderer test runs it first and writes the answer
to the step summary; it changes nothing.
@b-re-w

b-re-w commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Expected red on the dispatched run: the Linux live-scale step (fr82_scale_change_redraws_at_the_new_scale, dp size before and after) fails until the fork keeps a window's dp size across a scale change. p1B has that fix in progress for both X11 windows (Xvfb test 640x480 -> 1280x960); it lands after ext.3, so it reaches this repo with the next window pin. Every other fr82 line is expected green; a red elsewhere is a real finding.

The dispatched run printed 'xrdb: no Xft.dpi' at every scale and ran everything at scale 1: Xvfb resets when its last client disconnects, dropping the root window's resources that xrdb had just written. The step now starts Xvfb with -noreset, and the script fails when a setting does not stay, so scale 1 cannot pass as every scale.
…18)

FR-82 criterion 4 compares the screen at a fractional scale with Compose
drawn offscreen at that density with the same fonts and raster settings,
under criterion 2's tolerance. The reference was drawn with Skia's CPU
backend while the window draws through GL (llvmpipe on CI) or Direct3D,
so antialiased edges differed by a level or two: 0.17% of pixels over 8
levels at 1.25 and 0.11% at 1.50 on the Linux job, against a 0.1% limit,
while the screen equalled the drawn frame exactly.

The reference and the 1x stretched control are now drawn through a
HiDpiSurface the window supplies: on Linux the window's own back buffer,
through its GLX and Skia contexts and the props its frames use, never
presented; on Windows a render target on the window's Direct3D context
with the swapchain's colour type, origin and pixel geometry. The CPU
backend is kept only for a window without a GPU context. The check's
line says which path drew the reference. The tolerance is unchanged.
…fr82-ci

# Conflicts:
#	.github/workflows/test-kn-desktop-renderer.yml
#	.github/workflows/test-native-renderer.yml
… checks (FR-82, #18)

With the fork's 1.11.1-ext.4 window modules from feat/compose-ext4, the
X11 window keeps its size in dp across an Xft.dpi change (fork #216), so
fr82_scale_change_redraws_at_the_new_scale is expected to pass on Linux.
…FR-82)

Under ci.yml the windows-static job is skipped because the kit is already an
artifact of the run, and a job whose need was skipped is skipped too. Accept a
skipped windows-static the way package-windows-host.yml does.
@b-re-w

b-re-w commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Local merge gate on head eeaa2dc91 (develop d642d79b5 merged in d668b78df, clean textual merge; the PR's jobs and steps stay in test-native-renderer.yml and test-kn-desktop-renderer.yml, which ci.yml calls as the test_native_renderer and test_kn_desktop_renderer suites, so ci.yml and scripts/ci-suites.sh need no change).

One merge fix, eeaa2dc91: under ci.yml, test-native-renderer.yml gets windows_kit_built: true, so its windows-static job is skipped, and windows-hidpi (which needs it) would have been skipped with it. Its if: now accepts a skipped windows-static, the same way package-windows-host.yml's host job does.

Step Exit Counts
fetch-design-systems.sh 0
stand-in-renderer.sh --if-refused 0 stand-in used
cargo fmt --check 0
cargo clippy --workspace --all-targets -D warnings 0
cargo test --workspace 0 1040 passed, 0 failed (schema pin fr13_1_3_code_roles_leave_widget_property_and_modifier_schemas_unchanged ok, untouched)
scripts/tests/*.test.sh 0 each 87 of 87, no reruns
require-fork-artifacts.sh desktop macos 0
./kotlin test -m desktop 0 1259 tests, 0 failed
./kotlin test -m macos 0 58 passed, 0 failed
./kotlin build -m ios -p iosSimulatorArm64 (forced) 0 debug.log shows the compile
dx build sample-minimal android 0

Only CI can prove (ci.yml suites, run with run-heavy-ci):

  • Windows HiDPI at 100/125/150/200% and a scale change, with and without manifest: test_native_renderer job windows-hidpi (needs the kit from windows_static_kit).
  • Windows Kotlin/Native compile and MSVC link: windows_static_kit, windows_static_consumer, test_native_renderer.
  • GraalVM Windows image: test_graalvm_renderer.
  • Linux HiDPI under Xvfb at four Xft.dpi values and a change: test_kn_desktop_renderer, linux matrix leg (hidpi-linux-check.sh).
  • macOS HiDPI display mode report: test_kn_desktop_renderer, macos leg.

# Conflicts:
#	CHANGELOG.md
#	renderer/windows/src/Win32Window.kt
…ndow's size in dp (FR-82)

The window pin moves from 96ae925 to ea0880c (fork #243), which still
publishes as 1.11.1-ext.5. On WM_DPICHANGED the Windows window now
restates the size it remembers at the new scale instead of applying the
rectangle Windows scaled from the outer frame, so a 320x240 dp window at
200% is 400x300 px at 125% rather than 398x297, the failure the FR-82
Windows HiDPI job reported. Window C only (win32_window.c and the new
win32_dpi.h); REVISION and MINGW_REVISION stay at 96ae925, so the
change lists do not move.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant