Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race with kanshi loses output configuration when connected outputs change #676

Open
vilhalmer opened this issue Sep 17, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@vilhalmer
Copy link

I just switched from sway and carried over my kanshi config to disable the internal display on my laptop when at my desk (at least until #145 :). Enable/disabling outputs works correctly when I connect the laptop to my dock, but some sort of race is occurring which causes niri's output config to be ignored when kanshi toggles the internal output right as the external one becomes available. I noticed this because it resets the external display's scale, but I added a transform "90" to debug and confirmed that it is ignored after the hotplug as well.

I use an LG DualUp and this also occurs when I split/unsplit the display into two for use with my second machine, which causes the vertical resolution reported to the system to be cut in half/doubled respectively. I think this just appears as a display disconnecting and reconnecting, so probably the same code path. I used this to test below, but the behavior is identical if I physically unplug and replug the laptop dock.

My output config:

output "eDP-1" {
    scale 1.2
    background-color "black"
}

output "LG Electronics LG SDQHD 204NTTQ2H201" {
    background-color "black"
    scale 1
    position x=0 y=0
}

Here are the debug logs at startup, with kanshi launched using spawn-at-startup:

2024-09-17T13:10:05.456944Z  INFO niri: starting version 0.1.9 (v0.1.9-1-g6ee5b5a)
2024-09-17T13:10:05.464105Z DEBUG niri_config: loaded config from "/home/vil/.config/niri/config.kdl"
2024-09-17T13:10:05.532829Z  INFO niri::backend::tty: using as the render node: "/dev/dri/renderD128"
2024-09-17T13:10:05.549878Z DEBUG niri::backend::tty: device added: 57857 "/dev/dri/card1"
2024-09-17T13:10:05.913167Z DEBUG niri::backend::tty: this is the primary node
2024-09-17T13:10:05.913190Z DEBUG niri::backend::tty: this is the primary render node
2024-09-17T13:10:05.928221Z DEBUG niri::backend::tty: device changed: 57857
2024-09-17T13:10:06.713149Z DEBUG niri::backend::tty: connecting connector: eDP-1
2024-09-17T13:10:06.713440Z DEBUG niri::backend::tty: picking mode: Mode { name: "2256x1504", clock: 235690, size: (2256, 1504), hsync: (2304, 2336, 2536), vsync: (1507, 1513, >
2024-09-17T13:10:06.713554Z DEBUG niri::backend::tty: set max bpc to 8
2024-09-17T13:10:06.722257Z DEBUG niri::niri: putting output eDP-1 at x=0 y=0
2024-09-17T13:10:06.722295Z DEBUG niri::backend::tty: connecting connector: DP-1
2024-09-17T13:10:06.722378Z DEBUG niri::backend::tty: picking mode: Mode { name: "2560x1440", clock: 241500, size: (2560, 1440), hsync: (2608, 2640, 2720), vsync: (1443, 1448, >
2024-09-17T13:10:06.722417Z DEBUG niri::backend::tty: set max bpc to 8
2024-09-17T13:10:06.726922Z DEBUG niri::niri: putting output DP-1 at x=0 y=0
2024-09-17T13:10:06.726937Z DEBUG niri::niri: putting output eDP-1 at x=2560 y=0
2024-09-17T13:10:06.727046Z  INFO niri: listening on Wayland socket: wayland-1
2024-09-17T13:10:06.727053Z  INFO niri: IPC listening on: /run/user/1000/niri.wayland-1.94603.sock
2024-09-17T13:10:08.137425Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
2024-09-17T13:10:08.635988Z ERROR niri::backend::tty: missing surface in vblank callback for crtc crtc::Handle(131)
2024-09-17T13:10:08.636576Z DEBUG niri::protocols::output_management: OutputConfiguration: request from an outdated configuration
2024-09-17T13:10:35.992652Z DEBUG niri::backend::tty: device changed: 57857
2024-09-17T13:10:36.203896Z DEBUG niri::backend::tty: disconnecting connector: "DP-1"
2024-09-17T13:10:36.282352Z DEBUG niri::backend::tty: connecting connector: eDP-1
2024-09-17T13:10:36.282430Z DEBUG niri::backend::tty: picking mode: Mode { name: "2256x1504", clock: 235690, size: (2256, 1504), hsync: (2304, 2336, 2536), vsync: (1507, 1513, >
2024-09-17T13:10:36.282478Z DEBUG niri::backend::tty: set max bpc to 8
2024-09-17T13:10:36.287868Z DEBUG niri::niri: putting output eDP-1 at x=0 y=0
2024-09-17T13:10:36.526377Z DEBUG niri::protocols::output_management: OutputConfiguration: request from an outdated configuration
2024-09-17T13:10:37.301191Z DEBUG niri::backend::tty: device changed: 57857
2024-09-17T13:10:37.371671Z DEBUG niri::backend::tty: connecting connector: DP-1
2024-09-17T13:10:37.371901Z DEBUG niri::backend::tty: picking mode: Mode { name: "2560x2880", clock: 483250, size: (2560, 2880), hsync: (2608, 2640, 2720), vsync: (2883, 2893, >
2024-09-17T13:10:37.371998Z DEBUG niri::backend::tty: set max bpc to 8
2024-09-17T13:10:37.385774Z DEBUG niri::niri: putting output DP-1 at x=1880 y=0
2024-09-17T13:10:38.520847Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
2024-09-17T13:10:38.520912Z DEBUG niri::niri: putting output DP-1 at x=0 y=0
2024-09-17T13:10:39.009349Z ERROR niri::backend::tty: missing surface in vblank callback for crtc crtc::Handle(131)
2024-09-17T13:10:39.012121Z DEBUG niri::protocols::output_management: OutputConfiguration: request from an outdated configuration

You can also see it initially disabling eDP-1, which works fine and doesn't break the external output's config despite also throwing the "request from an outdated configuration" message. The later change at 13:10:35 is me switching the display mode (which is why the chosen mode is now 2880) and thus causing a reconnect. After this, the configuration is lost and the scale is the default 1.25.

I fixed it with niri msg output DP-1 scale 1.0, killed kanshi, and changed the display mode again. This time without kanshi, the internal display remains disabled throughout the disconnect/reconnect:

2024-09-17T13:11:55.820910Z DEBUG niri::backend::tty: device changed: 57857
2024-09-17T13:11:56.030063Z DEBUG niri::backend::tty: disconnecting connector: "DP-1"
2024-09-17T13:11:57.115855Z DEBUG niri::backend::tty: device changed: 57857
2024-09-17T13:11:57.182944Z DEBUG niri::backend::tty: connecting connector: DP-1
2024-09-17T13:11:57.183024Z DEBUG niri::backend::tty: picking mode: Mode { name: "2560x1440", clock: 241500, size: (2560, 1440), hsync: (2608, 2640, 2720), vsync: (1443, 1448, 1481), hskew: 0, vscan: 0, vrefresh: 60, mode_type: >
2024-09-17T13:11:57.183056Z DEBUG niri::backend::tty: set max bpc to 8
2024-09-17T13:11:57.187111Z DEBUG niri::niri: putting output DP-1 at x=0 y=0

The configuration is retained.

I haven't tested with any other wlr-output-management tools to see if this is common to all of them or kanshi-specific.

System Information

  • niri version: niri 0.1.9 (v0.1.9-1-g6ee5b5a)
  • Distro: Arch Linux
  • GPU: Intel Corporation Raptor Lake-P [Iris Xe Graphics] (rev 04)
  • CPU: 13th Gen Intel(R) Core(TM) i5-1340P

P.S.: I love Niri, I had started writing this exact compositor a while ago but ran out of steam. Thanks for building it!

@vilhalmer vilhalmer added the bug Something isn't working label Sep 17, 2024
@YaLTeR
Copy link
Owner

YaLTeR commented Sep 17, 2024

Hm, interesting. Could you also get a WAYLAND_DEBUG=1 log from kanshi and upload it, with some annotation on when the outputs reconnect and when the issue occurs?

P.S.: I love Niri, I had started writing this exact compositor a while ago but ran out of steam. Thanks for building it!

Hah, that's curious. :) Steam management is tough, yeah..

@vilhalmer
Copy link
Author

Here's the log, line 141 is the split where I hit the button: kanshi.log

You can see it reacting to there only being the internal display and switching it back on, then immediately switching it back off when the external reappears moments later. kanshi doesn't seem to notice anything going wrong despite niri reporting the outdated configuration, so something must be changing internally between the time the zwlr_output_configuration_v1 is created and the time kanshi requests a change?

@YaLTeR
Copy link
Owner

YaLTeR commented Sep 17, 2024

Thanks. Also, could you post your kanshi config?

@vilhalmer
Copy link
Author

profile laptop {
	output eDP-1 enable
}
profile desk {
	output eDP-1 disable
	output 'LG Electronics LG SDQHD 204NTTQ2H201' enable
}

@YaLTeR
Copy link
Owner

YaLTeR commented Sep 17, 2024

So if you run kanshi only after connecting the dock then it doesn't lose the output config?

@vilhalmer
Copy link
Author

Indeed, if I:

>> pkill kanshi
>> niri msg output eDP-1 on       
>> kanshi
applying profile 'desk'
applying profile output 'LG Electronics LG SDQHD 204NTTQ2H201' on connected head 'DP-1'
applying profile output 'eDP-1' on connected head 'eDP-1'
configuration for profile 'desk' applied

it powers off the internal display without breaking the external one. Seems to require the external one disappearing and reappearing at the same time the internal is being changed to trigger the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants