Skip to content

fix: reapply VRR on physical monitor reconnect#1200

Open
rockerBOO wants to merge 1 commit into
mangowm:mainfrom
rockerBOO:fix/reapply-monitorrule-on-reconnect
Open

fix: reapply VRR on physical monitor reconnect#1200
rockerBOO wants to merge 1 commit into
mangowm:mainfrom
rockerBOO:fix/reapply-monitorrule-on-reconnect

Conversation

@rockerBOO

Copy link
Copy Markdown

The monitor VRR was not getting set after turning off and turning on the monitor.

The VRR attempts to apply when the monitor is focused. There is a retry mechanism to attempt to set it in a loop to let the monitor settle.

The following code is to handle when the output commit fails it will remain in "enabling" mode. But this pattern is kinda sloppy though and duplicated a few times.

	    if (mango_output_commit(m))
			updatemons(NULL, NULL);
		else
			m->is_vrr_enabling = true;

This issue is likely similarly happening for HDR but that has a larger number of changes and harder to check because tooling doesn't support checking HDR support quite yet. I have a branch of wlr-randr to support looking at HDR support and a monitor that supports HDR so I can look into this if an approach here is acceptable.

Willing to make changes and feedback if the HDR changes would be desired.

Physical DRM hotplug never emits wlr_output.events.request_state (only the
X11/Wayland nested backends do), so the existing requestmonstate rule-reapply
path was dead code for real monitors. On reconnect, createmon does the initial
modeset while the connector is still settling, so the adaptive-sync enable test
fails and VRR comes back disabled.

Recover VRR through two paths:

- Add a per-monitor retry timer (monitor_vrr_retry_callback), armed by createmon
  when the rule wants VRR but the initial enable test failed. It re-tests and
  commits every 200ms (up to 25 attempts) until the connector accepts adaptive
  sync, covering the case where the monitor reconnects with no focused client.

- Rebuild updatemons' output-manager snapshot after focusclient so state changed
  by check_vrr_enable (VRR enabled) is pushed to clients like wlr-randr instead
  of the stale pre-focus snapshot. check_vrr_enable now also checks each commit
  result and rolls back is_vrr_enabling on failure so a later attempt can retry.

Remove the dead requestmonstate rule-reapply block.

Recovery drops from ~25s to ~125ms (windowed) / ~200ms (empty) after modeset.
@rockerBOO rockerBOO changed the title fix: reapply VRR on physical monitor reconnect reapply VRR on physical monitor reconnect Jul 22, 2026
@rockerBOO rockerBOO changed the title reapply VRR on physical monitor reconnect fix: reapply VRR on physical monitor reconnect Jul 22, 2026
@DreamMaoMao

Copy link
Copy Markdown
Collaborator

why not wlr-randr --output eDP-1 --on --adaptive-sync enabled use this?

@rockerBOO

rockerBOO commented Jul 22, 2026

Copy link
Copy Markdown
Author

Every time I turn my monitor on again I would need to re-run the wlr-randr command to enable it. We already are setting the VRR in our Mango config so makes it more consistent than to silently drop VRR when the monitor power refreshes. I had a udev command to detect the monitor coming on and running wlr-randr but it seemed like a workaround to getting Mango to re-enable VRR.

Edit:

Also could remove the "retry" parts as it will try to apply the VRR when the cursor enters the screen so that trade off is probably fine.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants