nikitabobko / AeroSpace

AeroSpace is an i3-like tiling window manager for macOS
https://nikitabobko.github.io/AeroSpace/guide
MIT License
7.6k stars 125 forks source link

Aerospace accumulates Ghost Windows over time #570

Closed dhruvasagar closed 1 month ago

dhruvasagar commented 1 month ago

Aerospace gets these ghost windows that mess up it's window sizing / layout from time to time. I am on Macbook Pro with OSX version Sonoma 14.5 having a M1 Pro.

λ aerospace list-windows --all
17321 | Emacs   |
17321 | Emacs   |
17266 | Emacs   |
17266 | Emacs   |
17191 | Emacs   |
17182 | Emacs   |
17182 | Emacs   |
17151 | Emacs   |
17139 | Emacs   |
17126 | Emacs   |
17126 | Emacs   |
17067 | Emacs   |
17046 | Emacs   |
17046 | Emacs   |
17011 | Emacs   |
17266 | Emacs   |
118   | Firefox | Inbox (507) - dhruva@zenoptics.com - ZENOPTICS Mail
115   | Firefox | Problem loading page
119   | Firefox | YouTube
6054  | Slack   | zenoptics-dev (Channel) - Tarka Labs - Slack
8149  | WezTerm | zenoptics:3:zsh - "RFL498.local"

As you can see above, I have only 1 window of Emacs, however aerospace has accumulated a ton of these, and these always mess up the layout. The only solution I have found is to kill and restart Aerospace after which it is fine, but over time it seems to end up in a similar situation.

Here's my configuration :

start-at-login = true

enable-normalization-flatten-containers = true
enable-normalization-opposite-orientation-for-nested-containers = true

on-focused-monitor-changed = ['move-mouse monitor-lazy-center']
on-focus-changed = "move-mouse window-lazy-center"

# Notify Sketchybar about workspace change
exec-on-workspace-change = ['/bin/bash', '-c',
    'sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE'
]

[mode.main.binding]
alt-enter = 'exec-and-forget open -n /Applications/WezTerm.app'
alt-ctrl-b = '''exec-and-forget osascript <<EOF
tell application "Firefox" to activate
delay 0.5
tell application "System Events" to keystroke "n" using command down
EOF'''

alt-tab = 'workspace-back-and-forth'
alt-shift-q = 'close'

alt-h = 'focus left'
alt-j = 'focus down'
alt-k = 'focus up'
alt-l = 'focus right'

alt-ctrl-h = 'join-with left'
alt-ctrl-j = 'join-with down'
alt-ctrl-k = 'join-with up'
alt-ctrl-l = 'join-with right'

alt-shift-h = 'move left'
alt-shift-j = 'move down'
alt-shift-k = 'move up'
alt-shift-l = 'move right'

alt-f = 'fullscreen'
alt-shift-f = 'close-all-windows-but-current'

alt-s = 'layout v_accordion' # 'layout stacking' in i3
alt-t = 'layout h_accordion' # 'layout tabbed' in i3
alt-e = 'layout tiles horizontal vertical' # 'layout toggle split' in i3

alt-shift-space = 'layout floating tiling'
alt-comma = 'layout tiles horizontal vertical'

alt-1 = 'workspace 1'
alt-2 = 'workspace 2'
alt-3 = 'workspace 3'
alt-4 = 'workspace 4'
alt-5 = 'workspace 5'
alt-6 = 'workspace 6'
alt-7 = 'workspace 7'
alt-8 = 'workspace 8'
alt-9 = 'workspace 9'
alt-0 = 'workspace 10'

alt-ctrl-p = 'workspace prev --wrap-around'
alt-ctrl-n = 'workspace next --wrap-around'

alt-ctrl-1 = 'move-node-to-workspace 1'
alt-ctrl-2 = 'move-node-to-workspace 2'
alt-ctrl-3 = 'move-node-to-workspace 3'
alt-ctrl-4 = 'move-node-to-workspace 4'
alt-ctrl-5 = 'move-node-to-workspace 5'
alt-ctrl-6 = 'move-node-to-workspace 6'
alt-ctrl-7 = 'move-node-to-workspace 7'
alt-ctrl-8 = 'move-node-to-workspace 8'
alt-ctrl-9 = 'move-node-to-workspace 9'
alt-ctrl-0 = 'move-node-to-workspace 10'

alt-shift-1 = ['move-node-to-workspace 1', 'workspace 1']
alt-shift-2 = ['move-node-to-workspace 2', 'workspace 2']
alt-shift-3 = ['move-node-to-workspace 3', 'workspace 3']
alt-shift-4 = ['move-node-to-workspace 4', 'workspace 4']
alt-shift-5 = ['move-node-to-workspace 5', 'workspace 5']
alt-shift-6 = ['move-node-to-workspace 6', 'workspace 6']
alt-shift-7 = ['move-node-to-workspace 7', 'workspace 7']
alt-shift-8 = ['move-node-to-workspace 8', 'workspace 8']
alt-shift-9 = ['move-node-to-workspace 9', 'workspace 9']
alt-shift-0 = ['move-node-to-workspace 10', 'workspace 10']

alt-shift-c = 'reload-config'
alt-r = 'mode resize'
alt-equal = 'balance-sizes'

[mode.resize.binding]
h = 'resize width -50'
j = 'resize height +50'
k = 'resize height -50'
l = 'resize width +50'
enter = 'mode main'
esc = 'mode main'

# Application to workspace mapping
[[on-window-detected]]
if.app-id = 'com.github.wez.wezterm'
run = "layout floating"

[[on-window-detected]]
if.app-id = 'com.tinyspeck.slackmacgap'
run = "move-node-to-workspace 1"

