hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
18.45k stars 768 forks source link

Crash when disabling only connected display #2625

Open omernaveedxyz opened 1 year ago

omernaveedxyz commented 1 year ago

I am using scripts to enable/disable my laptop's internal display on lid open/close when an external display is connected. Everything works fine, except if I disconnect the external display with the lid still closed (and therefore the internal display still disabled), Hyprland crashes and returns me to the TTY.

Here is a sample of the config on NixOS:

let

  # when lid closed, if at least one external display connected, disable internal display
  closeLid = pkgs.writeShellScriptBin "closeLid" ''
    monitors=$(hyprctl monitors | grep "^Monitor")

    if [ $(echo "$monitors" | wc -l) -ge 2 ]; then
      hyprctl keyword monitor "eDP-1, disable"
    fi
  '';

  # when lid opened, if internal display disabled, re-enable display and reload Hyprland
  openLid = pkgs.writeShellScriptBin "openLid" ''
    monitors=$(hyprctl monitors | grep "^Monitor")

    if [ -z "$(echo "$monitors" |  grep eDP-1)" ]; then
      hyprctl keyword monitor "eDP-1, preferred, auto, 1"
      systemctl --user restart waybar
    fi
  '';

in {
  wayland.windowManager.hyprland = {
    ...

    extraConfig = ''
      ...

      bindl=,switch:on:Lid Switch,exec,${closeLid}/bin/closeLid
      bindl=,switch:off:Lid Switch,exec,${openLid}/bin/openLid
    '';
  };
}

Steps to Reproduce

  1. Disconnect all but internal display
  2. Run hyprctl keyword monitor "eDP-1, disable"
  3. Hyprland will freeze and then crash to TTY after a few seconds.

Expected Outcome

If possible, Hyprland should either continue functioning without any display running, or (more likely) attempt to enable any disabled monitors when no monitor is active.

Hyprland Log

hyprland-log.txt

Crash Report

hyprland-crash-report.txt

Cloudef commented 1 year ago

Also happens if using way-displays and you switch output of monitor

jakubkaczor commented 12 months ago

I have

bindl = , switch:on:Lid Switch, exec, hyprctl keyword monitor "eDP-1, disable"
bindl = , switch:off:Lid Switch, exec, hyprctl keyword monitor "eDP-1, preferred, 0x1080, 1"

in hyprland.conf, so I always disable my laptop monitor on lid-closed event and Hyprland doesn't crash. After enabling the monitor, swaybg and Waybar display nothing, but the processes are alive. If I remember correctly, the author of Hyprland justified this by saying the programs might not be able to handle no output (citation needed), but it also happens with hyprpaper.

I remember Hyprland used to crash, but after some release, it stopped. I see that the current Nix's stable release is 0.25. Is this the version you are using?

Boothwhack commented 12 months ago

I'm facing the same issue on a fresh installation (no swaybg, waybar, hyprpaper, etc.) on version 0.27.2. Using these bindings:

bindl=,switch:off:Lid Switch,exec,hyprctl keyword monitor "eDP-1,highrr,0x0,auto"
bindl=,switch:on:Lid Switch,exec,hyprctl keyword monitor "eDP-1,disable"

hyprland crashes when I close the lid on my laptop with no other displays attached, or when detaching the only external display while the lid is closed.

coffebar commented 1 month ago

Sometimes I have a crash when I disconnect an external monitor with lid open. v0.41.1

