alex-courtis / way-displays

way-displays: Auto Manage Your Wayland Displays
MIT License
252 stars 13 forks source link

Closed laptop display not enabled after unplugging other displays #36

Closed alex-courtis closed 1 year ago

alex-courtis commented 2 years ago
  1. Start with displays connected, lid closed
  2. Unplug displays
  3. Open lid

Laptop display is off. Plugging other displays does nothing. User can successfully switch to a console however the compositor session remains off when switched to.

Possible sway/wlroots issue. #31 with some automation may be a solution.

See https://github.com/alex-courtis/way-displays/issues/33#issuecomment-1093960493 for logs.

0x0013 commented 2 years ago

Attaching another log with this problem, this time with debug flag enabled.

Opened lid immediately after disconnecting laptop (few seconds max), and for some amount of time, I am unable to even switch to non-graphical console (ctrl+alt+F2), it seems the laptop is completely hung. However, after repeated trying, I am able to switch to console, and from then, switching works every time. There have also been instances when I am unable to switch back at all. Process list indicates way-displays as well as Sway is running. Log ends when I kill Sway process manually. way-displays.debug.unplug-closed.log

0x0013 commented 2 years ago

Another different scenario, simulating normal day-to-day workflow with laptop/dock operation. I have been able to repeat this twice.

Start with freshly launched Sway/way-displays, laptop unplugged, lid open.

  1. Close lid (laptop should go into s2idle suspend)
  2. Wait 5-10 seconds, plug laptop (still closed) into dock. Laptop wakes up, both displays are detected and set up properly. However, the closed laptop display seems to still be active, as one of my workspaces is not visible, yet I can still operate on whatever is on it.
  3. Unplug laptop from dock. From previous experience, I expect it goes back to s2idle at this point.
  4. Wait 5-10 seconds. Open lid. After initial delay of some seconds, the display comes alive complete with sway workspace, but goes blank after a split second. A few seconds after that, display comes back on and behaves as expected, however, way-displays has exited at this point. Looking at the log, it seems that when laptop wakes after opening the lid, way-displays detects the lid open event, but still consider the (now long gone) external displays to be attached, and attempts to rearrange them, only later registering the "Departed" events. way-displays.debug.sleep-plug-unplug.log
alex-courtis commented 2 years ago

Opened lid immediately after disconnecting laptop

That's fantastic - exactly what I was after!

[15:08:26] eDP-1 Changing: is the key: we are not getting any response for that operation until [15:08:38] [src/listener_output_configuration.c:51] Output Configuration cancelled 0xb5e which occurs after the unplug of the external displays. It may be a sway/wlroots failure which results in the response not being sent.

This can be worked around / fixed but will require some thought. See #38

alex-courtis commented 2 years ago

2. However, the closed laptop display seems to still be active

That can be fixed now: incoming. The event logging shows that changes may be aggressively retried following a cancellation.

4. Looking at the log, it seems that when laptop wakes after opening the lid, way-displays detects the lid open event, but still consider the (now long gone) external displays to be attached, and attempts to rearrange them, only later registering the "Departed" events.

The delayed processing until the lid is opened will be resolved with the above fix.

The arrive/depart/arrive is "normal" finnicky monitor behaviour. That is not a problem however the failure during that behaviour is, and will be investigated/fixed. #39

alex-courtis commented 2 years ago

Fix: aggressively retry after cancellation, as there are no other update/change events in flight. If there are, subsequent retries will handle the situation, as they will operate on the updated information.

alex-courtis commented 1 year ago

This seems to be fixed.