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
19.66k stars 830 forks source link

Swaylock/waylock lose focus after resume #3581

Open sant0s12 opened 11 months ago

sant0s12 commented 11 months ago

Hyprland Version

1b48642fd15c433c53876f1b933dcd46265caf8f

Bug or Regression?

Bug

Description

I have this issue where sometimes swaylock/waylock (it happens for either of them) don't get focus when resuming from sleep. This is not always the case so I haven't been able to pin-point the issue. When it happens, sometimes the mouse cursor is visible but then goes away after pressing any key. Trying to input the password does not work at all and the screen remains black (but still lit). Then I have to kill swaylock from another tty to be able to access the system.

I have swaydle setup so that is turns off the screen before it locks it and the screen is locked using a the lockscreen script below.

I hope this is not a duplicate issue since I have not been able to find anybody else having the same problem.

hyprland config:

exec-once = swayidle -w timeout 400 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' timeout 700 'lockscreen' timeout 1000 'systemctl suspend' lock 'lockscreen' before-sleep 'lockscreen'

lockscreen script:

#!/bin/sh
playerctl -a pause

dunst_old=$(dunstctl is-paused)
dunstctl set-paused true # pause dunst

# mute
pactl set-sink-mute 0 true

pidof swaylock > /dev/null || swaylock -d >> /tmp/lockscreen.log 2>&1

# wait for swaylock to finish
wait $!

dunstctl set-paused "$dunst_old" # restore dunst state

swaylock config:

color=000000
show-keyboard-layout
daemonize
ignore-empty-password