[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1
[LOG] [GammaControl] setGamma for HDMI-A-1
[LOG] [GammaControl] setting to monitor HDMI-A-1
[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1
[LOG] [GammaControl] setGamma for HDMI-A-1
[LOG] [GammaControl] setting to monitor HDMI-A-1
[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1
[LOG] [GammaControl] setGamma for HDMI-A-1
[LOG] [GammaControl] setting to monitor HDMI-A-1
[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1
[LOG] [GammaControl] setGamma for HDMI-A-1
[LOG] [GammaControl] setting to monitor HDMI-A-1
[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1
[LOG] [GammaControl] setGamma for HDMI-A-1
[LOG] [GammaControl] setting to monitor HDMI-A-1
[wlr] [backend/session/session.c:180] udev event for card1 (change)
[wlr] [backend/session/session.c:209] DRM device card1 changed
[wlr] [backend/drm/backend.c:135] Received hotplug event for /dev/dri/card1
[wlr] [backend/drm/drm.c:1654] Scanning DRM connector 339 on /dev/dri/card1
[wlr] [backend/drm/drm.c:1741] 'DP-2' disconnected
[LOG] Destroy called for monitor DP-2
[LOG] Removing monitor DP-2 from realMonitors
[LOG] Callback 561ad21186e0 -> 561ad21186d8, CMonitor removed.
[LOG] Callback 561ad2118748 -> 561ad2118740, CMonitor removed.
[LOG] Callback 561ad21187b0 -> 561ad21187a8, CMonitor removed.
[LOG] Callback 561ad2118818 -> 561ad2118810, CMonitor removed.
[LOG] Callback 561ad2118880 -> 561ad2118878, CMonitor removed.
[LOG] Callback 561ad21188e8 -> 561ad21188e0, CMonitor removed.
[LOG] Callback 561ad2118950 -> 561ad2118948, CMonitor removed.
[wlr] [backend/drm/drm.c:1274] connector DP-2: De-allocating CRTC 236
[wlr] [backend/drm/drm.c:866] connector DP-2: Turning off
[wlr] [backend/drm/drm.c:1305] Reallocating CRTCs
[wlr] [backend/drm/drm.c:1368]   Connector eDP-1 (connected, needs CRTC): CRTC 98 (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-1 (connected, needs CRTC): CRTC 167 (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-1 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-2 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-2 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-3 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-3 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-4 (disconnected): no CRTC (no change)
[wlr] [backend/session/session.c:180] udev event for card1 (change)
[wlr] [backend/session/session.c:209] DRM device card1 changed
[wlr] [backend/drm/backend.c:135] Received hotplug event for /dev/dri/card1
[wlr] [backend/drm/drm.c:1654] Scanning DRM connector 317 on /dev/dri/card1
[wlr] [backend/drm/drm.c:1741] 'HDMI-A-1' disconnected
[LOG] Destroy called for monitor HDMI-A-1
[LOG] onDisconnect called for HDMI-A-1
[LOG] Registered signal for owner 561ad2774a70: 561ad1fea238 -> 561ad2774a80 (owner: CRenderbuffer)
[LOG] Callback 561ad2774aa8 -> 561ad2774aa0, CRenderbuffer removed.
[LOG] Registered signal for owner 561ad2774a70: 561ad1fe7608 -> 561ad2774a80 (owner: CRenderbuffer)
[LOG] Callback 561ad2774aa8 -> 561ad2774aa0, CRenderbuffer removed.
[LOG] Callback 561ad1a7fb68 -> 561ad1a7fb60, CMonitor removed.
[LOG] Callback 561ad1a7fe40 -> 561ad1a7fe38, CMonitor removed.
[LOG] Callback 561ad1a7fca0 -> 561ad1a7fc98, CMonitor removed.
[LOG] Callback 561ad1a7fd08 -> 561ad1a7fd00, CMonitor removed.
[LOG] Callback 561ad1a7fd70 -> 561ad1a7fd68, CMonitor removed.
[LOG] Callback 561ad1a7fdd8 -> 561ad1a7fdd0, CMonitor removed.
[LOG] Removed monitor HDMI-A-1!
[LOG] moveWorkspaceToMonitor: Moving 1 to monitor 0
[LOG] moveWorkspaceToMonitor: Plugging gap with existing 6
[LOG] [hookSystem] New hook event registered: moveWorkspace
[LOG] moveWorkspaceToMonitor: Moving 6 to monitor 0
[LOG] moveWorkspaceToMonitor: Plugging gap with existing 9
[LOG] moveWorkspaceToMonitor: Moving 9 to monitor 0
[LOG] moveWorkspaceToMonitor: Plugging gap with new 3
[LOG] moveWorkspaceToMonitor: Plugging gap with existing 3
[wlr] [backend/drm/drm.c:866] connector HDMI-A-1: Turning off
[LOG] Callback 561ad0da02d8 -> 561ad0da02d0, CRenderbuffer removed.
[LOG] Callback 561ad1fba8f8 -> 561ad1fba8f0, CRenderbuffer removed.
[LOG] Removing monitor HDMI-A-1 from realMonitors
[LOG] Callback 561ad1a7fbd0 -> 561ad1a7fbc8, CMonitor removed.
[LOG] Callback 561ad1a7fc38 -> 561ad1a7fc30, CMonitor removed.
[wlr] [backend/drm/drm.c:1305] Reallocating CRTCs
[wlr] [backend/drm/drm.c:1368]   Connector eDP-1 (connected, needs CRTC): CRTC 98 (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-1 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-1 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-2 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-2 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector HDMI-A-3 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-3 (disconnected): no CRTC (no change)
[wlr] [backend/drm/drm.c:1368]   Connector DP-4 (disconnected): no CRTC (no change)
[LOG] Destroying workspace ID 3
[LOG] LayerSurface 1 destroyed
[WARN] Layersurface destroyed on an invalid monitor (removed?)
[LOG] Forcing an unmap of a LS that did a straight destroy!
[LOG] LayerSurface 1 unmapped
[WARN] Layersurface unmapping on invalid monitor (removed?) ignoring.
[LOG] CWLSurface 561ad211ad20 called destroy()
[LOG] LayerSurface 0 destroyed
[WARN] Layersurface destroyed on an invalid monitor (removed?)
[LOG] [WLCompositor] New wl_surface with id 115 at 561ad1b5e7c0
[LOG] [GammaControl] setGamma for eDP-1
[LOG] [GammaControl] setting to monitor eDP-1