Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an app is temporarily unresponsive on the Accessibility API (for example, Electron/Chromium apps during heavy DOM streaming) or when Rectangle's own Settings window is open/active during window interactions,
SnappingManagercan stall the main thread for several seconds:AccessibilityElement.getWindowElementUnderCursorperforms unbounded synchronous AX calls (AXUIElementCopyAttributeValue(.windows)andAXUIElementCopyElementAtPosition). When an app times out, Stage 1 falls through to Stage 2 (systemWide) and Stage 3 (frontmostApplication), andSnappingManager.leftMouseDraggedretries up to 20 times.SnappingManager.checkFullScreen()callsAccessibilityElement.getFrontWindowElement()onfrontAppChanged, which also cascades through unbounded AX fallbacks (.focusedWindow->.windows->systemWide.focusedUIElement).AccessibilityElement(pid)previously queried.roleover AX IPC insideapplicationElementeven though the element is already known to be an application element, andgetWindowElementUnderCursordid not short-circuit on Rectangle's own windows.Changes
Rectangle/Utilities/AXExtension.swift: AddedAXLookupResult,AXUIElement.didMessagingTimeout, andperformTimedLookupfor optional bounded-timeoutgetValueResult/getElementAtPositionResultcalls (restoring timeout to0viadefer).Rectangle/General/AccessibilityElement.swift:knownApplicationflag forAccessibilityElement(_ pid:)to skip redundant.roleAX IPC.WindowLookupResult(.found,.ownWindow,.notFound,.timedOut) andaxLookupTimeout = 0.25(matchingOverlapOffsetGeometry,StackBadgeManager,StackCycleManager, andNewWindowActionManager).resolveWindowElementUnderCursoron own windows and on.timedOutso fallbacks do not cascade.getFrontWindowElement(timeout: Float? = nil)withresolveFrontWindowElementto stop cascading on.timedOutwhen bounded.Rectangle/Snapping/SnappingManager.swift:checkFullScreen()in-process viaNSApp.windowswhen own app is frontmost, and bounded external-app lookups withaxLookupTimeout.abortNativeGesture()and aborted the drag gesture on.ownWindowor.timedOutinleftMouseDown/leftMouseDraggedto prevent 20x retry loops.RectangleTests/SnappingTests.swift: AddedSelfWindowAccessibilityGuardTestscovering own-window short-circuiting, timeout cascading prevention, andSnappingManagerdrag-retry abort.Verification
sampleagainst a local Debug build while interacting with a busy Electron app: multi-secondgetWindowElementUnderCursor/checkFullScreenstalls were eliminated.RectangleTests: 796 passed, 0 failed, 11 skipped (run locally on Xcode 26.6 / macOS 26.7.3).