Repository navigation
Reduce typing lag by hiding invisible views from accessibility tree - #862
Conversation
Profiling shows the main thread spends ~24% of time in AccessibilityViewGraph.needsUpdate walking invisible SwiftUI views during every layout pass, blocking key event dequeue. - Add .accessibilityHidden on inactive workspaces in the ZStack (opacity-0 but still walked by the accessibility subsystem) - Add .accessibilityHidden on NotificationsPage and the tabs container when their respective selection is not active - Mark GhosttyTerminalView's HostContainerView (empty portal placeholder) as non-accessible since the terminal surface lives in the AppKit portal layer above SwiftUI
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request enhances accessibility by adding modifiers to hide non-visible or non-selected UI elements from assistive technologies. Additionally, a temporary container in the terminal view is marked to prevent accessibility traversal into placeholder elements. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR addresses typing lag caused by SwiftUI's accessibility subsystem walking the entire view tree during layout passes. The changes hide invisible views from the accessibility tree using Key changes:
The boolean logic correctly mirrors existing visibility patterns (opacity + hit testing), and follows the established pattern in the codebase of hiding invisible UI elements from accessibility. No actual accessibility functionality is affected since these views are already invisible to users. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 5742799 |
…anaflow-ai#862) Profiling shows the main thread spends ~24% of time in AccessibilityViewGraph.needsUpdate walking invisible SwiftUI views during every layout pass, blocking key event dequeue. - Add .accessibilityHidden on inactive workspaces in the ZStack (opacity-0 but still walked by the accessibility subsystem) - Add .accessibilityHidden on NotificationsPage and the tabs container when their respective selection is not active - Mark GhosttyTerminalView's HostContainerView (empty portal placeholder) as non-accessible since the terminal surface lives in the AppKit portal layer above SwiftUI
Summary
Profiling cmux NIGHTLY with
sampleshows the main thread spending ~24% of CPU time inAccessibilityViewGraph.needsUpdateduring every SwiftUI layout pass. The accessibility subsystem walks the entire view tree, including invisible views (opacity-0, hit-testing disabled), blocking the run loop from dequeuing key events and causing typing lag.ContentView.swift). All mounted workspaces sit in a ZStack; inactive ones are opacity-0 but still walked. Adding.accessibilityHidden(!isVisible)eliminates them from the walk.GhosttyTerminalView'sHostContainerViewas non-accessible. This empty NSView placeholder (portal pattern) has no content since the terminal surface lives in the AppKit layer above SwiftUI.Note:
NotificationsPageis effectively dead code for users (all notification paths go to the popover). Could be removed entirely in a follow-up.Testing
sample <pid> 10while typing to compareAccessibilityViewGraph.needsUpdatesample counts before/after.Profiling data (before)
Main thread sample breakdown (10s capture, 5707 samples):
NSHostingView.layout()→ SwiftUI view graph renderAccessibilityViewGraph.needsUpdateUpdateStack::update()AccessibilityViewModifierAccessorSummary by cubic
Hide invisible SwiftUI views from the accessibility tree to reduce layout overhead and improve typing responsiveness. This cuts time spent in AccessibilityViewGraph.needsUpdate during layout.
Written for commit 5742799. Summary will update on new commits.
Summary by CodeRabbit