Support arbitrary headful viewport sizes via dynamic modelines#277
Open
hiroTamada wants to merge 1 commit into
Open
Support arbitrary headful viewport sizes via dynamic modelines#277hiroTamada wants to merge 1 commit into
hiroTamada wants to merge 1 commit into
Conversation
PATCH /display previously 500'd for any width/height without a pre-baked xorg.conf modeline (e.g. 1365x768): the X server snapped to the nearest mode (1366x768) and waitForXRootSize's exact-match check rejected it. Maintaining an allowlist for every possible size is impractical. Instead, generate the exact modeline on the fly for the headful "dummy" driver. generateExactModeline synthesizes CVT-style timings that preserve the EXACT requested active resolution (cvt/gtf/libxcvt all round H-active to the 8px cell granularity, so they can't express odd/non-mod-8 widths). ensureXorgModeline newmode/addmode's it idempotently before the resize. For the Neko path, ScreenConfigurationChange matches against a cached RandR mode list and can miss a just-added mode (reporting success but snapping the X root to its max), so assertXorgMode pins the exact geometry via xrandr afterward. On vGPU (dynamic modelines disallowed) newmode/assert fail gracefully and behavior is unchanged. Headless (Xvfb) already supports arbitrary sizes via screen restart and is unaffected. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR appears to be in a display/rendering service within a larger monorepo, but doesn't clearly indicate which of the four specified repos (kernel, infra, hypeman, hypeship) it belongs to—please confirm the repo name or opt in manually. To monitor this PR anyway, reply with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PATCH /displayreturns 500 for any width/height that lacks a pre-bakedxorg.confmodeline on the headful path. For example, requesting1365x768:The resize actually succeeds — the X server snaps the odd/unsupported size to the nearest available mode (
1366x768) — butwaitForXRootSize's exact-equality check rejects the snap and turns a working resize into an error (and leaves the display at the snapped size). Maintaining anxorg.confallowlist covering every possible viewport size is impractical.Approach (generate modelines on the fly)
For the headful Xorg dummy driver (which has no cell-granularity or pixel-clock constraints —
HorizSync 5–1000,VertRefresh 5–200), generate the exact modeline at request time instead of enumerating them statically:generateExactModeline— synthesizes CVT-style timings that preserve the exact requested active resolution.cvt/libxcvt/gtfall round H-active down to the 8px CVT cell granularity (gtf 1365 768→ a 1368-wide mode), so they can't express odd or non-mod-8 widths; this generator keepshdisplay/vdisplayexactly as asked.ensureXorgModeline— idempotentxrandr --newmode/--addmodebefore applying (tolerates "already exists" for modes shipped inxorg.confor added by a prior resize).assertXorgMode— pins exact geometry viaxrandr --output … --mode ….Wired into both headful paths:
setResolutionXorgViaXrandr(Neko disabled) andsetResolutionViaNeko.Why the extra
assertXorgModeon the Neko pathNeko's
ScreenConfigurationChangematches the requestedWxHagainst a cached RandR mode list. A just-added modeline may not be in that cache yet, so Neko reports success but snaps the X root to its largest known mode (e.g.3840x2160). Pinning the mode directly afterward is immediate, sticks (Neko doesn't revert it), and aligns the X root with the size already handed to Neko's capture pipeline.Scope / safety
Xvfb -screen 0 WxHx24, and never callswaitForXRootSize.newmode/assertfail gracefully (logged, non-fatal) and behavior is unchanged from today for that path.Testing
Validated live in headful containers (arm64 dummy driver), both Neko-enabled and Neko-disabled. All sizes return 200 on the first try with the X root landing exactly:
go vetclean.Follow-ups / open questions
ensureXorgModelineon a driver/displayModecheck to keep vGPU logs quiet.Note
Medium Risk
Touches live display resize, xrandr, and Neko integration on the headful path; failures could leave wrong resolution but Xvfb and most failure modes are bounded by existing verification and non-fatal vGPU handling.
Overview
Headful
PATCH /displayno longer depends on pre-bakedxorg.confmodes for every width/height. The API now creates and applies exact RandR modelines at request time so sizes that standardcvt/gtfcannot represent (odd widths, non–8px-aligned sizes) still matchwaitForXRootSizeinstead of snapping to the nearest baked mode and returning 500.New helpers in
display.go:generateExactModeline(CVT-style timings with exact active resolution),ensureXorgModeline(idempotentxrandr --newmode/--addmode),assertXorgMode(pin output to a named mode), andxorgOutputName(sharedDUMMY0/ env override). Both headful paths callensureXorgModelinebefore resize:setResolutionXorgViaXrandrandsetResolutionViaNeko. On the Neko path,assertXorgModeruns afterScreenConfigurationChangebecause Neko may use a stale mode cache and report success while the X root stays on a larger mode.Xvfb / headless behavior is unchanged. vGPU paths may still ignore dynamic modelines; failures there are logged and non-fatal per the PR description.
Reviewed by Cursor Bugbot for commit 31c2ad1. Bugbot is set up for automated code reviews on this repo. Configure here.