From 439b6431d58b06eaa6d105b2d29454f5bc0cba30 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:29:00 +0900 Subject: [PATCH 001/209] Docs: Describe the Windows resize path FR-19.8 criterion 4 has, without DirectComposition The criterion said WM_SIZE returns after ResizeBuffers, the Skia draw, Present and a DirectComposition Commit. The window has no DirectComposition: during a size change it hides the GPU child, draws the frame with Skia's raster backend into a DIB and copies it into the top-level window's redirection surface with BitBlt before WM_SIZE returns, and with DXC_RASTER_RESIZE=0 it presents on the GPU and waits with DwmFlush. The measure of the criterion (no frame at another size) is unchanged. Refs #353 --- docs/SPEC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SPEC.md b/docs/SPEC.md index 97802db60..e4a856579 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -1459,7 +1459,7 @@ INTENT D19가 Compose 자체를 고치는 일을 `thisisthepy/compose-multiplatf 1. 지금 이 저장소가 창에 대해 돌리는 검사(19.4, 19.7의 수용 기준, 그리고 `scripts/tests/`의 창 검사: 캡션 기하, Win32와 X11 창 배치, 크기 조절 중 그리기)가 포크의 샘플(`compose-multiplatform-extended`의 hello 앱)에 대해 같은 결과로 통과합니다. 캡션의 색과 크기 조절 중 그리기가 그 샘플에 지금 없는 것이 이 이전이 끝나지 않았다는 표시입니다. 2. 그 확인을 화면 배율 100%와 200%에서 각각 하고, 각 배율의 스크린숏을 기록합니다. 3. 옮긴 뒤 compose-rust의 샘플이 포크의 창으로 같은 검사를 통과하고, 이 저장소의 창 사본이 지워집니다. -4. **크기를 바꾸는 동안 화면에 나오는 프레임은 모두 그 순간의 창 크기로 Skia가 그린 프레임입니다.** 측정 기준은 "현재 창 크기와 다른 크기로 그려진 프레임의 비율 = 0"입니다. 배경색으로 빈 곳을 가리는 것, 이전 프레임을 늘리는 것, 이전 프레임을 그대로 보여 주는 것은 모두 실패입니다. 이 기준은 macOS, Linux, Windows의 Kotlin/Native 경로와 GraalVM 경로 모두에 같게 적용되고, 일치 시험(`parity/`)의 리사이즈 항목도 이 비율로 판정합니다. Windows에서는 크기가 바뀌는 순간 `ResizeBuffers`, Skia 그리기, `Present`, DirectComposition `Commit`을 차례로 마친 뒤에 크기 변경 메시지를 돌려줍니다. +4. **크기를 바꾸는 동안 화면에 나오는 프레임은 모두 그 순간의 창 크기로 Skia가 그린 프레임입니다.** 측정 기준은 "현재 창 크기와 다른 크기로 그려진 프레임의 비율 = 0"입니다. 배경색으로 빈 곳을 가리는 것, 이전 프레임을 늘리는 것, 이전 프레임을 그대로 보여 주는 것은 모두 실패입니다. 이 기준은 macOS, Linux, Windows의 Kotlin/Native 경로와 GraalVM 경로 모두에 같게 적용되고, 일치 시험(`parity/`)의 리사이즈 항목도 이 비율로 판정합니다. Windows에서는 크기가 바뀌는 동안 GPU 자식 창을 숨기고, 그 크기의 프레임을 Skia 래스터 백엔드로 DIB에 그려 `BitBlt`로 최상위 창의 리디렉션 표면에 복사한 뒤에 `WM_SIZE`를 돌려줍니다. 크기가 멈추면 자식 창의 copy-model 스왑체인(GPU)으로 돌아갑니다. `DXC_RASTER_RESIZE=0`이면 크기가 바뀌는 동안에도 GPU에 남아 `ResizeBuffers`, Skia 그리기, `Present`, `DwmFlush`를 차례로 마친 뒤에 `WM_SIZE`를 돌려줍니다. 어느 경로도 DirectComposition을 쓰지 않습니다. ### FR-20 반응형 레이아웃 기반 (창 크기 클래스) (`Done`) From 085ca850dfa39807090faf6d1c3810294d75edc2 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:29:26 +0900 Subject: [PATCH 002/209] Test: Make the Windows resize probe show whether it can tell late frames from prompt ones On CI hand-check passes with resize frames on the CPU and on the GPU alike, so the probe has never shown it can tell a late frame from a prompt one, and Windows 11 26H2 may hold a window's new size back until its content is ready, which would hide lateness on its own. - resize-control.c: a negative control built like the GPU resize path (redirected top level, child with a copy-model swapchain, refit, draw, Present, DwmFlush inside WM_SIZE) that presents every new size DXC_RESIZE_PRESENT_DELAY_MS (50) late during a drag. It draws a ruler, so a stretched or misplaced picture moves. - resize-probe.c: the Windows version with its UBR as the first line (resize-os-version.h, shared with the control); a stale check (the content's left zone must stay where it was at rest; FR-19.8 criterion 4 counts a stretched or old frame as a failure); the lag of the window's edge behind the cursor per frame and per drag, in px and ms; the window is put on the primary monitor's work area by the probe itself when it is not there (--place-after, default 20 s), at whatever size it settles. - run-probe-v2.ps1: drags the control at each rate too, writes the OS line at the top of each application log, and writes summary.md, where a renderer's result is INCONCLUSIVE (no discrimination) at a rate where the control passes. - The probe workflow runs on windows-2022 (20348) and windows-2025 (26100), checks the control was late, and puts each runner's table in the job summary. Refs #353 --- .github/scripts/resize-control.c | 309 +++++++++++++++++ .github/scripts/resize-os-version.h | 70 ++++ .github/scripts/resize-probe-README.txt | 59 +++- .github/scripts/resize-probe.c | 317 +++++++++++++++--- .github/scripts/run-probe-v2.ps1 | 115 ++++++- .../workflows/test-windows-resize-metrics.yml | 1 + .../workflows/test-windows-resize-probe.yml | 163 +++++---- 7 files changed, 893 insertions(+), 141 deletions(-) create mode 100644 .github/scripts/resize-control.c create mode 100644 .github/scripts/resize-os-version.h diff --git a/.github/scripts/resize-control.c b/.github/scripts/resize-control.c new file mode 100644 index 000000000..1a1d65238 --- /dev/null +++ b/.github/scripts/resize-control.c @@ -0,0 +1,309 @@ +/* + * resize-control: a window that is late on purpose, to show whether resize-probe can see + * lateness at all on the machine it runs on. + * + * It is built the way the renderer's window draws a resize on the GPU (DXC_RASTER_RESIZE=0): + * a top-level window with its redirection surface and no background brush, a child window + * over its client area, and on the child a copy-model swapchain (DXGI_SWAP_EFFECT_SEQUENTIAL, + * one buffer, DXGI_SCALING_STRETCH). On WM_SIZE it refits the swapchain to the new client + * size, draws, presents, fits the child and waits for DWM (DwmFlush), all before WM_SIZE + * returns. The one difference: during a drag it first sleeps DXC_RESIZE_PRESENT_DELAY_MS + * milliseconds (50 when not set), so every new size's picture is that much late. + * + * Where Windows shows the window at its new size before its picture is there, that lateness + * is on screen (an unpainted strip at the right, the old picture stretched or in the wrong + * place), and the probe must report FAIL for this window. Where it does not, Windows is + * holding the window's new size back until the picture is ready, and a PASS from the probe + * for any window on that machine says nothing about how promptly that window draws: the + * probe cannot tell late from prompt there. + * + * What it draws is made for the probe's stale check: a light grey field with a dark 2 px line + * every 24 px from the left, and a blue band along the right edge. A picture drawn for one + * width and shown at another moves the lines. + * + * It opens at the primary monitor's work area's top left, 640x480 pixels, as hand-check does + * with DXC_REAL_DRAG=external, and closes itself after --seconds (default 300) or when closed. + * + * resize-control.exe [--delay-ms N] [--seconds N] + * + * --delay-ms overrides DXC_RESIZE_PRESENT_DELAY_MS. DXC_D3D12_WARP=1 draws with WARP, the + * software adapter, as the renderer does with that variable. Lines go to standard error. + */ +#define _WIN32_WINNT 0x0A00 +#define WIN32_LEAN_AND_MEAN +#define UNICODE +#define _UNICODE +#define COBJMACROS +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include +#include +#include +#include + +#include "resize-os-version.h" + +#pragma comment(lib, "user32.lib") +#pragma comment(lib, "d3d11.lib") +#pragma comment(lib, "dxgi.lib") +#pragma comment(lib, "dxguid.lib") +#pragma comment(lib, "dwmapi.lib") + +#define CONTROL_CLASS L"ResizeControlWindow" +#define SURFACE_CLASS L"ResizeControlSurface" +#define RULER_STEP 24 +#define RULER_WIDTH 2 +#define BAND_WIDTH 8 +#define MAX_LINES 512 + +static HWND window; +static HWND surface; +static ID3D11Device *device; +static ID3D11DeviceContext *context; +static ID3D11DeviceContext1 *context1; +static IDXGISwapChain1 *swapchain; +static int buffer_width, buffer_height; +static int delay_ms = 50; +static int sizing; +static long steps; +static LARGE_INTEGER frequency; + +static long long now_qpc(void) { + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + return now.QuadPart; +} + +/* Refits the swapchain to width x height when it is another size, draws the ruler and presents. */ +static int draw(int width, int height) { + if (swapchain == NULL || width <= 0 || height <= 0) return 0; + if (width != buffer_width || height != buffer_height) { + HRESULT resized = IDXGISwapChain1_ResizeBuffers(swapchain, 0, (UINT)width, (UINT)height, DXGI_FORMAT_UNKNOWN, 0); + if (FAILED(resized)) { + fprintf(stderr, "resize-control: ResizeBuffers %dx%d failed (0x%08lx)\n", width, height, (unsigned long)resized); + return 0; + } + buffer_width = width; + buffer_height = height; + } + ID3D11Texture2D *buffer = NULL; + if (FAILED(IDXGISwapChain1_GetBuffer(swapchain, 0, &IID_ID3D11Texture2D, (void **)&buffer))) return 0; + ID3D11RenderTargetView *target = NULL; + HRESULT made = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)buffer, NULL, &target); + ID3D11Texture2D_Release(buffer); + if (FAILED(made)) return 0; + const float field[4] = {0.88f, 0.88f, 0.88f, 1.0f}; + const float line[4] = {0.25f, 0.25f, 0.25f, 1.0f}; + const float band[4] = {0.10f, 0.35f, 0.80f, 1.0f}; + ID3D11DeviceContext_ClearRenderTargetView(context, target, field); + if (context1 != NULL) { + D3D11_RECT lines[MAX_LINES]; + UINT count = 0; + for (int x = RULER_STEP; x + RULER_WIDTH <= width - BAND_WIDTH - 4 && count < MAX_LINES; x += RULER_STEP) { + lines[count].left = x; + lines[count].top = 0; + lines[count].right = x + RULER_WIDTH; + lines[count].bottom = height; + count++; + } + if (count > 0) ID3D11DeviceContext1_ClearView(context1, (ID3D11View *)target, line, lines, count); + D3D11_RECT edge; + edge.left = width > BAND_WIDTH ? width - BAND_WIDTH : 0; + edge.top = 0; + edge.right = width; + edge.bottom = height; + ID3D11DeviceContext1_ClearView(context1, (ID3D11View *)target, band, &edge, 1); + } + ID3D11RenderTargetView_Release(target); + HRESULT shown = IDXGISwapChain1_Present(swapchain, 0, 0); + if (FAILED(shown)) { + fprintf(stderr, "resize-control: Present %dx%d failed (0x%08lx)\n", width, height, (unsigned long)shown); + return 0; + } + return 1; +} + +static LRESULT CALLBACK surface_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { + if (message == WM_PAINT) { + ValidateRect(hwnd, NULL); + return 0; + } + if (message == WM_ERASEBKGND) return 1; + if (message == WM_NCHITTEST) return HTTRANSPARENT; + return DefWindowProcW(hwnd, message, wparam, lparam); +} + +static LRESULT CALLBACK control_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { + switch (message) { + case WM_ENTERSIZEMOVE: + sizing = 1; + return 0; + case WM_EXITSIZEMOVE: + sizing = 0; + fprintf(stderr, "resize-control: drag done steps=%ld\n", steps); + return 0; + case WM_SIZE: + if (wparam != SIZE_MINIMIZED && swapchain != NULL) { + int width = (int)LOWORD(lparam); + int height = (int)HIWORD(lparam); + long long asked = now_qpc(); + int late = sizing && delay_ms > 0; + if (late) Sleep((DWORD)delay_ms); + int drawn = draw(width, height); + long long presented = now_qpc(); + if (surface != NULL) { + SetWindowPos(surface, NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); + } + DwmFlush(); + if (sizing) { + steps++; + fprintf(stderr, "resize-control: step n=%ld %dx%d qpc_size=%lld qpc_present=%lld late_ms=%.1f drawn=%d\n", + steps, width, height, asked, presented, + (double)(presented - asked) * 1000.0 / (double)frequency.QuadPart, drawn); + } + } + return 0; + case WM_PAINT: { + PAINTSTRUCT paint; + BeginPaint(hwnd, &paint); + EndPaint(hwnd, &paint); + RECT client; + GetClientRect(hwnd, &client); + if (!sizing) draw(client.right, client.bottom); + return 0; + } + case WM_ERASEBKGND: + return 1; + case WM_TIMER: + DestroyWindow(hwnd); + return 0; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + default: + return DefWindowProcW(hwnd, message, wparam, lparam); + } +} + +static const char *argument(int argc, char **argv, const char *name, const char *fallback) { + for (int index = 1; index + 1 < argc; index++) { + if (strcmp(argv[index], name) == 0) return argv[index + 1]; + } + return fallback; +} + +int main(int argc, char **argv) { + SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + QueryPerformanceFrequency(&frequency); + const char *asked = getenv("DXC_RESIZE_PRESENT_DELAY_MS"); + if (asked != NULL && asked[0] != 0) delay_ms = atoi(asked); + const char *flag = argument(argc, argv, "--delay-ms", NULL); + if (flag != NULL) delay_ms = atoi(flag); + int seconds = atoi(argument(argc, argv, "--seconds", "300")); + const char *warp = getenv("DXC_D3D12_WARP"); + int use_warp = warp != NULL && strcmp(warp, "1") == 0; + + char os_line[512]; + resize_os_version(os_line, sizeof os_line); + fprintf(stderr, "resize-control: os %s\n", os_line); + fprintf(stderr, "resize-control: start qpc_frequency=%lld present_delay_ms=%d adapter=%s\n", + (long long)frequency.QuadPart, delay_ms, use_warp ? "warp" : "hardware"); + + WNDCLASSEXW description; + memset(&description, 0, sizeof description); + description.cbSize = sizeof description; + description.style = CS_HREDRAW | CS_VREDRAW; + description.lpfnWndProc = control_proc; + description.hInstance = GetModuleHandleW(NULL); + description.hCursor = LoadCursorW(NULL, IDC_ARROW); + description.hbrBackground = NULL; + description.lpszClassName = CONTROL_CLASS; + if (RegisterClassExW(&description) == 0) return 2; + description.style = 0; + description.lpfnWndProc = surface_proc; + description.lpszClassName = SURFACE_CLASS; + if (RegisterClassExW(&description) == 0) return 2; + + POINT origin = {0, 0}; + MONITORINFO monitor; + memset(&monitor, 0, sizeof monitor); + monitor.cbSize = sizeof monitor; + GetMonitorInfoW(MonitorFromPoint(origin, MONITOR_DEFAULTTOPRIMARY), &monitor); + window = CreateWindowExW(0, CONTROL_CLASS, L"resize control", WS_OVERLAPPEDWINDOW, monitor.rcWork.left, + monitor.rcWork.top, 640, 480, NULL, NULL, GetModuleHandleW(NULL), NULL); + if (window == NULL) { + fprintf(stderr, "resize-control: could not make the window (%lu)\n", (unsigned long)GetLastError()); + return 2; + } + RECT client; + GetClientRect(window, &client); + surface = CreateWindowExW(0, SURFACE_CLASS, L"", WS_CHILD | WS_VISIBLE, 0, 0, client.right, client.bottom, window, + NULL, GetModuleHandleW(NULL), NULL); + + D3D_FEATURE_LEVEL levels[] = {D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0}; + HRESULT made = D3D11CreateDevice(NULL, use_warp ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_HARDWARE, NULL, + D3D11_CREATE_DEVICE_BGRA_SUPPORT, levels, 2, D3D11_SDK_VERSION, &device, NULL, + &context); + if (FAILED(made)) { + fprintf(stderr, "resize-control: no Direct3D 11 device (0x%08lx)\n", (unsigned long)made); + return 2; + } + if (FAILED(ID3D11DeviceContext_QueryInterface(context, &IID_ID3D11DeviceContext1, (void **)&context1))) { + context1 = NULL; + fprintf(stderr, "resize-control: no ID3D11DeviceContext1, so no ruler: the stale check has nothing to see\n"); + } + IDXGIDevice *dxgi_device = NULL; + IDXGIAdapter *adapter = NULL; + IDXGIFactory2 *factory = NULL; + ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); + if (dxgi_device != NULL) IDXGIDevice_GetAdapter(dxgi_device, &adapter); + if (adapter != NULL) IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory2, (void **)&factory); + if (factory == NULL || surface == NULL) { + fprintf(stderr, "resize-control: no DXGI factory or child window\n"); + return 2; + } + DXGI_ADAPTER_DESC adapter_description; + memset(&adapter_description, 0, sizeof adapter_description); + IDXGIAdapter_GetDesc(adapter, &adapter_description); + DXGI_SWAP_CHAIN_DESC1 swapchain_description; + memset(&swapchain_description, 0, sizeof swapchain_description); + swapchain_description.Width = (UINT)client.right; + swapchain_description.Height = (UINT)client.bottom; + swapchain_description.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + swapchain_description.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapchain_description.BufferCount = 1; + swapchain_description.SampleDesc.Count = 1; + swapchain_description.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; + swapchain_description.Scaling = DXGI_SCALING_STRETCH; + swapchain_description.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; + made = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)device, surface, &swapchain_description, NULL, NULL, + &swapchain); + if (FAILED(made)) { + fprintf(stderr, "resize-control: no swapchain (0x%08lx)\n", (unsigned long)made); + return 2; + } + buffer_width = client.right; + buffer_height = client.bottom; + fprintf(stderr, "resize-control: swapchain on a child window, copy model (sequential), 1 buffer, STRETCH, %ldx%ld, on %ls\n", + client.right, client.bottom, adapter_description.Description); + + ShowWindow(window, SW_SHOWNORMAL); + draw(client.right, client.bottom); + UpdateWindow(window); + SetForegroundWindow(window); + if (seconds > 0) SetTimer(window, 1, (UINT)seconds * 1000u, NULL); + RECT outer; + GetWindowRect(window, &outer); + fprintf(stderr, "resize-control: ready at %ld,%ld %ldx%ld px, dpi %u, frames late by %d ms during a drag\n", + outer.left, outer.top, outer.right - outer.left, outer.bottom - outer.top, GetDpiForWindow(window), delay_ms); + + MSG message; + while (GetMessageW(&message, NULL, 0, 0) > 0) { + TranslateMessage(&message); + DispatchMessageW(&message); + } + fprintf(stderr, "resize-control: closed after %ld drag steps\n", steps); + return 0; +} diff --git a/.github/scripts/resize-os-version.h b/.github/scripts/resize-os-version.h new file mode 100644 index 000000000..033237f38 --- /dev/null +++ b/.github/scripts/resize-os-version.h @@ -0,0 +1,70 @@ +/* + * The Windows version a resize result was measured on, as one line: the kernel's own version + * (RtlGetVersion, which no compatibility shim rewrites, unlike GetVersionEx) and, from + * HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion, the update build revision (UBR), the + * feature update's name (DisplayVersion, "24H2") and the product name. + * + * Whether a window's frame waits for its content during a live resize changes between builds + * of Windows, so a resize result means nothing without the full build it was taken on: + * 10.0.26100.6584, not "Windows 11". + * + * Header only, shared by resize-probe.c and resize-control.c. Needs advapi32.lib. + */ +#ifndef RESIZE_OS_VERSION_H +#define RESIZE_OS_VERSION_H + +#include +#include +#include + +#pragma comment(lib, "advapi32.lib") + +typedef LONG(WINAPI *resize_rtl_get_version_fn)(OSVERSIONINFOW *); + +static void resize_registry_string(const wchar_t *name, char *into, size_t size) { + wchar_t value[128]; + DWORD bytes = sizeof value; + into[0] = 0; + if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", name, + RRF_RT_REG_SZ, NULL, value, &bytes) == ERROR_SUCCESS) { + WideCharToMultiByte(CP_UTF8, 0, value, -1, into, (int)size, NULL, NULL); + } else { + snprintf(into, size, "unknown"); + } +} + +/* + * Writes "windows 10.0.. (build , ubr , display_version <...>, + * product \"<...>\", installation_type <...>)" into line. + */ +static void resize_os_version(char *line, size_t size) { + OSVERSIONINFOW version; + memset(&version, 0, sizeof version); + version.dwOSVersionInfoSize = sizeof version; + resize_rtl_get_version_fn get_version = + (resize_rtl_get_version_fn)(void *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion"); + if (get_version == NULL || get_version(&version) != 0) { + version.dwMajorVersion = version.dwMinorVersion = version.dwBuildNumber = 0; + } + DWORD ubr = 0; + DWORD bytes = sizeof ubr; + int have_ubr = RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"UBR", + RRF_RT_REG_DWORD, NULL, &ubr, &bytes) == ERROR_SUCCESS; + char display_version[64], product[128], installation[64]; + resize_registry_string(L"DisplayVersion", display_version, sizeof display_version); + resize_registry_string(L"ProductName", product, sizeof product); + resize_registry_string(L"InstallationType", installation, sizeof installation); + char revision[24]; + if (have_ubr) { + snprintf(revision, sizeof revision, "%lu", (unsigned long)ubr); + } else { + snprintf(revision, sizeof revision, "unknown"); + } + snprintf(line, size, + "windows %lu.%lu.%lu.%s (build %lu, ubr %s, display_version %s, product \"%s\", installation_type %s)", + (unsigned long)version.dwMajorVersion, (unsigned long)version.dwMinorVersion, + (unsigned long)version.dwBuildNumber, revision, (unsigned long)version.dwBuildNumber, revision, + display_version, product, installation); +} + +#endif diff --git a/.github/scripts/resize-probe-README.txt b/.github/scripts/resize-probe-README.txt index 3bf0a4af0..125f84afa 100644 --- a/.github/scripts/resize-probe-README.txt +++ b/.github/scripts/resize-probe-README.txt @@ -11,14 +11,35 @@ What it does Magenta inside the window (the window's frame is there, its picture is not) or black inside the window is a failure. + It also checks that each frame's picture is the one for the window's size at that moment: + while the right edge moves, the left part of the content stays where it is, so a frame in + which it has moved (a picture drawn for another width and stretched, or the old picture in + the new rectangle) is stale, and a failure too. And it measures how far the window's right + edge lags the cursor, in pixels and in milliseconds: a window can show no blank area and + still trail the mouse. + Do not touch the mouse while it runs: the probe is moving it. -The quick way: both apps, both paths, all three rates +Why there is a control window + Some builds of Windows hold a window's new size back until the window has drawn for it. + There, a late frame never reaches the screen and the probe sees nothing wrong, whatever the + window does. So a PASS only means something where the probe can be shown to catch a late + window. resize-control.exe is that window: built like the renderer's GPU resize path, but + every new size is presented 50 ms late (DXC_RESIZE_PRESENT_DELAY_MS, 50 by default). Where + the probe FAILs it, the results for hand-check at the same mouse rate stand. Where it PASSes + it, hand-check's results are INCONCLUSIVE: Windows is hiding lateness there. + + Every probe log starts with the Windows version (resize-probe: os windows 10.0.BUILD.UBR ...), + and run-probe-v2 writes the same line at the top of each application log, because whether + Windows hides late frames depends on the build. + +The quick way: every app, every path, all three rates Double-click run-probe-v2.cmd (or run run-probe-v2.ps1 in PowerShell) and do not touch the - mouse until it says "Done". It drags hand-check.exe (the Kotlin/Native renderer) and then - graalvm\bin\hand-check.exe (the GraalVM native image renderer), each with resize frames on - the CPU (new) and on the GPU (old, DXC_RASTER_RESIZE=0), at 16, 8 and 1 ms per mouse move, - and zips the logs into probe-logs.zip. Send that file. + mouse until it says "Done". It drags hand-check.exe (the Kotlin/Native renderer), then + graalvm\bin\hand-check.exe (the GraalVM native image renderer) when it is there, each with + resize frames on the CPU (new) and on the GPU (old, DXC_RASTER_RESIZE=0), and then the + control window (late), at 16, 8 and 1 ms per mouse move. It prints a table of the results, + writes it to probe-logs\summary.md, and zips the logs into probe-logs.zip. Send that file. Then check by hand, in each app (hand-check.exe and graalvm\bin\hand-check.exe), in the first text field: type a few letters, press Ctrl+A (all of it is selected), Ctrl+C, click @@ -66,10 +87,18 @@ How to run one drag by hand (PowerShell, in the folder that holds hand-check.exe --travel N (how far out, default to the right edge of the work area less 16 px), --out FILE (default: the console), --class NAME (window class, default ComposeRustWindow), --wait-seconds N (how long to wait for the window, default 180), --place (put the window at - the work area's top left at 640x480 from the probe, for an application that does not do it - itself: the GraalVM renderer, which has no DXC_REAL_DRAG hook). + the primary monitor's work area's top left at 640x480 from the probe as soon as it holds + still, for an application that does not do it itself: the GraalVM renderer, which has no + DXC_REAL_DRAG hook), --place-after N (without --place, the probe puts the window there itself + when it is not there after N seconds, default 20: when it opened on another monitor, say). + The drag always happens on the primary monitor, which is the one recorded. + + The control window: resize-control.exe [--delay-ms N] [--seconds N], with --class + ResizeControlWindow on the probe. It opens on the primary monitor's top left by itself. What the output means (probe log) + os windows ... the Windows version: build, update build revision (UBR), + DisplayVersion (24H2, ...), product name, client or server duplicating ... the monitor and graphics adapter being recorded background captured ... the desktop it compares against window ... (ready) the window settled at the top left and the drag can start: its @@ -78,8 +107,12 @@ What the output means (probe log) window's rectangle, its visible frame and its client area are, in physical pixels and in the window's logical pixels. The window must be on the captured monitor and its client area inside it. + placed the window ... the probe moved the window to the primary monitor itself client ... edge_offset where the rows are, and how far past the picture's right edge the - window's frame and shadow reach + window's frame and shadow reach; rest_offset, how far right of the + cursor the window's edge is at rest + stale reference ... the zone the stale check compares, and how many of its rows have + enough sharp steps in brightness to be judged send n=... qpc=... every mouse event, when it was sent (QPC) and where the cursor was move-size loop entered Windows started its sizing loop; "NOT entered" is a failure of the drag itself, not of the window @@ -95,11 +128,19 @@ What the output means (probe log) differ by more than 2 px, a frame showing two sizes at once strip_hole_rows rows with backdrop inside the window, and the first such pixel strip_black_rows rows with black inside the window + edge_rows/stale_rows rows judged by the stale check, and those whose content had moved; + stale=1 when 30% of them had, a picture not at the window's size + lag_px how far the window's right edge is from where the cursor was + when the frame was shown (positive: behind it going out) + lag_ms how long ago the cursor was where this frame's edge is (-1: not + in the last two seconds) runs0, runs1 each row near the window's right end: W window, D backdrop, S shadow over the backdrop, K black + lag ... the drag's lag: median, 95th percentile and largest, in pixels + (distance) and milliseconds summary / verdict PASS when the loop was entered, the window changed size, and no frame during the drag had desktop or black inside the window, - on the two rows or anywhere down the strip, or was torn + on the two rows or anywhere down the strip, was torn, or was stale Exit code: 0 PASS, 1 FAIL, 2 could not run. hand-check log (with DXC_RESIZE_TRACE=1) diff --git a/.github/scripts/resize-probe.c b/.github/scripts/resize-probe.c index 28d650c72..4b6e47636 100644 --- a/.github/scripts/resize-probe.c +++ b/.github/scripts/resize-probe.c @@ -20,8 +20,21 @@ * start the application with DXC_REAL_DRAG=external. All times are QPC, the same clock the * application's DXC_RESIZE_TRACE lines use, so the two logs line up. * - * Exit status: 0 PASS, 1 FAIL (no move-size loop, no step, a hole or black inside the window), - * 2 could not run (no duplication, no window). + * Besides holes and black, each frame is checked for a stale picture: the left part of the + * window's content does not move while its right edge is dragged, so every frame must show it + * where it was at rest. A picture drawn for another width and stretched to this one (or the + * old picture shown in the new rectangle) moves it, and the frame counts as stale. And each + * frame's right edge is measured against where the cursor was when the frame was shown: how + * many pixels and milliseconds the window lags the mouse. A window can have no blank area and + * still lag; the lag says so. + * + * Whether the probe can tell a late frame from a prompt one at all depends on the build of + * Windows (some hold the window's new size back until its content is ready), so the first line + * is the Windows version, and resize-control.exe is the window to prove it with: one that + * presents 50 ms late on purpose, which must fail wherever the probe can see lateness. + * + * Exit status: 0 PASS, 1 FAIL (no move-size loop, no step, a hole, black or a stale picture + * inside the window), 2 could not run (no duplication, no window). */ #define _WIN32_WINNT 0x0A00 #define WIN32_LEAN_AND_MEAN @@ -43,6 +56,8 @@ #include #include +#include "resize-os-version.h" + #pragma comment(lib, "user32.lib") #pragma comment(lib, "gdi32.lib") #pragma comment(lib, "d3d11.lib") @@ -167,7 +182,22 @@ static int edge_offset; /* rightmost window pixel minus client right ed static long frames_total, frames_analysed, frames_with_hole, frames_with_black; static long long drag_from_qpc, drag_to_qpc; static long frames_in_drag, holes_in_drag, black_in_drag; -static long torn_in_drag, strip_holes_in_drag, strip_black_in_drag; +static long torn_in_drag, strip_holes_in_drag, strip_black_in_drag, stale_in_drag; + +/* + * Every mouse move the drag sent, when and where, so that each frame's right edge can be set + * against where the cursor was when the frame was shown. Written by the drag thread, read by + * the capture thread; send_count is raised after the entry is written. + */ +#define MAX_SENDS 65536 +static long long send_qpc[MAX_SENDS]; +static int send_x[MAX_SENDS]; +static volatile LONG send_count; +static int rest_offset; /* row 0's right end minus the cursor's x, at rest */ +static volatile LONG lag_ready; +static int lag_px_list[MAX_FRAMES]; +static double lag_ms_list[MAX_FRAMES]; +static int lag_count, lag_ms_count; /* * The strip: every second row of the client area from 24 px below its top to 24 px above @@ -185,7 +215,99 @@ struct strip_result { int right_min, right_max; int hole_rows, black_rows; int first_hole_y, first_hole_x; + int edge_rows, stale_rows; }; + +/* + * The stale check. While the right edge is dragged, the left part of the content stays where + * it is: the zone from the client's left edge across 60% of its width at rest. At rest, every + * strip row's sharp steps in brightness there (a rise or a fall of EDGE_STEP or more between + * two neighbouring pixels) are recorded. In a frame, a row whose recorded steps are mostly + * not found again (same direction, within a pixel) is stale, and a frame with STALE_SHARE of + * its rows stale shows a picture that is not at the window's size: stretched, or the old one + * shown in the new rectangle. Rows with fewer than EDGE_MIN steps are not judged. A pixel + * either way is allowed, because the picture at rest comes from the GPU and the one during + * the drag may be drawn on the CPU, and their antialiasing differs. + */ +#define EDGE_STEP 40 +#define EDGE_MATCH 20 +#define EDGE_MIN 6 +#define ROW_MATCH_PERCENT 70 +#define STALE_SHARE_PERCENT 30 +static signed char *reference_edges; /* per strip row (every second row), per zone pixel */ +static int reference_row_count; +static int zone_left; /* screen x */ +static int zone_width; +static volatile LONG reference_ready; + +static int luminance(uint32_t pixel) { + return (int)(((pixel >> 16) & 0xFF) * 2 + ((pixel >> 8) & 0xFF) * 5 + (pixel & 0xFF)) / 8; +} + +static signed char edge_at(const uint32_t *pixels, int x, int step) { + int d = luminance(pixels[x + 1]) - luminance(pixels[x]); + return d >= step ? 1 : d <= -step ? -1 : 0; +} + +/* Records the zone's steps on every strip row of the frame in `latest`, at rest. */ +static void capture_reference(void) { + if (strip_bottom <= strip_top || zone_width < 16) return; + D3D11_BOX box; + box.left = 0; + box.right = (UINT)desktop_width; + box.top = (UINT)(strip_top - desktop.top); + box.bottom = (UINT)(strip_bottom - desktop.top); + box.front = 0; + box.back = 1; + ID3D11DeviceContext_CopySubresourceRegion(context, (ID3D11Resource *)full_staging, 0, 0, box.top, 0, + (ID3D11Resource *)latest, 0, &box); + D3D11_MAPPED_SUBRESOURCE mapped; + if (FAILED(ID3D11DeviceContext_Map(context, (ID3D11Resource *)full_staging, 0, D3D11_MAP_READ, 0, &mapped))) return; + reference_row_count = (strip_bottom - strip_top + 1) / 2; + reference_edges = (signed char *)calloc((size_t)reference_row_count * zone_width, 1); + int left = zone_left - desktop.left; + long steps = 0; + int judged = 0; + for (int index = 0; reference_edges != NULL && index < reference_row_count; index++) { + int y = strip_top + index * 2; + const uint32_t *pixels = (const uint32_t *)((const uint8_t *)mapped.pData + (size_t)(y - desktop.top) * mapped.RowPitch); + signed char *row = reference_edges + (size_t)index * zone_width; + int count = 0; + for (int x = 0; x + 1 < zone_width; x++) { + row[x] = edge_at(pixels, left + x, EDGE_STEP); + count += row[x] != 0; + } + steps += count; + judged += count >= EDGE_MIN; + } + ID3D11DeviceContext_Unmap(context, (ID3D11Resource *)full_staging, 0); + if (reference_edges != NULL) InterlockedExchange(&reference_ready, 1); + say("stale reference: zone x=%d..%d, %d rows, %d with at least %d steps, %ld steps", zone_left, + zone_left + zone_width - 1, reference_row_count, judged, EDGE_MIN, steps); +} + +/* 1 when the row at y has lost most of the steps it had at rest; -1 when it is not judged. */ +static int row_stale(const uint32_t *pixels, int y) { + int index = (y - strip_top) / 2; + if (!reference_ready || index < 0 || index >= reference_row_count) return -1; + const signed char *row = reference_edges + (size_t)index * zone_width; + int left = zone_left - desktop.left; + int expected = 0, found = 0; + for (int x = 0; x + 1 < zone_width; x++) { + if (row[x] == 0) continue; + expected++; + for (int dx = -1; dx <= 1; dx++) { + int at = x + dx; + if (at < 0 || at + 1 >= zone_width) continue; + if (edge_at(pixels, left + at, EDGE_MATCH) == row[x]) { + found++; + break; + } + } + } + if (expected < EDGE_MIN) return -1; + return found * 100 < expected * ROW_MATCH_PERCENT; +} static int widths_seen[4096]; static int widths_seen_count; @@ -323,6 +445,11 @@ static void analyse_strip(struct strip_result *result) { } result->hole_rows += hole; result->black_rows += black; + int stale = row_stale(pixels, y); + if (stale >= 0) { + result->edge_rows++; + result->stale_rows += stale; + } } ID3D11DeviceContext_Unmap(context, (ID3D11Resource *)full_staging, 0); if (result->rows == 0) result->right_min = result->right_max = -1 - desktop.left; @@ -332,6 +459,36 @@ static void analyse_strip(struct strip_result *result) { typedef HRESULT(WINAPI *timing_fn)(HWND, DWM_TIMING_INFO *); +/* + * How far the window's right edge (row 0's right end) is behind the cursor in the frame shown + * at `present`: in pixels, against the last move sent before it, and in milliseconds, back to + * the most recent move that put the cursor where this frame's edge is (-1 when none in the + * last two seconds). At rest the edge is rest_offset to the right of the cursor. + */ +static int lag_of(long long present, int observed, double *lag_ms) { + LONG count = send_count; + *lag_ms = -1.0; + int last = -1; + for (int low = 0, high = (int)count - 1; low <= high;) { + int middle = (low + high) / 2; + if (send_qpc[middle] <= present) { + last = middle; + low = middle + 1; + } else { + high = middle - 1; + } + } + if (last < 0) return 0; + for (int k = last; k >= 0 && ms_between(send_qpc[k], present) < 2000.0; k--) { + int expected = send_x[k] + rest_offset; + if (expected - observed <= 2 && observed - expected <= 2) { + *lag_ms = ms_between(send_qpc[k], present); + break; + } + } + return send_x[last] + rest_offset - observed; +} + static void analyse_latest(long long present, UINT accumulated, int calibrating) { D3D11_BOX box; for (int row = 0; row < ROWS; row++) { @@ -355,12 +512,17 @@ static void analyse_latest(long long present, UINT accumulated, int calibrating) InterlockedExchange(&last_right, results[0].right); if (calibrating) { say("calibration right=%d runs=%s raw=%s", results[0].right + desktop.left, results[0].runs, results[0].raw); + capture_reference(); return; } frames_analysed++; struct strip_result strip; analyse_strip(&strip); int torn = strip.rows > 0 && strip.right_max - strip.right_min > TORN_PX; + int stale = strip.edge_rows >= 4 && strip.stale_rows * 100 >= strip.edge_rows * STALE_SHARE_PERCENT; + int lag_px = 0; + double lag_ms = -1.0; + if (lag_ready && results[0].right >= 0) lag_px = lag_of(present, results[0].right + desktop.left, &lag_ms); int holes = results[0].holes + results[1].holes; int black = results[0].black + results[1].black; if (holes > 0) frames_with_hole++; @@ -375,7 +537,13 @@ static void analyse_latest(long long present, UINT accumulated, int calibrating) torn_in_drag += torn; strip_holes_in_drag += strip.hole_rows > 0; strip_black_in_drag += strip.black_rows > 0; + stale_in_drag += stale; if (inferred > 0) note_width(inferred); + if (lag_ready && results[0].right >= 0 && lag_count < MAX_FRAMES) { + /* Behind the cursor going out is positive, going back negative: the distance counts. */ + lag_px_list[lag_count++] = lag_px < 0 ? -lag_px : lag_px; + if (lag_ms >= 0.0) lag_ms_list[lag_ms_count++] = lag_ms; + } } static timing_fn timing; static int looked_up; @@ -391,13 +559,15 @@ static void analyse_latest(long long present, UINT accumulated, int calibrating) "resize-probe: frame n=%ld qpc_present=%lld accumulated=%u qpc_taken=%lld cframe=%llu qpc_compose=%llu " "qpc_vblank=%llu crefresh=%llu cframe_displayed=%llu in_drag=%d width=%d right0=%d right1=%d " "holes0=%d holes1=%d hole_from0=%d hole_from1=%d black=%d strip_rows=%d strip_right=%d-%d torn=%d " - "strip_hole_rows=%d strip_first_hole=%d,%d strip_black_rows=%d runs0=%s| runs1=%s| raw0=%s| raw1=%s\n", + "strip_hole_rows=%d strip_first_hole=%d,%d strip_black_rows=%d edge_rows=%d stale_rows=%d stale=%d " + "lag_px=%d lag_ms=%.1f runs0=%s| runs1=%s| raw0=%s| raw1=%s\n", frames_analysed, present, accumulated, now_qpc(), (unsigned long long)info.cFrame, (unsigned long long)info.qpcCompose, (unsigned long long)info.qpcVBlank, (unsigned long long)info.cRefresh, (unsigned long long)info.cFrameDisplayed, in_drag, inferred, results[0].right + desktop.left, results[1].right + desktop.left, results[0].holes, results[1].holes, results[0].hole_from, results[1].hole_from, black, strip.rows, strip.right_min, strip.right_max, torn, - strip.hole_rows, strip.first_hole_x, strip.first_hole_y, strip.black_rows, results[0].runs, results[1].runs, + strip.hole_rows, strip.first_hole_x, strip.first_hole_y, strip.black_rows, strip.edge_rows, strip.stale_rows, + stale, lag_px, lag_ms, results[0].runs, results[1].runs, results[0].raw, results[1].raw); } @@ -512,6 +682,12 @@ static void send_mouse(DWORD flags, int x, int y, long index) { input.mi.dwFlags = flags | MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK; long long before = now_qpc(); UINT sent = SendInput(1, &input, sizeof input); + LONG slot = send_count; + if (slot < MAX_SENDS) { + send_qpc[slot] = before; + send_x[slot] = x; + InterlockedExchange(&send_count, slot + 1); + } POINT cursor; GetCursorPos(&cursor); fprintf(out, "resize-probe: send n=%ld qpc=%lld x=%d y=%d flags=%lu sent=%u cursor=%ld,%ld\n", index, before, x, y, @@ -623,6 +799,16 @@ static void start_memory(HWND window) { CreateThread(NULL, 0, memory_thread, NULL, 0, NULL); } +static int compare_int(const void *a, const void *b) { + int left = *(const int *)a, right = *(const int *)b; + return (left > right) - (left < right); +} + +static int compare_double(const void *a, const void *b) { + double left = *(const double *)a, right = *(const double *)b; + return (left > right) - (left < right); +} + static const char *argument(int argc, char **argv, const char *name, const char *fallback) { for (int index = 1; index + 1 < argc; index++) { if (strcmp(argv[index], name) == 0) return argv[index + 1]; @@ -651,6 +837,7 @@ int main(int argc, char **argv) { int step_px = atoi(argument(argc, argv, "--step-px", "8")); int travel = atoi(argument(argc, argv, "--travel", "0")); int wait_seconds = atoi(argument(argc, argv, "--wait-seconds", "180")); + int place_after_seconds = atoi(argument(argc, argv, "--place-after", "20")); const char *class_name = argument(argc, argv, "--class", "ComposeRustWindow"); int turn_on_full_drag = 0, place = 0; for (int index = 1; index < argc; index++) { @@ -668,6 +855,9 @@ int main(int argc, char **argv) { DWORD aware_error = aware ? 0 : GetLastError(); QueryPerformanceFrequency(&frequency); timeBeginPeriod(1); + char os_line[512]; + resize_os_version(os_line, sizeof os_line); + say("os %s", os_line); say("start qpc_frequency=%lld interval_ms=%d step_px=%d", (long long)frequency.QuadPart, interval_ms, step_px); DPI_AWARENESS awareness = GetAwarenessFromDpiAwarenessContext(GetThreadDpiAwarenessContext()); say("dpi awareness %s (SetProcessDpiAwarenessContext %s, error %lu), system dpi %u", awareness_name(awareness), @@ -720,56 +910,56 @@ int main(int argc, char **argv) { return 2; } DWORD thread = GetWindowThreadProcessId(window, NULL); - if (place) { - /* - * --place: an application that does not put its window in place for the drag (the - * GraalVM renderer has no DXC_REAL_DRAG hook) has it put there from here, once it is - * showing and has stopped moving: the work area's top left, 640x480 pixels asked for. - */ - RECT before, now; - GetWindowRect(window, &before); - int still = 0; - for (int waited = 0; waited < wait_seconds * 1000 && IsWindow(window) && still < 1000; waited += 50) { - Sleep(50); - GetWindowRect(window, &now); - still = IsWindowVisible(window) && EqualRect(&now, &before) ? still + 50 : 0; - before = now; - } - MONITORINFO work; - memset(&work, 0, sizeof work); - work.cbSize = sizeof work; - GetMonitorInfoW(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), &work); - BOOL placed = SetWindowPos(window, NULL, work.rcWork.left, work.rcWork.top, 640, 480, - SWP_NOZORDER | SWP_NOACTIVATE); - say("placed the window at %ld,%ld asking for 640x480 px: %s", work.rcWork.left, work.rcWork.top, - placed ? "ok" : "FAILED"); - } /* - * Ready: the application (DXC_REAL_DRAG=external) moves its window to the top left of the - * work area and asks for 640x480 pixels. What it gets can be larger, because the window's - * minimum size is in logical pixels: at 200% the minimum is twice as many physical pixels, - * and 640x480 is below it. So the probe does not wait for 640x480. It waits for the window - * to have left where it opened, to sit at the work area's top left, at least 640x480, and - * to hold that rectangle for a second, and takes whatever size that is. + * Ready: the window sits on the primary monitor, the one captured, at its work area's top + * left, at least 640x480 pixels, and has held that rectangle for a second. + * + * The application (DXC_REAL_DRAG=external) moves its window to the top left of the work + * area of the monitor it opened on and asks for 640x480 pixels. What it gets can be larger, + * because the window's minimum size is in logical pixels: at 200% the minimum is twice as + * many physical pixels, and 640x480 is below it. So the probe takes whatever size the + * window settles at. When the window opened on another monitor, or the application does not + * place it at all (--place: the GraalVM renderer has no DXC_REAL_DRAG hook), the probe puts + * it there itself, once it has held still for a second: on its own after --place-after + * seconds (default 20), at once with --place. Moving to a monitor of another scale changes + * the window's size as it arrives, so it is placed up to three times. */ + MONITORINFO work; + memset(&work, 0, sizeof work); + work.cbSize = sizeof work; + GetMonitorInfoW(desktop_monitor, &work); RECT first, outer, last; GetWindowRect(window, &first); outer = last = first; - int moved = 0, held = 0, settled = 0; - MONITORINFO placed_on; + int moved = 0, held = 0, still = 0, settled = 0, placements = 0, next_placement = 0; for (int waited = 0; waited < wait_seconds * 1000 && IsWindow(window); waited += 50) { Sleep(50); GetWindowRect(window, &outer); if (!EqualRect(&outer, &first)) moved = 1; - memset(&placed_on, 0, sizeof placed_on); - placed_on.cbSize = sizeof placed_on; - GetMonitorInfoW(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), &placed_on); - int placed = outer.left == placed_on.rcWork.left && outer.top == placed_on.rcWork.top && + int on_primary = MonitorFromWindow(window, MONITOR_DEFAULTTONULL) == desktop_monitor; + int placed = on_primary && outer.left == work.rcWork.left && outer.top == work.rcWork.top && outer.right - outer.left >= 640 && outer.bottom - outer.top >= 480; - held = placed && EqualRect(&outer, &last) ? held + 50 : 0; + int same = EqualRect(&outer, &last); + still = IsWindowVisible(window) && same ? still + 50 : 0; + held = placed && same ? held + 50 : 0; last = outer; /* Opened in place already: then only time tells that nothing is still to come. */ - if (held >= 1000 && (moved || waited >= 5000)) { settled = 1; break; } + if (held >= 1000 && (moved || placements > 0 || waited >= 5000)) { + settled = 1; + break; + } + int ours = place || waited >= place_after_seconds * 1000; + if (!placed && ours && still >= 1000 && placements < 3 && waited >= next_placement) { + BOOL done = SetWindowPos(window, NULL, work.rcWork.left, work.rcWork.top, 640, 480, + SWP_NOZORDER | SWP_NOACTIVATE); + placements++; + next_placement = waited + 3000; + still = 0; + say("placed the window from the probe (attempt %d): at %ld,%ld on the primary monitor, asking for " + "640x480 px: %s; it was at %ld,%ld %ldx%ld px on %s", + placements, work.rcWork.left, work.rcWork.top, done ? "ok" : "FAILED", outer.left, outer.top, + outer.right - outer.left, outer.bottom - outer.top, on_primary ? "the primary monitor" : "another monitor"); + } } if (!IsWindow(window)) { say("verdict ERROR: the window closed before it was ready for the drag"); @@ -817,9 +1007,9 @@ int main(int argc, char **argv) { } say_rect("client (ClientToScreen)", &client_screen, scale); if (!settled) { - say("verdict ERROR: the window never settled at the work area's top left (at least 640x480 px, still for " - "1 s) in %d s; is the application running with DXC_METRICS=1 and DXC_REAL_DRAG=external?", - wait_seconds); + say("verdict ERROR: the window never settled at the primary monitor's work area's top left (at least " + "640x480 px, still for 1 s) in %d s, after %d placements from the probe", + wait_seconds, placements); return 2; } /* @@ -845,6 +1035,9 @@ int main(int argc, char **argv) { strip_bottom = origin.y + client.bottom - STRIP_MARGIN; if (strip_top < desktop.top) strip_top = desktop.top; if (strip_bottom > desktop.bottom) strip_bottom = desktop.bottom; + zone_left = origin.x + 2; + zone_width = client.right * 3 / 5; + if (zone_left + zone_width > desktop.right - 1) zone_width = desktop.right - 1 - zone_left; if (travel <= 0) travel = (int)(monitor.rcWork.right - outer.right) - 16; /* * The backdrop goes directly behind the window, above everything else: the runner's @@ -857,12 +1050,17 @@ int main(int argc, char **argv) { InterlockedExchange(&calibrate_request, 1); for (int waited = 0; calibrate_request && waited < 2000; waited += 10) Sleep(10); int right = (int)last_right; + /* Where the drag presses: on the right edge's resize border, at the client's middle height. */ + int x = outer.right - 3; + int y = origin.y + client.bottom / 2; if (right >= 0) { edge_offset = right + desktop.left - (origin.x + client.right); + rest_offset = right + desktop.left - x; InterlockedExchange(&calibrated, 1); + InterlockedExchange(&lag_ready, 1); } - say("client %ldx%ld at %ld,%ld rows y=%d,%d edge_offset=%d travel=%d", client.right, client.bottom, origin.x, - origin.y, row_y[0], row_y[1], edge_offset, travel); + say("client %ldx%ld at %ld,%ld rows y=%d,%d edge_offset=%d travel=%d rest_offset=%d", client.right, client.bottom, + origin.x, origin.y, row_y[0], row_y[1], edge_offset, travel, rest_offset); if (right < 0 || right + desktop.left >= desktop.right - 2) { say("verdict ERROR: the backdrop does not show beside the window (row ends at %d), so holes could not be seen", right + desktop.left); @@ -902,8 +1100,6 @@ int main(int argc, char **argv) { say_memory("start", sample_memory()); /* The drag. */ - int x = outer.right - 3; - int y = origin.y + client.bottom / 2; long sends = 0; send_mouse(0, x, y, sends++); Sleep(200); @@ -959,16 +1155,27 @@ int main(int argc, char **argv) { if (turned_on) SystemParametersInfoW(SPI_SETDRAGFULLWINDOWS, FALSE, NULL, SPIF_SENDCHANGE); int failed = !looping || widths_seen_count < 2 || holes_in_drag > 0 || black_in_drag > 0 || torn_in_drag > 0 || - strip_holes_in_drag > 0 || strip_black_in_drag > 0; + strip_holes_in_drag > 0 || strip_black_in_drag > 0 || stale_in_drag > 0; + /* + * The lag of the window's right edge behind the cursor over the drag's frames. A window + * whose frame waits for its content shows no hole and still lags; this is where it shows. + */ + qsort(lag_px_list, (size_t)lag_count, sizeof *lag_px_list, compare_int); + qsort(lag_ms_list, (size_t)lag_ms_count, sizeof *lag_ms_list, compare_double); + say("lag frames=%d px_median=%d px_p95=%d px_max=%d ms_frames=%d ms_median=%.1f ms_p95=%.1f ms_max=%.1f", + lag_count, lag_count ? lag_px_list[lag_count / 2] : -1, lag_count ? lag_px_list[(lag_count * 95) / 100] : -1, + lag_count ? lag_px_list[lag_count - 1] : -1, lag_ms_count, lag_ms_count ? lag_ms_list[lag_ms_count / 2] : -1.0, + lag_ms_count ? lag_ms_list[(lag_ms_count * 95) / 100] : -1.0, lag_ms_count ? lag_ms_list[lag_ms_count - 1] : -1.0); say("summary frames_total=%ld frames_analysed=%ld frames_in_drag=%ld distinct_widths_in_drag=%d " "frames_with_hole_in_drag=%ld frames_with_black_in_drag=%ld frames_with_hole_all=%ld " - "strip_frames_torn_in_drag=%ld strip_frames_with_hole_in_drag=%ld strip_frames_with_black_in_drag=%ld", + "strip_frames_torn_in_drag=%ld strip_frames_with_hole_in_drag=%ld strip_frames_with_black_in_drag=%ld " + "frames_stale_in_drag=%ld", frames_total, frames_analysed, frames_in_drag, widths_seen_count, holes_in_drag, black_in_drag, - frames_with_hole, torn_in_drag, strip_holes_in_drag, strip_black_in_drag); + frames_with_hole, torn_in_drag, strip_holes_in_drag, strip_black_in_drag, stale_in_drag); say("verdict %s (loop %s, %d widths seen, %ld frames with desktop inside the window, %ld with black; " - "full height: %ld torn, %ld with desktop, %ld with black)", + "full height: %ld torn, %ld with desktop, %ld with black; %ld stale)", failed ? "FAIL" : "PASS", looping ? "entered" : "not entered", widths_seen_count, holes_in_drag, - black_in_drag, torn_in_drag, strip_holes_in_drag, strip_black_in_drag); + black_in_drag, torn_in_drag, strip_holes_in_drag, strip_black_in_drag, stale_in_drag); if (out != stdout) fclose(out); return failed ? 1 : 0; } diff --git a/.github/scripts/run-probe-v2.ps1 b/.github/scripts/run-probe-v2.ps1 index 7b100fd58..f3cefc13c 100644 --- a/.github/scripts/run-probe-v2.ps1 +++ b/.github/scripts/run-probe-v2.ps1 @@ -1,13 +1,22 @@ -# Real drags of hand-check's right edge driven by resize-probe, for both Windows renderers in +# Real drags of a window's right edge driven by resize-probe, for both Windows renderers in # turn: the Kotlin/Native one (hand-check.exe) and the GraalVM native image one -# (graalvm\bin\hand-check.exe). Each is dragged with resize frames on the CPU (new) and on the -# GPU (old, DXC_RASTER_RESIZE=0), at three mouse rates. Logs go to probe-logs\ and -# probe-logs.zip. Do not touch the mouse while it runs. +# (graalvm\bin\hand-check.exe), and for the control window (resize-control.exe). Each renderer +# is dragged with resize frames on the CPU (new) and on the GPU (old, DXC_RASTER_RESIZE=0); the +# control presents every size 50 ms late on purpose (late). All at three mouse rates. Logs go to +# probe-logs\ and probe-logs.zip, with summary.md, the table of results. Do not touch the mouse +# while it runs. # -# -NoPause skips the closing prompt (CI). -Out puts the logs somewhere else. +# The control decides what the renderers' results mean on this machine. Where the probe sees +# the control's lateness (the control FAILs), a renderer's PASS or FAIL at the same mouse rate +# stands. Where it does not (the control PASSes), Windows itself is hiding late frames here, so +# a renderer's result at that rate is INCONCLUSIVE: the probe cannot tell late from prompt. +# +# -NoPause skips the closing prompt (CI). -Out puts the logs somewhere else. -Apps picks which +# of kn, graalvm and control run (all that are present, by default). param( [switch]$NoPause, - [string]$Out = '' + [string]$Out = '', + [string[]]$Apps = @('kn', 'graalvm', 'control') ) $ErrorActionPreference = 'Continue' $here = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -15,23 +24,27 @@ $out = if ($Out -ne '') { $Out } else { Join-Path $here 'probe-logs' } New-Item -ItemType Directory -Force -Path $out | Out-Null $rates = @(@(16, 8), @(8, 4), @(1, 1)) # The GraalVM renderer has no hook that puts its window in place for the drag, so the probe -# places it (--place). -$apps = @( - @{ Name = 'kn'; Exe = (Join-Path $here 'hand-check.exe'); Place = $false }, - @{ Name = 'graalvm'; Exe = (Join-Path $here 'graalvm\bin\hand-check.exe'); Place = $true } +# places it (--place). The control places itself. +$all = @( + @{ Name = 'kn'; Exe = (Join-Path $here 'hand-check.exe'); Place = $false; Class = 'ComposeRustWindow'; Paths = @('new', 'old') }, + @{ Name = 'graalvm'; Exe = (Join-Path $here 'graalvm\bin\hand-check.exe'); Place = $true; Class = 'ComposeRustWindow'; Paths = @('new', 'old') }, + @{ Name = 'control'; Exe = (Join-Path $here 'resize-control.exe'); Place = $false; Class = 'ResizeControlWindow'; Paths = @('late') } ) -foreach ($app in $apps) { +$runs = @() +foreach ($app in $all) { + if ($Apps -notcontains $app.Name) { continue } if (-not (Test-Path $app.Exe)) { Write-Host "== $($app.Name): $($app.Exe) is missing, skipped" continue } - foreach ($path in @('new', 'old')) { + foreach ($path in $app.Paths) { foreach ($r in $rates) { $label = "$($app.Name)-$path-$($r[0])" $probeLog = Join-Path $out "$label-probe.log" $appLog = Join-Path $out "$label.log" Write-Host "== $label" - $arguments = @('--turn-on-full-window-drag', '--interval-ms', "$($r[0])", '--step-px', "$($r[1])", '--out', "`"$probeLog`"") + $arguments = @('--turn-on-full-window-drag', '--interval-ms', "$($r[0])", '--step-px', "$($r[1])", + '--class', $app.Class, '--out', "`"$probeLog`"") if ($app.Place) { $arguments += '--place' } $probe = Start-Process -PassThru -WindowStyle Minimized -FilePath (Join-Path $here 'resize-probe.exe') ` -ArgumentList $arguments @@ -42,17 +55,91 @@ foreach ($app in $apps) { } $env:DXC_METRICS = '1'; $env:DXC_REAL_DRAG = 'external'; $env:DXC_RESIZE_TRACE = '1' if ($path -eq 'old') { $env:DXC_RASTER_RESIZE = '0' } else { Remove-Item Env:DXC_RASTER_RESIZE -ErrorAction SilentlyContinue } + if ($path -eq 'late') { $env:DXC_RESIZE_PRESENT_DELAY_MS = '50' } else { Remove-Item Env:DXC_RESIZE_PRESENT_DELAY_MS -ErrorAction SilentlyContinue } $process = Start-Process -PassThru -FilePath $app.Exe -WorkingDirectory (Split-Path -Parent $app.Exe) ` -RedirectStandardOutput $appLog -RedirectStandardError "$appLog.err" $probe.WaitForExit(180000) | Out-Null Start-Sleep -Seconds 2 if (-not $process.HasExited) { Stop-Process -Id $process.Id -Force } Start-Sleep -Seconds 1 + # Both of the application's logs (standard output, and standard error, where its resize + # lines go) start with the Windows version it ran on, as the probe read it. + $os = Select-String -Path $probeLog -Pattern '^resize-probe: os (.*)$' | Select-Object -First 1 + if ($os) { + $line = "resize-kit: os $($os.Matches[0].Groups[1].Value) (read by resize-probe, written here by run-probe-v2)" + foreach ($log in @($appLog, "$appLog.err")) { + $body = if (Test-Path $log) { Get-Content -Raw -Path $log } else { '' } + if ($body -eq $null) { $body = '' } + Set-Content -Path $log -Value ($line + "`r`n" + $body) -NoNewline -Encoding UTF8 + } + } Select-String -Path $probeLog -Pattern 'verdict' | ForEach-Object { Write-Host $_.Line } + $runs += @{ Label = $label; App = $app.Name; Path = $path; Rate = $r[0]; Probe = $probeLog } + } + } +} +Remove-Item Env:DXC_RASTER_RESIZE, Env:DXC_METRICS, Env:DXC_REAL_DRAG, Env:DXC_RESIZE_TRACE, Env:DXC_RESIZE_PRESENT_DELAY_MS -ErrorAction SilentlyContinue + +# The table: every drag's verdict, what it saw, how far the window lagged the cursor, and what +# the verdict means here given the control's at the same rate. +function Read-Field($text, $name) { + $m = [regex]::Match($text, "$name=(-?[0-9.]+)") + if ($m.Success) { return $m.Groups[1].Value } else { return '-' } +} +function Read-Verdict($text) { + $m = [regex]::Match($text, 'resize-probe: verdict (PASS|FAIL|ERROR)') + if ($m.Success) { return $m.Groups[1].Value } else { return 'none' } +} +$controlVerdict = @{} +foreach ($run in $runs) { + if ($run.App -eq 'control') { + $text = if (Test-Path $run.Probe) { Get-Content -Raw -Path $run.Probe } else { '' } + $controlVerdict[$run.Rate] = Read-Verdict $text + } +} +$osLine = 'unknown' +$scaleLine = 'unknown' +$rows = @() +foreach ($run in $runs) { + $text = if (Test-Path $run.Probe) { Get-Content -Raw -Path $run.Probe } else { '' } + $m = [regex]::Match($text, 'resize-probe: os (.*)') + if ($m.Success -and $osLine -eq 'unknown') { $osLine = $m.Groups[1].Value.Trim() } + $m = [regex]::Match($text, 'px, dpi ([0-9]+) \(([0-9.]+)x\)') + if ($m.Success -and $scaleLine -eq 'unknown') { $scaleLine = "dpi $($m.Groups[1].Value) ($($m.Groups[2].Value)x)" } + $verdict = Read-Verdict $text + $control = if ($controlVerdict.ContainsKey($run.Rate)) { $controlVerdict[$run.Rate] } else { 'none' } + if ($run.App -eq 'control') { + $meaning = switch ($verdict) { + 'FAIL' { 'the probe sees 50 ms late frames here' } + 'PASS' { 'NO DISCRIMINATION: 50 ms late frames look prompt here' } + default { 'the control did not run' } } + } elseif ($verdict -ne 'PASS' -and $verdict -ne 'FAIL') { + $meaning = 'the drag did not run' + } elseif ($control -eq 'FAIL') { + $meaning = $verdict + } elseif ($control -eq 'PASS') { + $meaning = "INCONCLUSIVE (no discrimination; probe said $verdict)" + } else { + $meaning = "INCONCLUSIVE (the control did not run; probe said $verdict)" } + $holes = "$(Read-Field $text 'frames_with_hole_in_drag')/$(Read-Field $text 'strip_frames_with_hole_in_drag')" + $black = "$(Read-Field $text 'frames_with_black_in_drag')/$(Read-Field $text 'strip_frames_with_black_in_drag')" + $rows += "| $($run.App) | $($run.Path) | $($run.Rate) ms | $verdict | $(Read-Field $text 'frames_in_drag') | $holes | $black | " + + "$(Read-Field $text 'strip_frames_torn_in_drag') | $(Read-Field $text 'frames_stale_in_drag') | " + + "$(Read-Field $text 'px_median') / $(Read-Field $text 'px_p95') | $(Read-Field $text 'ms_median') / $(Read-Field $text 'ms_p95') | $meaning |" } -Remove-Item Env:DXC_RASTER_RESIZE, Env:DXC_METRICS, Env:DXC_REAL_DRAG, Env:DXC_RESIZE_TRACE -ErrorAction SilentlyContinue +$summary = @( + "OS: $osLine", + "Display: $scaleLine", + '', + '| app | path | mouse | probe | frames in drag | holes (rows/strip) | black (rows/strip) | torn | stale | lag px (median / p95) | lag ms (median / p95) | result here |', + '|---|---|---|---|---|---|---|---|---|---|---|---|' +) + $rows +$summaryPath = Join-Path $out 'summary.md' +Set-Content -Path $summaryPath -Value $summary -Encoding UTF8 +Write-Host '' +$summary | ForEach-Object { Write-Host $_ } Compress-Archive -Force -Path (Join-Path $out '*') -DestinationPath (Join-Path (Split-Path -Parent $out) 'probe-logs.zip') Write-Host "Done. Send probe-logs.zip" if (-not $NoPause) { Read-Host "Press Enter to close" } diff --git a/.github/workflows/test-windows-resize-metrics.yml b/.github/workflows/test-windows-resize-metrics.yml index cddf4a582..58f192010 100644 --- a/.github/workflows/test-windows-resize-metrics.yml +++ b/.github/workflows/test-windows-resize-metrics.yml @@ -19,6 +19,7 @@ on: - ".github/scripts/resize-metrics-run.sh" - ".github/scripts/resize-real-drag-run.sh" - ".github/scripts/resize-probe.c" + - ".github/scripts/resize-os-version.h" concurrency: # One run per pull request: a new commit cancels the older run. Pushes to develop, diff --git a/.github/workflows/test-windows-resize-probe.yml b/.github/workflows/test-windows-resize-probe.yml index 6cd3a2a04..7d548caa2 100644 --- a/.github/workflows/test-windows-resize-probe.yml +++ b/.github/workflows/test-windows-resize-probe.yml @@ -1,14 +1,23 @@ # Windows resize probe test: real drags of hand-check's right edge from resize-probe, a separate # process, at 100% and at 200% display scale, with resize frames on the CPU (the default) and on -# the GPU (DXC_RASTER_RESIZE=0), each at three mouse rates. +# the GPU (DXC_RASTER_RESIZE=0), each at three mouse rates, on two builds of Windows: Server +# 2022 (build 20348) and Server 2025 (build 26100). +# +# Each run also drags resize-control, a window that presents every new size 50 ms late on +# purpose. It is the negative control: where the probe sees its lateness (it FAILs), the probe +# can tell a late frame from a prompt one on that build of Windows, and hand-check's results +# there mean something. Where the control PASSes, Windows is hiding late frames itself, and +# hand-check's results on that runner are INCONCLUSIVE. The first line of every probe log is +# the Windows version with its update build revision. # # The Kotlin/Native hand-check.exe is the one the Resize metrics workflow built in run # 38807049709, so its two-hour build is not repeated. It runs under the same run-probe-v2.ps1 # the kit hands to a person. # -# What this shows is that the probe works on the runner: the drag happens, the widths change, -# the backdrop shows, and the app takes the resize path asked for. It is not a resize verdict: -# the runner draws with WARP on the Basic Render Driver; that verdict comes from a real machine. +# The job passes when the probe works on the runner: every drag happens, the widths change, +# the backdrop shows, the app takes the resize path asked for and the control is late as asked. +# The verdicts and what they mean on each runner are in the job summary (results-.md); +# they are not this job's pass or fail. The runner draws with WARP on the Basic Render Driver. name: Windows resize probe test @@ -23,6 +32,8 @@ on: paths: - ".github/workflows/test-windows-resize-probe.yml" - ".github/scripts/resize-probe.c" + - ".github/scripts/resize-control.c" + - ".github/scripts/resize-os-version.h" - ".github/scripts/resize-probe.manifest" - ".github/scripts/resize-probe-README.txt" - ".github/scripts/resize-probe-match.sh" @@ -62,9 +73,13 @@ jobs: probe: needs: requested - name: Real drags from the resize probe at 100% and 200% (Windows, x64) - runs-on: windows-latest - timeout-minutes: 60 + name: Real drags from the resize probe at 100% and 200% (Windows, ${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: [windows-2022, windows-2025] + runs-on: ${{ matrix.os }} + timeout-minutes: 90 defaults: run: shell: bash @@ -103,8 +118,9 @@ jobs: Write-Output "MSVC tools: $bin" Write-Output "Windows SDK tools: $(Join-Path $sdkbin 'x64')" - - name: Build the resize probe and the display scale tool, and lay out the kit - # The probe's manifest makes it per-monitor DPI aware before any of its code runs. + - name: Build the resize probe, the control window and the display scale tool, and lay out the kit + # The probe's manifest makes it per-monitor DPI aware before any of its code runs; the + # control window takes the same one, as hand-check is per-monitor aware too. run: | set -euo pipefail kit="$(cygpath -u "$RUNNER_TEMP")/probe-kit" @@ -113,6 +129,8 @@ jobs: scripts="$(cygpath -w "$PWD/.github/scripts")" (cd "$kit" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\resize-probe.c" \ /link /MANIFEST:EMBED "/MANIFESTINPUT:$scripts\\resize-probe.manifest") + (cd "$kit" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\resize-control.c" \ + /link /MANIFEST:EMBED "/MANIFESTINPUT:$scripts\\resize-probe.manifest") (cd "$tools" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\set-display-scale.c") rm -f "$kit"/*.obj "$tools"/*.obj cp "$(cygpath -u "$RUNNER_TEMP")/hand-check/hand-check.exe" "$kit/" @@ -122,6 +140,7 @@ jobs: echo echo "This kit" echo " resize-probe.exe the probe, from commit $GITHUB_SHA" + echo " resize-control.exe the control window (50 ms late on purpose), from commit $GITHUB_SHA" echo " hand-check.exe the Kotlin/Native renderer, PRE-MERGE: built in run $HAND_CHECK_RUN" echo " from commit 2332cd29, before develop was merged into this branch." echo " It lacks, against this commit: the letter and digit keys (Ctrl+A, Ctrl+C," @@ -130,13 +149,15 @@ jobs: echo " win32_window.c is the same as this commit's (the merge left those functions unchanged)." echo echo "sha256" - (cd "$kit" && sha256sum hand-check.exe resize-probe.exe) + (cd "$kit" && sha256sum hand-check.exe resize-probe.exe resize-control.exe) } >> "$kit/README.txt" ls -la "$kit" sha256sum "$kit"/*.exe - name: Keep the probe kit - # Both apps and the probe, for run-probe-v2.cmd on a real machine. + # hand-check, the control and the probe, for run-probe-v2.cmd on a real machine. One kit, + # from one runner: the executables are the same on both. + if: matrix.os == 'windows-2025' uses: actions/upload-artifact@v4 with: name: resize-probe-kit-windows @@ -145,8 +166,8 @@ jobs: retention-days: 30 - name: Real drags at 100% - # The kit's own script, as a person runs it. The runner has no graphics card, so both - # renderers draw with WARP. + # The kit's own script, as a person runs it. The runner has no graphics card, so + # hand-check and the control draw with WARP. env: DXC_D3D12_WARP: '1' run: | @@ -178,33 +199,42 @@ jobs: powershell -NoProfile -ExecutionPolicy Bypass -File "$kit\\run-probe-v2.ps1" -NoPause -Out "$out" - name: Report the drags + # The table run-probe-v2 wrote for each scale, then each drag's own lines. if: always() run: | out="$(cygpath -u "$RUNNER_TEMP")/probe-logs" + results="$out/results-${{ matrix.os }}.md" + { + echo "## ${{ matrix.os }}" + for scale in 1x 2x; do + echo + echo "### $scale" + echo + cat "$out/$scale/summary.md" 2>/dev/null | tr -d '\r' | sed 's/^\xEF\xBB\xBF//' || echo "no summary" + done + } > "$results" { - echo "These show that the probe and both apps work here; they are not a resize verdict." + cat "$results" + echo echo "### Display scale" echo '```' cat "$out/set-display-scale.log" 2>/dev/null || echo "no set-display-scale log" echo '```' for scale in 1x 2x; do - for app in kn; do - for path in new old; do - for rate in 16 8 1; do - label="$app-$path-$rate" - dir="$out/$scale" - echo "### $scale $label" - echo '```' - grep -hE "resize-probe: (dpi awareness|duplicating|placed|window| |client|move-size|summary|verdict)" \ - "$dir/$label-probe.log" 2>/dev/null || echo "no probe log" - cat "$dir/$label.log" "$dir/$label.log.err" 2>/dev/null | - grep -E "a window of our own|Compose scene created|first frame drawn|resize-mode: (monitor|resize frames)|real drag (ready|done)" | - sort | uniq -c || true - cat "$dir/$label.log" "$dir/$label.log.err" 2>/dev/null > "$dir/$label.all.log" - bash .github/scripts/resize-probe-match.sh "$dir/$label.all.log" "$dir/$label-probe.log" 2>/dev/null | tail -3 - echo '```' - done - done + for label in kn-new-16 kn-new-8 kn-new-1 kn-old-16 kn-old-8 kn-old-1 control-late-16 control-late-8 control-late-1; do + dir="$out/$scale" + echo "### $scale $label" + echo '```' + grep -hE "resize-probe: (os|dpi awareness|duplicating|placed|window| |client|stale reference|move-size|lag|summary|verdict)" \ + "$dir/$label-probe.log" 2>/dev/null || echo "no probe log" + cat "$dir/$label.log" "$dir/$label.log.err" 2>/dev/null | + grep -E "a window of our own|Compose scene created|first frame drawn|resize-mode: (monitor|resize frames)|real drag (ready|done)|resize-control: (os|start|swapchain|ready|drag done)" | + sort | uniq -c || true + cat "$dir/$label.log" "$dir/$label.log.err" 2>/dev/null > "$dir/$label.all.log" + case "$label" in + kn-*) bash .github/scripts/resize-probe-match.sh "$dir/$label.all.log" "$dir/$label-probe.log" 2>/dev/null | tail -3 ;; + esac + echo '```' done done } >> "$GITHUB_STEP_SUMMARY" @@ -251,15 +281,16 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: resize-probe-logs-windows + name: resize-probe-logs-${{ matrix.os }} path: ${{ runner.temp }}/probe-logs/ retention-days: 14 - - name: The probe ran, and both apps took the same resize path + - name: The probe ran, both paths were taken, and the control was late # Not a resize verdict (see the top of this file). Each drag must have run: a verdict - # that is not ERROR, the move-size loop entered, more than one width seen. And both - # apps must take the path asked for, in the same words from the same C: frames on the - # CPU with every step blitted and validated, or frames on the GPU with no such step. + # that is not ERROR, the move-size loop entered, more than one width seen, the Windows + # version logged. hand-check must take the path asked for, in the same words from the + # same C: frames on the CPU with every step blitted and validated, or frames on the GPU + # with no such step. The control must have drawn its drag steps at least 45 ms late. # Every check here counts and goes on, so the step lists every failure, not the first. shell: bash --noprofile --norc -o pipefail {0} run: | @@ -269,33 +300,39 @@ jobs: status=0 for scale in 1x 2x; do want="$([ $scale = 1x ] && echo "dpi 96 (1.00x)" || echo "dpi 192 (2.00x)")" - for app in kn; do - for path in new old; do - for rate in 16 8 1; do - label="$app-$path-$rate" - dir="$out/$scale" - probe="$dir/$label-probe.log" - log="$dir/$label.all.log" - [ -f "$log" ] || cat "$dir/$label.log" "$dir/$label.log.err" > "$log" 2>/dev/null - verdict="$(grep -h "resize-probe: verdict" "$probe" 2>/dev/null || echo "no verdict")" - echo "$scale $label: $verdict" - case "$verdict" in *"verdict PASS"*|*"verdict FAIL"*) ;; *) echo " the probe did not run"; status=1 ;; esac - grep -q "move-size loop entered" "$probe" 2>/dev/null || { echo " no move-size loop"; status=1; } - grep -qF "px, $want" "$probe" 2>/dev/null || { echo " the window was not at $want"; status=1; } - if [ "$path" = new ]; then - grep -qF "resize-mode: resize frames on the CPU (Skia raster, GDI blit)" "$log" || - { echo " $app did not take the CPU resize path"; status=1; } - steps="$(grep -c "resize-proof step" "$log" || true)" - bad="$(grep "resize-proof step" "$log" | grep -vcE "presents=0 child_visible=0 blit=1 validated=1$" || true)" - echo " resize-proof steps: $steps, not blitted and validated: $bad" - { [ "$steps" -gt 0 ] && [ "$bad" = 0 ]; } || status=1 - else - grep -qF "resize-mode: resize frames on the GPU" "$log" || - { echo " $app did not take the GPU resize path"; status=1; } - ! grep -q "resize-proof step" "$log" || { echo " $app drew CPU steps with DXC_RASTER_RESIZE=0"; status=1; } - fi - done - done + for label in kn-new-16 kn-new-8 kn-new-1 kn-old-16 kn-old-8 kn-old-1 control-late-16 control-late-8 control-late-1; do + dir="$out/$scale" + probe="$dir/$label-probe.log" + log="$dir/$label.all.log" + [ -f "$log" ] || cat "$dir/$label.log" "$dir/$label.log.err" > "$log" 2>/dev/null + verdict="$(grep -h "resize-probe: verdict" "$probe" 2>/dev/null || echo "no verdict")" + echo "$scale $label: $verdict" + case "$verdict" in *"verdict PASS"*|*"verdict FAIL"*) ;; *) echo " the probe did not run"; status=1 ;; esac + grep -q "^resize-probe: os windows [1-9]" "$probe" 2>/dev/null || { echo " no Windows version in the probe log"; status=1; } + grep -q "move-size loop entered" "$probe" 2>/dev/null || { echo " no move-size loop"; status=1; } + grep -qF "px, $want" "$probe" 2>/dev/null || { echo " the window was not at $want"; status=1; } + grep -q "^resize-probe: lag frames=[1-9]" "$probe" 2>/dev/null || { echo " no lag measured"; status=1; } + case "$label" in + kn-new-*) + grep -qF "resize-mode: resize frames on the CPU (Skia raster, GDI blit)" "$log" || + { echo " hand-check did not take the CPU resize path"; status=1; } + steps="$(grep -c "resize-proof step" "$log" || true)" + bad="$(grep "resize-proof step" "$log" | grep -vcE "presents=0 child_visible=0 blit=1 validated=1$" || true)" + echo " resize-proof steps: $steps, not blitted and validated: $bad" + { [ "$steps" -gt 0 ] && [ "$bad" = 0 ]; } || status=1 + ;; + kn-old-*) + grep -qF "resize-mode: resize frames on the GPU" "$log" || + { echo " hand-check did not take the GPU resize path"; status=1; } + ! grep -q "resize-proof step" "$log" || { echo " hand-check drew CPU steps with DXC_RASTER_RESIZE=0"; status=1; } + ;; + control-late-*) + steps="$(grep -c "resize-control: step n=" "$log" || true)" + prompt="$(grep "resize-control: step n=" "$log" | awk '{ for (i = 1; i <= NF; i++) if ($i ~ /^late_ms=/) { split($i, v, "="); if (v[2] + 0 < 45) n++ } } END { print n + 0 }')" + echo " control steps: $steps, less than 45 ms late: $prompt" + { [ "$steps" -gt 0 ] && [ "$prompt" = 0 ]; } || status=1 + ;; + esac done done exit $status From f473b77262efbacafe75eee2e1d8667bcb85aa6e Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:36:37 +0900 Subject: [PATCH 003/209] Fix: Link the resize control as a GUI program, so no console covers the backdrop On windows-2025 the console window the control opened sat beside it, above the probe's backdrop, and the probe stopped with "the backdrop does not show beside the window" for five of six control drags. Refs #353 --- .github/scripts/resize-control.c | 3 +++ .github/workflows/test-windows-resize-probe.yml | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/scripts/resize-control.c b/.github/scripts/resize-control.c index 1a1d65238..323bbc05a 100644 --- a/.github/scripts/resize-control.c +++ b/.github/scripts/resize-control.c @@ -28,6 +28,9 @@ * * --delay-ms overrides DXC_RESIZE_PRESENT_DELAY_MS. DXC_D3D12_WARP=1 draws with WARP, the * software adapter, as the renderer does with that variable. Lines go to standard error. + * + * Linked as a GUI program (/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup), so that starting it opens + * no console window next to it; standard error still reaches a file it is redirected to. */ #define _WIN32_WINNT 0x0A00 #define WIN32_LEAN_AND_MEAN diff --git a/.github/workflows/test-windows-resize-probe.yml b/.github/workflows/test-windows-resize-probe.yml index 7d548caa2..e997c7400 100644 --- a/.github/workflows/test-windows-resize-probe.yml +++ b/.github/workflows/test-windows-resize-probe.yml @@ -129,8 +129,10 @@ jobs: scripts="$(cygpath -w "$PWD/.github/scripts")" (cd "$kit" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\resize-probe.c" \ /link /MANIFEST:EMBED "/MANIFESTINPUT:$scripts\\resize-probe.manifest") + # A GUI program, so that starting it opens no console window: on Server 2025 the + # console opened beside the window and covered the backdrop the probe looks for. (cd "$kit" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\resize-control.c" \ - /link /MANIFEST:EMBED "/MANIFESTINPUT:$scripts\\resize-probe.manifest") + /link /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup /MANIFEST:EMBED "/MANIFESTINPUT:$scripts\\resize-probe.manifest") (cd "$tools" && MSYS_NO_PATHCONV=1 cl /nologo /O2 /W3 "$scripts\\set-display-scale.c") rm -f "$kit"/*.obj "$tools"/*.obj cp "$(cygpath -u "$RUNNER_TEMP")/hand-check/hand-check.exe" "$kit/" From 37cbf632ba1d52c66436d0a326ca775b02eb930d Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:30:32 +0900 Subject: [PATCH 004/209] Test: Draw edge markers and a ruler in hand-check for the resize probe (FR-19.8, #17) With DXC_RESIZE_MARKER=1 hand-check shows a scene the Windows resize probe can judge absolutely: a light field, a 2 dp green column down the left and right edges, a 2 dp green row along the bottom edge, and a dark 2 dp ruler line every 24 dp between the columns. A marker that does not reach the window's border is an area that was not drawn, and a marker of another width or a ruler line off its grid is a stretched picture, so a trailing strip with nothing drawn can no longer read as a narrower window. Covers FR-19.8 criterion 4 (every frame shown during a resize is drawn at that moment's size) on the application side. The scene is built from Row, Column and Box with Width, Weight and Background, nothing the window code has to know about, so no fork change is needed for it. --- .../tests/fixtures/hand-check/README.md | 10 ++ .../tests/fixtures/hand-check/src/main.rs | 156 +++++++++++++++++- 2 files changed, 163 insertions(+), 3 deletions(-) diff --git a/compose-rust/tests/fixtures/hand-check/README.md b/compose-rust/tests/fixtures/hand-check/README.md index 9da152932..c5b40b81c 100644 --- a/compose-rust/tests/fixtures/hand-check/README.md +++ b/compose-rust/tests/fixtures/hand-check/README.md @@ -33,3 +33,13 @@ On Linux the X11 window is the default; nothing needs to be set. | Focus | Click each field, press Tab | Only one field has the caret, and typing goes to it | | Click | Press the button | The counter counts and `event: click N` prints | | Scrolling | Scroll the list with the wheel and the scrollbar | 60 rows move smoothly | + +## The marker scene + +With `DXC_RESIZE_MARKER=1` the window shows a scene made for the Windows resize probe +(`.github/scripts/resize-probe.c`) instead of the controls above: a light field with a 2 dp +green column down its left and right edges, a 2 dp green row along its bottom edge, and a +dark 2 dp ruler line every 24 dp between the two columns. The probe reads it from a screen +capture. A marker that does not touch the window's border shows an area the application did +not draw, and a marker of the wrong width or a ruler line off its grid shows a stretched +picture. `run-probe-v2.ps1` sets the variable for every drag. diff --git a/compose-rust/tests/fixtures/hand-check/src/main.rs b/compose-rust/tests/fixtures/hand-check/src/main.rs index 8ec68c137..edb966db8 100644 --- a/compose-rust/tests/fixtures/hand-check/src/main.rs +++ b/compose-rust/tests/fixtures/hand-check/src/main.rs @@ -15,9 +15,20 @@ //! opens: it should be beside the caret. //! //! The renderer comes from `COMPOSE_RUST_RENDERER_DIR`, as it does for any application. +//! +//! With `DXC_RESIZE_MARKER=1` the window shows something else: the marker scene, which the +//! Windows resize probe reads from a screen capture. A light field with a 2 dp green column +//! down its left and right edges and a 2 dp green row along its bottom edge, and between the +//! two columns a ruler, a dark 2 dp line every 24 dp from the left edge. Nothing else is in +//! it, so every pixel the probe looks at has a known meaning. A frame whose markers do not +//! touch the window's border shows an area the application did not draw; a marker of the +//! wrong width, or ruler lines off their 24 dp grid, shows a picture stretched to a size it +//! was not drawn for. use compose_rust::protocol::{HostEvent, Mutation, PropertyValue, ProtocolError}; -use compose_rust::schema::{EventPayload, PropertyKind, WidgetKind, Window}; +use compose_rust::schema::{ + Color, EventPayload, Modifier, Paint, PropertyKind, WidgetKind, Window, +}; use compose_rust::{Batch, LaunchBuilder, Runtime}; const COLUMN: u32 = 1; @@ -31,12 +42,35 @@ const SIZE: u32 = 8; const LIST: u32 = 9; const ROW0: u32 = 100; +// The marker scene's nodes, apart from the ruler's, which count up from RULER_MARK0. +const MARKER_ROOT: u32 = 1000; +const MARKER_BODY: u32 = 1001; +const MARKER_LEFT: u32 = 1002; +const MARKER_RULER: u32 = 1003; +const MARKER_RIGHT: u32 = 1004; +const MARKER_BOTTOM: u32 = 1005; +const RULER_MARK0: u32 = 2000; + +/// The marker colour. Nothing else in the scene, the window's frame or the probe's magenta +/// backdrop is green, so the probe can find it by colour alone. +const MARKER_GREEN: u32 = 0x00ff00; +const FIELD_LIGHT: u32 = 0xe0e0e0; +const RULER_DARK: u32 = 0x404040; +/// Width of a marker and of a ruler line, and the ruler's period, in dp. +const MARKER_DP: f32 = 2.0; +const RULER_PERIOD_DP: f32 = 24.0; +/// Enough ruler periods for a window maximised on a 3840 pixel wide monitor at 100%. The +/// ruler is a row of fixed-width boxes, so the ones past the window's width get no room +/// and draw nothing. +const RULER_PERIODS: u32 = 160; + const ON_CLICK: i64 = 1; const ON_FIRST: i64 = 2; const ON_SECOND: i64 = 3; struct App { batch: Batch, + marker_scene: bool, clicks: u32, first: String, second: String, @@ -60,6 +94,108 @@ impl App { value: PropertyValue::Integer(id), }); } + + fn modifiers(&mut self, node_id: u32, modifiers: &[Modifier]) { + for (index, modifier) in modifiers.iter().enumerate() { + self.batch.write(Mutation::SetModifier { + node_id, + index: index as u16, + modifier: modifier.clone(), + }); + } + } + + fn create(&mut self, node_id: u32, widget: WidgetKind, modifiers: &[Modifier]) { + self.batch.write(Mutation::Create { node_id, widget }); + self.modifiers(node_id, modifiers); + } + + fn insert(&mut self, parent_id: u32, children: &[u32]) { + for (index, node_id) in children.iter().enumerate() { + self.batch.write(Mutation::Insert { + parent_id, + node_id: *node_id, + index: index as u32, + }); + } + } + + /// The scene the resize probe reads: markers on the left, right and bottom edges and a + /// ruler between them, described at the top of this file. + fn rebuild_marker_scene(&mut self) { + let green = Modifier::Background(Paint::Literal(Color::rgb(MARKER_GREEN))); + self.create( + MARKER_ROOT, + WidgetKind::Column, + &[ + Modifier::FillMaxWidth, + Modifier::FillMaxHeight, + Modifier::Background(Paint::Literal(Color::rgb(FIELD_LIGHT))), + ], + ); + self.create( + MARKER_BODY, + WidgetKind::Row, + &[Modifier::Weight(1.0), Modifier::FillMaxWidth], + ); + self.create( + MARKER_LEFT, + WidgetKind::Box, + &[ + Modifier::Width(MARKER_DP), + Modifier::FillMaxHeight, + green.clone(), + ], + ); + self.create( + MARKER_RULER, + WidgetKind::Row, + &[Modifier::Weight(1.0), Modifier::FillMaxHeight], + ); + self.create( + MARKER_RIGHT, + WidgetKind::Box, + &[ + Modifier::Width(MARKER_DP), + Modifier::FillMaxHeight, + green.clone(), + ], + ); + self.create( + MARKER_BOTTOM, + WidgetKind::Box, + &[Modifier::FillMaxWidth, Modifier::Height(MARKER_DP), green], + ); + // Each period is a light gap and a dark line, so the first line starts 24 dp from + // the window's left edge: the 2 dp marker and a 22 dp gap. + let mut ruler = Vec::with_capacity(RULER_PERIODS as usize * 2); + for period in 0..RULER_PERIODS { + let gap = RULER_MARK0 + period * 2; + let line = gap + 1; + self.create( + gap, + WidgetKind::Box, + &[ + Modifier::Width(RULER_PERIOD_DP - MARKER_DP), + Modifier::FillMaxHeight, + ], + ); + self.create( + line, + WidgetKind::Box, + &[ + Modifier::Width(MARKER_DP), + Modifier::FillMaxHeight, + Modifier::Background(Paint::Literal(Color::rgb(RULER_DARK))), + ], + ); + ruler.push(gap); + ruler.push(line); + } + self.insert(MARKER_RULER, &ruler); + self.insert(MARKER_BODY, &[MARKER_LEFT, MARKER_RULER, MARKER_RIGHT]); + self.insert(MARKER_ROOT, &[MARKER_BODY, MARKER_BOTTOM]); + } } impl Runtime for App { @@ -80,6 +216,10 @@ impl Runtime for App { window.min_height = 320; window.resizable = true; self.batch.write(Mutation::SetWindow(window)); + if self.marker_scene { + self.rebuild_marker_scene(); + return; + } for (node_id, widget) in [ (COLUMN, WidgetKind::Column), (CLICKS, WidgetKind::Text), @@ -128,7 +268,7 @@ impl Runtime for App { } fn render(&mut self, _frame_time_nanos: Option) { - if !self.dirty { + if !self.dirty || self.marker_scene { return; } self.dirty = false; @@ -175,10 +315,20 @@ impl Runtime for App { } } +/// Whether `DXC_RESIZE_MARKER` asks for the marker scene: set, and neither empty nor `0`. +fn marker_scene_asked() -> bool { + std::env::var("DXC_RESIZE_MARKER").is_ok_and(|value| !value.is_empty() && value != "0") +} + fn main() { - LaunchBuilder::new().launch_runtime(|| { + let marker_scene = marker_scene_asked(); + if marker_scene { + println!("hand-check: marker scene (DXC_RESIZE_MARKER)"); + } + LaunchBuilder::new().launch_runtime(move || { Box::new(App { batch: Batch::new(), + marker_scene, clicks: 0, first: "first field: select, copy, paste, undo here".to_owned(), second: "second field".to_owned(), From db6efefa86c5e6f71f81f7389fb16889ebc476f1 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:30:32 +0900 Subject: [PATCH 005/209] Test: Draw the same markers in the resize control, late on every size change (#353) The negative control now draws hand-check's marker scene in pixels (green left, right and bottom markers, a ruler every 24 px) instead of a blue band, so the marker checks are proven against a window known to be late. It is late on every WM_SIZE once it is on screen, not only inside a drag, so maximise, restore and a size set from outside are judged by the same control. --- .github/scripts/resize-control.c | 47 ++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/scripts/resize-control.c b/.github/scripts/resize-control.c index 323bbc05a..b14823a90 100644 --- a/.github/scripts/resize-control.c +++ b/.github/scripts/resize-control.c @@ -7,8 +7,9 @@ * over its client area, and on the child a copy-model swapchain (DXGI_SWAP_EFFECT_SEQUENTIAL, * one buffer, DXGI_SCALING_STRETCH). On WM_SIZE it refits the swapchain to the new client * size, draws, presents, fits the child and waits for DWM (DwmFlush), all before WM_SIZE - * returns. The one difference: during a drag it first sleeps DXC_RESIZE_PRESENT_DELAY_MS - * milliseconds (50 when not set), so every new size's picture is that much late. + * returns. The one difference: once it is on screen, every WM_SIZE first sleeps + * DXC_RESIZE_PRESENT_DELAY_MS milliseconds (50 when not set), so every new size's picture is + * that much late: in a drag, and on maximise, restore and a size set from outside alike. * * Where Windows shows the window at its new size before its picture is there, that lateness * is on screen (an unpainted strip at the right, the old picture stretched or in the wrong @@ -17,9 +18,11 @@ * for any window on that machine says nothing about how promptly that window draws: the * probe cannot tell late from prompt there. * - * What it draws is made for the probe's stale check: a light grey field with a dark 2 px line - * every 24 px from the left, and a blue band along the right edge. A picture drawn for one - * width and shown at another moves the lines. + * What it draws is the marker scene hand-check draws with DXC_RESIZE_MARKER=1, in pixels: a + * light grey field, a 2 px green column down the left and right edges and a 2 px green row + * along the bottom edge, and a dark 2 px line every 24 px from the left. The probe finds the + * markers against the window's border (a gap is an area not drawn), and a picture drawn for + * one width and shown at another moves the lines. * * It opens at the primary monitor's work area's top left, 640x480 pixels, as hand-check does * with DXC_REAL_DRAG=external, and closes itself after --seconds (default 300) or when closed. @@ -58,7 +61,7 @@ #define SURFACE_CLASS L"ResizeControlSurface" #define RULER_STEP 24 #define RULER_WIDTH 2 -#define BAND_WIDTH 8 +#define MARKER_WIDTH 2 #define MAX_LINES 512 static HWND window; @@ -70,6 +73,7 @@ static IDXGISwapChain1 *swapchain; static int buffer_width, buffer_height; static int delay_ms = 50; static int sizing; +static int ready; static long steps; static LARGE_INTEGER frequency; @@ -99,12 +103,12 @@ static int draw(int width, int height) { if (FAILED(made)) return 0; const float field[4] = {0.88f, 0.88f, 0.88f, 1.0f}; const float line[4] = {0.25f, 0.25f, 0.25f, 1.0f}; - const float band[4] = {0.10f, 0.35f, 0.80f, 1.0f}; + const float marker[4] = {0.0f, 1.0f, 0.0f, 1.0f}; ID3D11DeviceContext_ClearRenderTargetView(context, target, field); if (context1 != NULL) { D3D11_RECT lines[MAX_LINES]; UINT count = 0; - for (int x = RULER_STEP; x + RULER_WIDTH <= width - BAND_WIDTH - 4 && count < MAX_LINES; x += RULER_STEP) { + for (int x = RULER_STEP; x + RULER_WIDTH <= width - MARKER_WIDTH && count < MAX_LINES; x += RULER_STEP) { lines[count].left = x; lines[count].top = 0; lines[count].right = x + RULER_WIDTH; @@ -112,12 +116,20 @@ static int draw(int width, int height) { count++; } if (count > 0) ID3D11DeviceContext1_ClearView(context1, (ID3D11View *)target, line, lines, count); - D3D11_RECT edge; - edge.left = width > BAND_WIDTH ? width - BAND_WIDTH : 0; - edge.top = 0; - edge.right = width; - edge.bottom = height; - ID3D11DeviceContext1_ClearView(context1, (ID3D11View *)target, band, &edge, 1); + D3D11_RECT edges[3]; + edges[0].left = 0; + edges[0].top = 0; + edges[0].right = width < MARKER_WIDTH ? width : MARKER_WIDTH; + edges[0].bottom = height; + edges[1].left = width > MARKER_WIDTH ? width - MARKER_WIDTH : 0; + edges[1].top = 0; + edges[1].right = width; + edges[1].bottom = height; + edges[2].left = 0; + edges[2].top = height > MARKER_WIDTH ? height - MARKER_WIDTH : 0; + edges[2].right = width; + edges[2].bottom = height; + ID3D11DeviceContext1_ClearView(context1, (ID3D11View *)target, marker, edges, 3); } ID3D11RenderTargetView_Release(target); HRESULT shown = IDXGISwapChain1_Present(swapchain, 0, 0); @@ -152,7 +164,7 @@ static LRESULT CALLBACK control_proc(HWND hwnd, UINT message, WPARAM wparam, LPA int width = (int)LOWORD(lparam); int height = (int)HIWORD(lparam); long long asked = now_qpc(); - int late = sizing && delay_ms > 0; + int late = ready && delay_ms > 0; if (late) Sleep((DWORD)delay_ms); int drawn = draw(width, height); long long presented = now_qpc(); @@ -160,7 +172,7 @@ static LRESULT CALLBACK control_proc(HWND hwnd, UINT message, WPARAM wparam, LPA SetWindowPos(surface, NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); } DwmFlush(); - if (sizing) { + if (ready) { steps++; fprintf(stderr, "resize-control: step n=%ld %dx%d qpc_size=%lld qpc_present=%lld late_ms=%.1f drawn=%d\n", steps, width, height, asked, presented, @@ -299,7 +311,8 @@ int main(int argc, char **argv) { if (seconds > 0) SetTimer(window, 1, (UINT)seconds * 1000u, NULL); RECT outer; GetWindowRect(window, &outer); - fprintf(stderr, "resize-control: ready at %ld,%ld %ldx%ld px, dpi %u, frames late by %d ms during a drag\n", + ready = 1; + fprintf(stderr, "resize-control: ready at %ld,%ld %ldx%ld px, dpi %u, frames late by %d ms on every size change\n", outer.left, outer.top, outer.right - outer.left, outer.bottom - outer.top, GetDpiForWindow(window), delay_ms); MSG message; From 052c03fd56d5d051da6f6fa287664a22f865d1ae Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:30:32 +0900 Subject: [PATCH 006/209] Test: Judge every resize frame by the edge markers, on every edge, and keep the frames (#17, #164) resize-probe: - --markers: at rest it measures how far the left, right and bottom markers are from the window's border, how wide they are, and the ruler's grid. In every frame after, each marker must be there, no further from the border than at rest and as wide, and every ruler line on its grid. A gap (an area not drawn, including a trailing strip the border moved in on) or a stretch fails the run, where before such a frame read as a narrower window. - --edge right|bottom|left|corner|states: the bottom edge, the left edge (the window moves right first, so the drag goes outward and never meets the minimum size), the bottom right corner, and the window states: maximise, restore, the left half of the work area as snapping sets it (SetWindowPos, so no snap assist covers the backdrop), and back. --no-animation turns the maximise animation off for that run. - --frames DIR: the frame at rest, ten frames spread through the drag, the first six faulty frames and the first frame after, cropped to the window plus 16 px. - Every frame is copied once from a box around everywhere the window can be in the run; the strip, the columns and the markers read that copy. run-probe-v2.ps1 drags every edge at three rates and the window states once, for each app and path, with hand-check's marker scene on, and resize-contact-sheet.ps1 turns the frames into PNG files, a contact sheet per drag and one sheet with a frame of each, for the owner's look. Covers FR-19.8 criterion 4 (no frame at another size than the window's, measured from the screen by another process) and criterion 2 (pictures at 100% and 200%). --- .github/scripts/resize-contact-sheet.ps1 | 107 +++ .github/scripts/resize-probe-README.txt | 57 +- .github/scripts/resize-probe.c | 789 ++++++++++++++++++++--- .github/scripts/run-probe-v2.ps1 | 132 ++-- 4 files changed, 931 insertions(+), 154 deletions(-) create mode 100644 .github/scripts/resize-contact-sheet.ps1 diff --git a/.github/scripts/resize-contact-sheet.ps1 b/.github/scripts/resize-contact-sheet.ps1 new file mode 100644 index 000000000..4f77f37d6 --- /dev/null +++ b/.github/scripts/resize-contact-sheet.ps1 @@ -0,0 +1,107 @@ +# Turns the frames resize-probe kept (--frames, as BMP) into PNG files and contact sheets, so a +# person can look at what each verdict is about. +# +# -Dir the folder run-probe-v2.ps1 wrote: