Repository navigation
Restart Chromium when a headful display change only changes the refresh rate - #497
Open
masnwilliams wants to merge 1 commit into
Open
masnwilliams wants to merge 1 commit into
masnwilliams wants to merge 1 commit into
Conversation
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.
Summary
On headful images, a
PATCH /display(or a/chromium/configuredisplay part) that changes only the refresh rate at the current resolution switches the X mode but leaves Chromium rendering at its old rate. For example, 1920x1080@25 → 1920x1080@60 respondsrefresh_rate: 60and xrandr reports1920x1080 59.96*, butrequestAnimationFramekeeps firing every 40ms until Chromium restarts.Chromium on Linux re-reads the screen's refresh rate when the X screen size changes. A rate-only mode switch produces no display-metrics change, because
DisplayChangeNotifieronly flagsDISPLAY_METRIC_REFRESH_RATEon macOS (ui/display/display_change_notifier.cc). Before #262 the Xorg path restarted Chromium after every resize, which hid this. #262 removed that restart for size changes, which Chromium handles live, so rate-only changes regressed.Change
patchDisplayLocked(Xorg branch) now restarts Chromium withrestartChromiumAndWait(which waits for DevTools to be ready) only when the realized X root size is unchanged and the refresh rate changed. The decision lives inchromiumRestartForDisplayChange:restart_chromium: falseapplyResolutionAndConverge, because libxcvt rounding can map a different requested size onto the current one.restart_chromiumunset ortrueallows the restart. An explicitfalseopts out, which is the only way to keep the old no-restart behavior for a rate-only change./chromium/configureneeds no change:patchDisplayLocked, so create, pool acquire and browser update get the fix, with at most one restart per configure.Cost
A rate-only change now takes about 1s inside the VM:
PATCH /displaymeasured 0.63–1.71s, median 0.97s, across 3 browsers. Size-only changes stay at 8–32ms.The restart drops CDP connections and resets page state. That was already true of every headful resize before #262, but it now applies only to rate-only changes.
Testing
TestChromiumRestartForDisplayChangecovers rate up, rate down, size only, size and rate, no change, and bothrestart_chromiumvalues.go test ./cmd/api/...passes.kernel-images-apibinary inside 3 headful browsers, built from the current release source with and without this patch, then drove the public browser update API. Values are therequestAnimationFramemedian and whether Chromium restarted (PID change):restart_chromium: false(in-VM call)Notes
The OpenAPI description of
restart_chromium("restart after resolution change ... default false for headful") is left as is. Updating it means regeneratingoapi.go; I can do that in a follow-up if preferred.Note
Medium Risk
Changes headful display handling by conditionally restarting Chromium (~1s, drops CDP/page state), but logic is narrow, tested, and opt-out via
restart_chromium.Overview
Fixes a regression where headful
PATCH /displaycould switch the X mode to a new refresh rate while Chromium kept its oldrequestAnimationFrameinterval, because Linux Chromium only re-reads refresh rate when the screen size changes.After Xorg resize converges,
chromiumRestartForDisplayChangedecides whether torestartChromiumAndWait: yes for rate-only at the same realized resolution; no for size-only or size+rate (live resize path preserved). On restart, the CDP maximize re-assert is skipped; a failed restart surfaces as 500. Explicitrestart_chromium: falseskips the restart and logs a warning that the old rate persists.TestChromiumRestartForDisplayChangecovers the decision matrix and bothrestart_chromiumvalues.Reviewed by Cursor Bugbot for commit 0dd916f. Bugbot is set up for automated code reviews on this repo. Configure here.