qtile / qtile

:cookie: A full-featured, hackable tiling window manager written and configured in Python (X11 + Wayland)
http://qtile.org
MIT License
4.67k stars 691 forks source link

stale window in x11 layering code #4672

Open tych0 opened 5 months ago

tych0 commented 5 months ago

Issue description

I'm getting some errors from the layering code, and when qtile gets into this state, it gets very confused and will refuse to do many things, so it is quite annoying :). I'll think about how to protect us from ourselves so we can keep going in situations like this, but it looks like there's some staleness that can happen here too.

Version

0.24.0

Backend

X11 (default)

Config

No response

Logs

2024-01-28 07:22:12,766 ERROR libqtile core.py:_xpoll():L370 Got an exception in poll loop
Traceback (most recent call last):
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/core.py", line 345, in _xpoll
    self.handle_event(event)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/core.py", line 312, in handle_event
    ret = target(event)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/core.py", line 767, in handle_MapRequest
    self.qtile.manage(win)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/core/manager.py", line 702, in manage
    self.current_screen.group.add(win, focus=win.can_steal_focus)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/group.py", line 269, in add
    self.focus(win, warp=True, force=force)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/group.py", line 233, in focus
    self.layout_all(warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/group.py", line 165, in layout_all
    self.current_window.focus(warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 2312, in focus
    _Window.focus(self, warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 1334, in focus
    self.qtile.core.check_stacking(self)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/core.py", line 952, in check_stacking
    self.last_focused.change_layer()
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 1177, in change_layer
    self.qtile.windows_map[wid].window.configure(
KeyError: 142606350


### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.
elParaguayo commented 5 months ago

This may be related to what #4583 is trying to fix. Can you see if that helps?

tych0 commented 5 months ago

Great, thanks! I have been running 0.24.0 since it was released, and only seen this once, so it takes some strangeness to reproduce. I'll run your branch and report back here if it doesn't reappear.

elParaguayo commented 5 months ago

I could be way off the mark with that PR so feel free to tell me I'm doing it completely wrong.

tych0 commented 5 months ago

It looks like it will definitely fix it, but I read the existing code and couldn't figure out why it was wrong. Seems like we're caching a wid somewhere, but I couldn't figure out where?

elParaguayo commented 5 months ago

I'm not convinced that's the problem. I think the issue is that, when we query the stack, we get some window IDs which aren't in our window map. That could happen with override_redirect windows but there seem to be other cases that I don't quite understand.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 90 days with no activity. Remove the status: stale label or comment, or this will be closed in 30 days.

tych0 commented 1 month ago

I think we can close this, I haven't seen it again.

tych0 commented 1 month ago

Heh... spoke too soon. I just got:

2024-05-27 14:55:05,057 ERROR libqtile manager.py:process_key_event():L470 KB command error up: Traceback (most recent call last):
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/command/interface.py", line 431, in call
    return SUCCESS, cmd(*args, **kwargs)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/layout/max.py", line 81, in up
    _SimpleLayoutBase.previous(self)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/layout/base.py", line 521, in previous
    self.group.focus(client, True)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/group.py", line 233, in focus
    self.layout_all(warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/group.py", line 165, in layout_all
    self.current_window.focus(warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 2331, in focus
    _Window.focus(self, warp)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 1334, in focus
    self.qtile.core.check_stacking(self)
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/core.py", line 941, in check_stacking
    self.last_focused.change_layer()
  File "/home/tycho/.local/lib/python3.10/site-packages/libqtile/backend/x11/window.py", line 1177, in change_layer
    self.qtile.windows_map[wid].window.configure(
KeyError: 83886094