[[on-window-detected]]
if.app-id = 'com.apple.mail'
run = "move-node-to-workspace 4"

[[on-window-detected]]
if.app-id = 'com.microsoft.teams2'
run = "move-node-to-workspace 5"

[[on-window-detected]]
if.app-id = 'org.qutebrowser.qutebrowser'
run = 'layout tiling'

[[on-window-detected]]
if.app-id = 'com.openai.chat'
run = 'layout floating'

[[on-window-detected]]
if.app-id = 'org.gnu.Emacs'
run = 'layout floating'

[gaps]
inner.horizontal = 2
inner.vertical = 2
outer.left = 2
outer.bottom = 2
outer.top = 2
outer.right = 2

Checklist

aerospace CLI client version: 0.14.2-Beta 0cb8dbdfc5ee73b8cbc200f175f467ebead55201
AeroSpace.app server version: 0.14.2-Beta 0cb8dbdfc5ee73b8cbc200f175f467ebead55201
aohoyd commented 1 month ago

Same problem here. These ghost windows are also occupy space. I'm openning new window of Zed (cmd-shift-n), closing it (cmd-shift-w). The new window closes but windows on monitor are not rearranged, so I have some free space without any window

ParisTheProgrammer commented 1 month ago

@aohoyd This may not make a difference, but if you try mapping the aerospace close command to a key binding, use that key mapping to close your zed windows, and then run aerospace list-windows --all is anything different? Do the ghost windows still appear?

https://nikitabobko.github.io/AeroSpace/commands#close

aohoyd commented 1 month ago

@ParisTheProgrammer aerospace close closes windows correctly.

I'm openning 3 windows:

1437 | Zed Preview | dive
1517 | Zed Preview | empty project
1518 | Zed Preview | empty project

Now close first empty project with aerospace close:

1437 | Zed Preview | dive
1518 | Zed Preview | empty project

And close the second empty project with cmd+shift+w:

1518 | Zed Preview |
1437 | Zed Preview | dive

As you can see a title is gone, but the window is not removed by some reason. I reproduced it for vscode, orion browser and obsidian. I tried to get debug-window output, but I can't focus any ghost window, even from cli

aohoyd commented 1 month ago

Same problem was described in https://github.com/nikitabobko/AeroSpace/issues/321

leavism commented 1 month ago

Same problem here with various applications. Restarting Aerospace was the only way to get rid of them.

dhruvasagar commented 1 month ago

If I disable the on-window-detected section for emacs, this problem goes away, so it must be something with that.

tinkyholloway commented 1 month ago

For me, it only takes a few minutes for this to happen with my normal workflow.

Changing the Safari profile makes a ghost window as does pretty much any use of Finder.

dhruvasagar commented 1 month ago

I stand corrected, disabling the on-window-detected does not actually fix this, it's still happenning.

tinkyholloway commented 1 month ago

It seems very reproducable for me. If I compose an email with Mail, it creates a window to compose the email. Then, when the mail is sent, the compose window is removed, but the ghost window remains. It looks like any window that is closed without using aerospace close is retained by aerospace for layout:

~ aerospace list-windows --workspace 10
51   | Calendar | Calendar
2877 | Mail     |
2709 | Mail     |
93   | Mail     | All Inboxes – 1 message
tinkyholloway commented 1 month ago

I switched off everything in Settings > Login Items & Extensions and rebooted and since then I've not seen a reoccurence. I'm not sure yet what was causing my problem, I'll need to switch things on one at a time until the problem reoccurs to find out. Perhaps this will be of help to others with similar problems.

thewinger commented 1 month ago

It's also happening to me. Orcaslicer is close, it doesn't show in activity monitor or when I do CMD+TAB, but if I do in terminal:

❯  aerospace list-windows --workspace visible --format '{ "title": "%{app-name}", "subtitle": "%{window-title}", "windowId": "%{window-id}", "appPid": "%{app-pid}", "workspace": "%{workspace}, "bundleId": "%{app-bundle-id}"}'

{ "title": "Alacritty", "subtitle": "👨🏻‍💻", "windowId": "10761", "appPid": "709", "workspace": "M, "bundleId": "org.alacritty"}
{ "title": "Arc", "subtitle": "Aerospace accumulates Ghost Windows over time · Issue #570 · nikitabobko/AeroSpace", "windowId": "6281", "appPid": "76210", "workspace": "M, "bundleId": "company.thebrowser.Browser"}
{ "title": "Finder", "subtitle": "Cults - Flexi Spider", "windowId": "7809", "appPid": "731", "workspace": "M, "bundleId": "com.apple.finder"}
{ "title": "OrcaSlicer", "subtitle": "", "windowId": "8317", "appPid": "6407", "workspace": "M, "bundleId": "com.softfever3d.orca-slicer"}
{ "title": "OrcaSlicer", "subtitle": "", "windowId": "8351", "appPid": "6407", "workspace": "M, "bundleId": "com.softfever3d.orca-slicer"}
{ "title": "OrcaSlicer", "subtitle": "", "windowId": "8397", "appPid": "6407", "workspace": "M, "bundleId": "com.softfever3d.orca-slicer"}
{ "title": "Telegram", "subtitle": "Telegram", "windowId": "68", "appPid": "704", "workspace": "M, "bundleId": "ru.keepcoder.Telegram"}
{ "title": "‎WhatsApp", "subtitle": "‎WhatsApp", "windowId": "53", "appPid": "714", "workspace": "M, "bundleId": "net.whatsapp.WhatsApp"}

it shows as you can see.

nikitabobko commented 1 month ago

The bug appeared in Sequoia. In Sequoia, some apps may interfere with AeroSpace, known apps: contexts app, Amazon Q

Tracking issue: #445

thewinger commented 1 month ago

FYI, I'm not in sequoia