YaLTeR / niri

A scrollable-tiling Wayland compositor.
https://matrix.to/#/#niri:matrix.org
GNU General Public License v3.0
4.12k stars 123 forks source link

Disable laptop panel when the lid is closed is not working correctly on HP Elitebook 840 #786

Closed FluxTape closed 2 weeks ago

FluxTape commented 2 weeks ago

The recently introduced behavior of "Disable laptop panel when the lid is closed" is causing issues on my machine (HP Elitebook 840 G1). When I close the lid and open it again, the screen turns red and shows my cursor (see image). In this state I can't unlock the system (or maybe it's possible but I'm not able to tell, the screen stays red). Then, when I close and open it again it behaves like normal again. This Laptop Model always disables the screen when closing the lid so the option is not relevant to me - disabling it with the debug config fixes the issue. Additional info: My Laptop is set up to idle when the lid is closed and I have swaylock set to trigger before-sleep. niri_red_screen

System Information

YaLTeR commented 2 weeks ago

Hm, this looks like swaylock is failing to pick up a newly connected output.

YaLTeR commented 2 weeks ago

Doesn't seem to break on my laptop. Could you get some logs from swaylock, why it fails?

YaLTeR commented 2 weeks ago

5ff8b89aafca0143866f93dd7e2f27aee6c2b0f5 makes it so that when there are no external monitors, the laptop panel will not disable, which should fix this problem. Still, please send the swaylock output when it fails, in case there's a different issue involved.

FluxTape commented 2 weeks ago

Running swayidle -w before-sleep "swaylock -d" (and reproducing the issue) shows no errors in the terminal, only some info messages:

2024-11-08 09:21:44 - [main.c:1211] Parsing CLI Args
2024-11-08 09:21:44 - [pam.c:88] Prepared to authorize user fluxtape
2024-11-08 09:21:44 - [main.c:1268] Using ext-session-lock-v1
2024-11-08 09:22:51 - [comm.c:22] received pw check request

Also couldn't find anything in the system logs.

YaLTeR commented 2 weeks ago

Huh; does it reproduce if you just spawn swaylock manually then close the lid?

YaLTeR commented 2 weeks ago

Ah, probably doesn't matter since this looks like swaylock output anyway. Well, that's weird then

YaLTeR commented 2 weeks ago

Could you post the part of journalctl --user-unit=niri -b that should correspond to when the issue happened?

FluxTape commented 2 weeks ago

Can't reproduce when just running swaylock and then closing the lid, it only breaks when triggered by swayidle. Output of journalctl --user-unit=niri -b (first locked by just running swaylock, then by swayidle+swaylock)

