Repository navigation
Fix portal hit-test CPU on pointer movement - #6592
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaces recursive AppKit view-tree scanning on every pointer event with a cached ChangesPortal hit-testing performance: caching and event-type gating
Sequence Diagram(s)sequenceDiagram
participant AppKit as AppKit (pointer/layout event)
participant HostView as WindowTerminalHostView / WindowBrowserHostView
participant Cache as cachedSplitDividerRegions
participant Region as PortalSplitDividerRegion.collect()
participant Invalidator as PortalSplitDividerCacheInvalidator
rect rgba(200, 80, 80, 0.5)
Note over AppKit,Invalidator: Cache invalidation path
AppKit->>HostView: viewDidMoveToWindow / setFrameSize / didAddSubview / willRemoveSubview
HostView->>Invalidator: observe(geometryViews, structureViews, onChange:)
Invalidator->>Cache: invalidateSplitDividerRegionCache() → nil
HostView->>AppKit: invalidateCursorRects
end
rect rgba(80, 120, 200, 0.5)
Note over AppKit,Region: Hit-test / cursor-rect path (pointer move)
AppKit->>HostView: performHitTest / splitDividerCursorKind / resetCursorRects
HostView->>Cache: splitDividerRegions()
Cache-->>HostView: nil (miss) → Region.collect(in:hostView:)
Region-->>Cache: [PortalSplitDividerRegion] stored
HostView->>HostView: dividerHit / dividerCursorKind iterates cached regions only
HostView-->>AppKit: hit result (isInHostedContent, cursor kind)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (21 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f2dcc74 to
bb413c9
Compare
bb413c9 to
176d651
Compare
Greptile SummaryReplaces the per-pointer-event recursive portal hit-testing with a cached split-divider region approach and a registry-only fast path for hover events. The motivation is clear: profile captures showed over 1.3 s of sampled time in
Confidence Score: 5/5Safe to merge. The changes are a well-bounded performance fix on the pointer-event hot path with no behavioral regressions. The refactoring replaces recursive walks with a flat cached-rect array backed by multiple invalidation edges. The allLive() safety net ensures stale rects cannot persist. Six new tests cover the key liveness scenarios. No actor isolation mistakes, no blocking primitives, no user-facing text changes, and no new test-only seams in production source. No files require special attention. Important Files Changed
Reviews (9): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
Summary
Fixes #6586 by removing unbounded portal hit-test work from high-frequency pointer movement paths.
The supplied Time Profiler captures are the reproduction evidence. No manual gesture transcript was supplied, so the interaction path is inferred from the repeated stacks in the profiles.
Profile Evidence Before
From
time-profile-184312.xml:10112 msof12370 mssampled.BonsplitTabBarPassThrough.shouldPassThroughToPaneTabBar(windowPoint:below:):1338 msBonsplitTabBarPassThrough.hasUnderlyingBonsplitTabBarBackground(at:below:):1333 msBonsplitTabBarPassThrough.hasBonsplitTabBarBackground(at:in:):1328 msWindowBrowserHostView.hitTest(_:):583 msWindowTerminalHostView.performHitTest(at:currentEvent:):512 msWindowTerminalHostView.updateDividerCursor(at:):503 msFrom
time-profile-184454.xml:3377 msof4483 mssampled.WindowBrowserHostView.dividerHitandWindowTerminalHostView.dividerCursorKind.What Changed
mouseMoved/mouseEntered/mouseExited/cursorUpdatetab-strip pass-through now trustsBonsplitTabBarHitRegionRegistryand skips the fallback class-name subtree scan on registry miss.NSSplitView.didResizeSubviewsNotification.Tests
TabBarBackgroundNSViewdescendantsNotes
No user-facing strings were changed, so no localization catalog updates were needed.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Cuts CPU on pointer hover by replacing recursive portal hit‑testing with cached, liveness‑checked split‑divider regions and registry‑only tab‑bar routing. Fixes #6586.
Bug Fixes
BonsplitTabBarHitRegionRegistry; non‑hover events keep a bounded top‑band fallback scan.NSSplitView.didResizeSubviewsNotificationvia bounded observers with safe cleanup; Browser keeps hosted‑inspector dividers interactive while app splits pass through.Tests
PortalHitTestingPerformanceTestscovering registry‑only hover routing, reuse of cached divider regions on pointer moves, stale cache rejection after split removal, and cache refresh on root/nested insertions, visibility changes, and container moves.Written for commit ac4c396. Summary will update on new commits.
Summary by CodeRabbit