-
-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Labels
bugSomething isn't working as expectedSomething isn't working as expected
Description
There are two cases when it's possible:
1. When you unlock the screen. It's because the current algorithm of saving state before the screen is locked is incorrect. To fix it, we should make TreeNode
immutable #1215, which will make it a breath to take snapshots of the tree on its every modification before windows start "dying out" when the screen is locked.
2. During high CPU usage / when apps are slow at responding AX requests. When AeroSpace checks for dead windows, it doesn't distinguish between long responses and nil
response. Though it's a hypothesis, which should be investigated
Both of the issue are caused by #445 (since 0.16.0-Beta)
Action points:
(1) Investigate 21336ad
(2) Test case
commit a6b44c561e48191bf5ad2454ab4e414df2c4c733
Author: Nikita Bobko <[git@bobko.xyz](mailto:git@bobko.xyz)>
AuthorDate: Thu Dec 5 22:24:21 2024 +0100
Commit: Nikita Bobko <[git@bobko.xyz](mailto:git@bobko.xyz)>
CommitDate: Sun Feb 16 18:56:55 2025 +0100
TODO. Improve reliability of windows position restore on screen unlock. FUCK THIS DOESN'T WORK
test case:
Given: window1 and window2, window1 is in the closedWindowCache cache, window2 isn't
Steps:
1. lock the screen
2. window1 dies -> cache is not updated
3. window2 dies -> cache is updated, but it won't include window1, since window1 is already dead :(
4. unlock the screen
5. Only window2 is restored
The commit makes sure that the "given" is never the case
diff --git Sources/AppBundle/tree/MacWindow.swift Sources/AppBundle/tree/MacWindow.swift
index f2c2e685..27e68a97 100644
--- Sources/AppBundle/tree/MacWindow.swift
+++ Sources/AppBundle/tree/MacWindow.swift
@@ -38,6 +38,7 @@ final class MacWindow: Window, CustomStringConvertible {
allWindowsMap[id] = window
debugWindowsIfRecording(window)
if !restoreClosedWindowsCacheIfNeeded(newlyDetectedWindow: window) {
+ if !isClosedWindowsCacheUseful() { resetClosedWindowsCache() }
tryOnWindowDetected(window, startup: startup)
}
return window
diff --git Sources/AppBundle/tree/frozen/closedWindowsCache.swift Sources/AppBundle/tree/frozen/closedWindowsCache.swift
index 20da4b17..f042d607 100644
--- Sources/AppBundle/tree/frozen/closedWindowsCache.swift
+++ Sources/AppBundle/tree/frozen/closedWindowsCache.swift
@@ -121,3 +121,7 @@ private func restoreTreeRecursive(frozenContainer: FrozenContainer, parent: NonL
func resetClosedWindowsCache() {
closedWindowsCache = FrozenWorld(workspaces: [], monitors: [])
}
+
+func isClosedWindowsCacheUseful() -> Bool {
+ closedWindowsCache.windowIds.contains { MacWindow.get(byId: $0) == nil }
+}
check24-danielpaschsannapiu, inwonakng, jovanadjuric, jklaise, charles0801 and 30 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't working as expectedSomething isn't working as expected