How to reproduce

  1. Setup swayidle and swaylock as above.
  2. Make the system sleep (either by the timers expiring or by closing the laptop's lid)
  3. When the system wakes up, try to enter a password and fail

This is very inconsistent and I haven't been able to find out what exactly triggers it. But I have been having the problem quite frequently.

Any suggestions on how to pin-point the cause are greatly appreciated! I'm guessing it's probably missconfiguration.

As a final remark: I haven't had the same problem with gtklock, which does not support wayland's screen lock protocol, so maybe that has something to do with it. However, I haven't used gtklock for very long so maybe it would show up eventually.

Crash reports, logs, images, videos

No response

sant0s12 commented 11 months ago

This is the log of the last time this happened (the last time the session was locked I was unable to unlock it, the sessions above worked fine):

lock_error_hypr.log

sant0s12 commented 9 months ago

Does anybody have any idea about how I can debug this further? I switched to gtklock because of this issue but now that wlr-input-inhibitor was dropped I can no longer to that.

vaxerski commented 9 months ago

by doesnt get focus you mean keyboard focus? So you can still type behind it?

sant0s12 commented 9 months ago

Yes keyboard focus, I can't type in the password.

vaxerski commented 9 months ago

just because you can't type in the password doesn't mean focus is lost, it could be e.g. swaylock being hung?

Launch a terminal in the background, get it to do this, and try to type in and send pkill Hyprland

sant0s12 commented 9 months ago

You are right, swaylock is still in focus because I tried what you said and it does not work. However, I can still not type my password.

mindrunner commented 9 months ago

I think I face the same issue. I can confirm that swaylock has lost its focus and hyprland receives the keyboard inputs instead.

mindrunner commented 8 months ago

This only seem to happen when swayidle triggers the swaylock command in the before-sleep hook. For me there is no difference in how I initiate suspend/hibernate (e.g. wlogout, cli, lid, ...). If swaylock is active before suspend is triggered, the problem disappears:

swaylock && systemctl suspend

Workaround to recover unlockable session:

pkill -SIGUSR1 swaylock ; WAYLAND_DISPLAY=wayland-1 swaylock

smitropoulos commented 8 months ago

I also tried to use waylock instead and stumbled upon this. Might be an issue with Hyprland or swayidle?

hannessenonerCTM commented 8 months ago

This is most likely an issue with hyprland, i could reproduce similar behavior when adding a monitor when locked (eg. plugging in a monitor or it coming back from sleep). For me it also happened when starting swaylock from a terminal. I was able to reproduce the same issue with waylock. I could not reproduce the issue disappearing when swaylock was active before suspending (could also be me, I switched from sway to Hyprland yesterday) As a workaround I put this line into the config (inspired by @mindrunner ) bindl = $mainMod, BackSpace , exec, pkill -SIGUSR1 swaylock && WAYLAND_DISPLAY=wayland-1 swaylock

vaxerski commented 8 months ago

can you check on git I made a commit rn

hannessenonerCTM commented 8 months ago

Thanks for the fix, works except when closing a docked laptop, unplugging it and then opening it (I have a monitor connected to my docking station), but i can use the workaround I posted before for that situation. EDIT: it still does not work when triggered by swayidlle

otaj commented 8 months ago

Hi, I wanted to say I was also affected by this problem, but I think, I succesfully managed to isolate when this occurs for me:

Now that I think about, I think it's possible that swayidle is not the culprit, but hyprctl reload is (and I have no way of triggering it right after sleep othen than swayidle at the moment, I'm too lazy to setup a systemd service.

When either of these two conditions doesn't happen, then swaylock is happily taking my keyboard. (i.e. only laptop without monitors plugged in, or not using hyprctl reload right after sleep) I was initially using hyprctl reload in order to trigger things specified in exec in my config, but I can directly put it into swayidle's after-resume section.

I did not test changing the monitor setup while the laptop was sleeping.

otaj commented 8 months ago

I just now tested to put laptop into sleep by systemctl suspend (with swayidle running, therefore triggering before-sleep section, which locks the laptop), unplugging the monitors and waking up and everything works fine without hyprctl reload in after-resume. The other direction (sleeping without monitors, plugging in, waking up) worked as well.

Btw, I'm not on git version, but on 0.34.0-1 from Arch repos.

mindrunner commented 8 months ago

Happened to me without any external screens and not additional setups reloading hyprland.

M4he commented 6 months ago

The lockscreen stopping to receive input happens to me randomly on NixOS when using swaylock-effects in Hyprland. Not just after sleep/resume, also occasionally after locking normally through swayidle.

I can confirm that the emergency recovery methods illustrated above seem to work for me:

When the issue occurs and input focus is lost on swaylock, I can use the keybinding to reset it. The screen will flash red briefly and then a new swaylock instance spawns which receives keyboard input again, enabling me to unlock the screen.

EDIT: forgot to mention that I am unable to use the emergency recovery method from a tty since Hyprland freezes when switching back from a tty in this case for me, hence the need for the keybinding.


For reference are the software versions I am using:

M4he commented 5 months ago

I just encountered this again (I do almost once a day) and after I hit the emergency shortcut and unlocked my screen using a new swaylock instance, I could see parts of my password that I attempted to type until I realized swaylack is not reacting inserted into the terminal window that was visible on the workspace the lockscreen was covering.

So swaylock is not freezing but is actually loosing focus as the original description states. Furthermore, something on the previously active workspace might steal the focus.

As long as this isn't fixed anybody affected by this should be very careful when typing a password and hitting enter. Always check if swaylock is actually reacting to input before hitting enter. Otherwise you might post your password into a chat or something.

vaxerski commented 5 months ago

I thought I fixed this.

vaxerski commented 5 months ago

patch.txt try

M4he commented 5 months ago

patch.txt try

Thank you. I will thoroughly test-drive the patch this week.

sant0s12 commented 5 months ago

I have managed to hit this already:

/tmp/hypr/356414639fc06ace7045236ec41d673342981057_1711394832/hyprland.log:[ERR] BUG THIS: Session locked but focused isn't session lock on key

I was still unable to unlock it though.

leiserfg commented 5 months ago

To me, it happens mainly if I change the display setup. Like, I make the laptop sleep while plugged into a monitor and then wake it up without it, if I connect the monitor again then the focus works.

vaxerski commented 5 months ago

patch.txt try this then

sant0s12 commented 5 months ago

I have managed to hit the bug log but it seems to recover fine afterwards and I've always been able to log in so far.

[LOG] Switch Lid Switch fired, triggering binds.
[LOG] Switch Lid Switch turn on, triggering binds.
[LOG] New session lock!
[LOG] Session got locked by 2d60e40
[LOG] Registered signal for owner 2d60e40: 2d60e58 -> 249e5c0 (owner: wlr_session_lock_v1)
[LOG] Registered signal for owner 2d60e40: 2d60e68 -> 249e628 (owner: wlr_session_lock_v1)
[LOG] Registered signal for owner 2d60e40: 2d60e78 -> 249e690 (owner: wlr_session_lock_v1)
[LOG] Registered signal for owner 2d7cfd0: 2d72ed8 -> 2d7cfe8 (owner: SSessionLockSurface)
[LOG] Registered signal for owner 2d7cfd0: 2d41528 -> 2d7d050 (owner: SSessionLockSurface)
[LOG] Registered signal for owner 2d7cfd0: 2d72ec8 -> 2d7d0b8 (owner: SSessionLockSurface)
[LOG] SessionLockSurface 2d7cfd0 mapped
[LOG] Set keyboard focus to surface 2d72bf0
[LOG] New Gamma event at 7ffc8a1029c0
[LOG] New Gamma event at 7ffc8a1029c0
[LOG] Switch Lid Switch fired, triggering binds.
[LOG] Keybind handling only locked (inhibitor)
[LOG] Switch Lid Switch turn off, triggering binds.
[LOG] Keybind handling only locked (inhibitor)
[LOG] Callback 2d86a78 -> 2d86a70, Keyboard removed.
[LOG] Callback 2d86940 -> 2d86938, Keyboard removed.
[LOG] Callback 2d869a8 -> 2d869a0, Keyboard removed.
[LOG] Callback 2d86a10 -> 2d86a08, Keyboard removed.
[LOG] Destroyed keyboard 2d86910
[LOG] New Gamma event at 7ffc8a1029c0
[LOG] Registered signal for owner 2dd23f0: 2e0d918 -> 2dd2828 (owner: layerSurface)
[LOG] Registered signal for owner 2dd23f0: 2da5318 -> 2dd26f0 (owner: layerSurface)
[LOG] Registered signal for owner 2dd23f0: 2e0d928 -> 2dd2758 (owner: layerSurface)
[LOG] Registered signal for owner 2dd23f0: 2e0d938 -> 2dd27c0 (owner: layerSurface)
[LOG] Registered signal for owner 2dea9d0: 2da5328 -> 2deab50 (owner: CPopup Head)
[LOG] LayerSurface 2da5250 (namespace notifications layer 3) created on monitor eDP-1
[ERR] BUG THIS: No CWLSurface for surface in damageSurface!!!
[WARN] Orphaned wlr_surface 2e0d640 in setPreferredScaleForSurface
[WARN] Orphaned wlr_surface 2e0d640 in setPreferredTransformForSurface
[LOG] LayerSurface 2da5250 mapped
[LOG] Registered signal for owner 2dd25d0: 2e0d958 -> 2dd2618 (owner: CWLSurface)
[LOG] Registered signal for owner 2dd25d0: 2e0d918 -> 2dd2680 (owner: CWLSurface)
[LOG] CWLSurface 2dd25d0 called init()
[LOG] New Gamma event at 7ffc8a1029c0
[LOG] New Gamma event at 7ffc8a1029c0
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[LOG] cursorImage request: surface 0
[LOG] Callback 1bab070 -> 1bab068, CWLSurface removed.
[LOG] Callback 1bab0d8 -> 1bab0d0, CWLSurface removed.
[LOG] CWLSurface 1bab000 called destroy()
[LOG] cursorImage request: surface 2d38fe0
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
[LOG] New Gamma event at 7ffc8a1029c0
[LOG] Attached a keyboard with name Headphones (AVRCP)
[LOG] Registered signal for owner 2d86910: 2dce598 -> 2d86918 (owner: Keyboard)
[LOG] Registered signal for owner 2d86910: 2dce588 -> 2d86980 (owner: Keyboard)
[LOG] Registered signal for owner 2d86910: 2dce468 -> 2d86a50 (owner: Keyboard)
[LOG] Registered signal for owner 2d86910: 2dce5a8 -> 2d869e8 (owner: Keyboard)
[LOG] ApplyConfigToKeyboard for "headphones-(avrcp)", hasconfig: 0
[LOG] Attempting to create a keymap for layout ch-qwerty with variant  (rules: , model: , options: caps:swapescape)
[LOG] Updating keyboard 2d86910's translation state from an active index 0
[LOG] Set the keyboard layout to ch-qwerty and variant to  for keyboard "Headphones (AVRCP)"
[LOG] New keyboard created, pointers Hypr: 2d86910 and WLR: 2dce458
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] BUG THIS: key not found in m_dPressedKeys
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Keybind handling only locked (inhibitor)
[LOG] Session Unlocked
[LOG] Callback 249e6b8 -> 249e6b0, wlr_session_lock_v1 removed.
[LOG] Callback 249e5e8 -> 249e5e0, wlr_session_lock_v1 removed.
[LOG] Callback 249e650 -> 249e648, wlr_session_lock_v1 removed.
[LOG] Set keyboard focus to surface 2d2c810, with [Window 2d32b20: title: "YouTube — Mozilla Firefox"]
[LOG] SessionLockSurface 2d7cfd0 destroyed
[LOG] Callback 2d7d0e0 -> 2d7d0d8, SSessionLockSurface removed.
[LOG] Callback 2d7d078 -> 2d7d070, SSessionLockSurface removed.
[LOG] Callback 2d7d010 -> 2d7d008, SSessionLockSurface removed.
vaxerski commented 5 months ago