Nov 08 10:00:36 fedora systemd[6725]: Started niri.service - A scrollable-tiling Wayland compositor.
Nov 08 10:01:32 fedora niri[78561]: 2024-11-08T09:01:32.307580Z DEBUG niri::input: lid switch closed
Nov 08 10:01:32 fedora niri[78561]: 2024-11-08T09:01:32.307625Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Nov 08 10:01:41 fedora niri[78561]: 2024-11-08T09:01:41.230940Z DEBUG niri::input: lid switch opened
Nov 08 10:01:41 fedora niri[78561]: 2024-11-08T09:01:41.231013Z DEBUG niri::backend::tty: connecting connector: eDP-1
Nov 08 10:01:41 fedora niri[78561]: 2024-11-08T09:01:41.231063Z DEBUG niri::backend::tty: picking mode: Mode { name: "1600x900", clock: 107800, size: (1600, 900), hsync: (1648, 1680, 1940), vsync: (903, 908, 926), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Nov 08 10:01:41 fedora niri[78561]: 2024-11-08T09:01:41.231105Z DEBUG niri::backend::tty: set max bpc to 8
Nov 08 10:01:41 fedora niri[78561]: 2024-11-08T09:01:41.236290Z DEBUG niri::niri: putting output eDP-1 at x=160 y=1080
Nov 08 10:01:48 fedora niri[78561]: 2024-11-08T09:01:48.920871Z  INFO niri::niri: locking session
Nov 08 10:01:52 fedora niri[78561]: 2024-11-08T09:01:52.108029Z DEBUG niri::input: lid switch closed
Nov 08 10:01:52 fedora niri[78561]: 2024-11-08T09:01:52.108108Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Nov 08 10:02:19 fedora niri[78561]: 2024-11-08T09:02:19.085773Z DEBUG niri::input: lid switch opened
Nov 08 10:02:19 fedora niri[78561]: 2024-11-08T09:02:19.085864Z DEBUG niri::backend::tty: connecting connector: eDP-1
Nov 08 10:02:19 fedora niri[78561]: 2024-11-08T09:02:19.085909Z DEBUG niri::backend::tty: picking mode: Mode { name: "1600x900", clock: 107800, size: (1600, 900), hsync: (1648, 1680, 1940), vsync: (903, 908, 926), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Nov 08 10:02:19 fedora niri[78561]: 2024-11-08T09:02:19.085949Z DEBUG niri::backend::tty: set max bpc to 8
Nov 08 10:02:19 fedora niri[78561]: 2024-11-08T09:02:19.093114Z DEBUG niri::niri: putting output eDP-1 at x=160 y=1080
Nov 08 10:02:24 fedora niri[78561]: 2024-11-08T09:02:24.819974Z  INFO niri::niri: unlocking session
Nov 08 10:02:51 fedora niri[78561]: 2024-11-08T09:02:51.841360Z DEBUG niri::input: lid switch closed
Nov 08 10:02:51 fedora niri[78561]: 2024-11-08T09:02:51.841758Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Nov 08 10:02:52 fedora niri[78561]: 2024-11-08T09:02:52.127218Z  INFO niri::niri: locking session
Nov 08 10:03:07 fedora niri[78561]: 2024-11-08T09:03:07.234785Z DEBUG niri::input: lid switch opened
Nov 08 10:03:07 fedora niri[78561]: 2024-11-08T09:03:07.234856Z DEBUG niri::backend::tty: connecting connector: eDP-1
Nov 08 10:03:07 fedora niri[78561]: 2024-11-08T09:03:07.234904Z DEBUG niri::backend::tty: picking mode: Mode { name: "1600x900", clock: 107800, size: (1600, 900), hsync: (1648, 1680, 1940), vsync: (903, 908, 926), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Nov 08 10:03:07 fedora niri[78561]: 2024-11-08T09:03:07.234944Z DEBUG niri::backend::tty: set max bpc to 8
Nov 08 10:03:07 fedora niri[78561]: 2024-11-08T09:03:07.238417Z DEBUG niri::niri: putting output eDP-1 at x=160 y=1080
Nov 08 10:03:21 fedora niri[78561]: 2024-11-08T09:03:21.284520Z DEBUG niri::input: lid switch closed
Nov 08 10:03:21 fedora niri[78561]: 2024-11-08T09:03:21.284603Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Nov 08 10:03:48 fedora niri[78561]: 2024-11-08T09:03:48.236607Z DEBUG niri::input: lid switch opened
Nov 08 10:03:48 fedora niri[78561]: 2024-11-08T09:03:48.238040Z DEBUG niri::backend::tty: connecting connector: eDP-1
Nov 08 10:03:48 fedora niri[78561]: 2024-11-08T09:03:48.238107Z DEBUG niri::backend::tty: picking mode: Mode { name: "1600x900", clock: 107800, size: (1600, 900), hsync: (1648, 1680, 1940), vsync: (903, 908, 926), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Nov 08 10:03:48 fedora niri[78561]: 2024-11-08T09:03:48.238154Z DEBUG niri::backend::tty: set max bpc to 8
Nov 08 10:03:48 fedora niri[78561]: 2024-11-08T09:03:48.242109Z DEBUG niri::niri: putting output eDP-1 at x=160 y=1080
Nov 08 10:03:54 fedora niri[78561]: 2024-11-08T09:03:54.404972Z  INFO niri::niri: unlocking session
FluxTape commented 2 weeks ago

I can also confirm your latest commit fixes this when no external monitor is connected. Sadly I don't have an external monitor to test atm.

FluxTape commented 2 weeks ago

Another thing I noticed is that when the "red screen" issue occurs it also breaks waybar.

YaLTeR commented 2 weeks ago

Okay, so I found one small problem in that when there are no outputs, niri will delay the successful lock until one output appears. However, that doesn't explain the swaylock and waybar problems you seem to be having, because even if I spawn swaylock and waybar with all outputs disabled, and then enable the laptop output (via SSH), then they work fine.

The red screen is just niri's locked session background, you can see it if the lock screen application crashed or didn't draw anything.

FluxTape commented 2 weeks ago

Waybar seems to only break when I open the lid and then close it again too quickly, then it outputs a ton of: (waybar:84197): Gdk-CRITICAL **: 10:31:41.859: gdk_monitor_get_scale_factor: assertion 'GDK_IS_MONITOR (monitor)' failed (but no other errors)

YaLTeR commented 2 weeks ago

Guess it doesn't correctly catch when all monitors disappear or something

FluxTape commented 2 weeks ago

When I open and close the lid too quickly journalctl --user-unit=niri -b somtimes shows

Nov 08 10:33:47 fedora niri[78561]: libinput error: event5  - Video Bus: client bug: event processing lagging behind by 1384ms, your system is too slow
Nov 08 10:33:47 fedora niri[78561]: libinput error: event1  - Lid Switch: client bug: event processing lagging behind by 1384ms, your system is too slow
Nov 08 10:33:47 fedora niri[78561]: libinput error: event2  - Power Button: client bug: event processing lagging behind by 1257ms, your system is too slow

But since this doesn't happen every time, it can't be what breaks swaylock

YaLTeR commented 2 weeks ago

Yeah that's probably unrelated