[ERR] MEGA BUG THIS: No session lock found at all to focus to??

wtf? sounds like a bug on the side of the lock?

nfjdu commented 5 months ago

[ERR] MEGA BUG THIS: No session lock found at all to focus to??

wtf? sounds like a bug on the side of the lock?

not sure its bug on the side of lock, because i tried swaylock and hyprlock this week. have 2 same bugs on both of them. 1 - described here (no ability to input something after suspend + resume ) , 2 - no ability to change keyboard layout on lockscreen(but this one i have not tried to fix yet, so doesnt matter).

kennylevinsen commented 2 months ago

wtf? sounds like a bug on the side of the lock?

I don't think so:

[LOG] New session lock!
[LOG] Session got locked by 2d60e40
[LOG] SessionLockSurface 2d7cfd0 mapped
[LOG] Set keyboard focus to surface 2d72bf0
...
[LOG] LayerSurface 2da5250 (namespace notifications layer 3) created on monitor eDP-1
[LOG] LayerSurface 2da5250 mapped
[LOG] Set keyboard focus to surface 2d72bf0
...
[ERR] BUG THIS: Session locked but focused isn't session lock on key
[LOG] Set keyboard focus to surface 2d72bf0
[ERR] MEGA BUG THIS: No session lock found at all to focus to??
...
[LOG] Session Unlocked
[LOG] SessionLockSurface 2d7cfd0 destroyed

There's a lock surface present the entire time, so not much more for the client to do - that's the surface that should be given focus. Set keyboard focus to surface XYZ is also printing for each the "BUG THIS" lines, which during a lock can only happen if the surface passed to CCompositor::focusSurface is a session lock surface passing all checks.

Maybe print where wlr_seat_keyboard_notify_enter is called, print the resulting focused_surface after the call, and print then same focused_surface where you do the checks that fail to make sure they're all the same? Also make sure that the logs printing surface-related things use comparable pointers, e.g. all printing the underlying wlr_surface so you can match SessionLockSurface lines with focus lines directly.

vaxerski commented 2 months ago

wlroots stuff is long gone, if this bug is still there I'll revisit it after #6608 is done. Haven't experienced it ever myself so I dunno if it's still a thing

kennylevinsen commented 2 months ago

We just got another poke on that issue on swaylock, so I took a quick look before I closed the issue as being on the Hyprland side of things to make sure it wasn't an unreasonable assumption.

wlroots stuff is long gone,

heh, yeah I was looking at an old checkout - at least it it matched the logs. The business logic in question looks quite similar now though, so the issue might have carried over.