Repository navigation
Fix Auto Scroll activation delay in Finder and add opt-in override for pressable elements - #1340
Closed
gilang-gunawan wants to merge 2 commits into
Closed
gilang-gunawan wants to merge 2 commits into
gilang-gunawan wants to merge 2 commits into
Conversation
…vation delay AutoScrollAccessibilityActivationClassifier's nearby-point resampling (refineActivationProbe) ran on every non-pressable hit unconditionally, which is every successful activation since auto scroll only starts on non-pressable elements. Each pass issued up to 9 extra synchronous AX hit-tests, adding ~600-900ms of perceptible delay before auto scroll activated in Finder and other native list/table views. The resampling exists to compensate for browser accessibility trees reporting an imprecise hit near a link or button, so it now only runs when the hit is actually inside web content (AXWebArea/AXScrollArea ancestor). Measured Finder activation latency: ~600-890ms before, ~7-120ms after.
Auto scroll never activates when the initial click lands on a pressable element (link, button, file icon), by design since linearmouse#1273 removed the old preserveNativeMiddleClick toggle after it proved unreliable (linearmouse#1237, linearmouse#1271) and the maintainer hard-coded "always preserve native click on pressable elements" as the simplified default. linearmouse#1339 reports the flip side: users who want auto scroll to win over a pressable element currently have no way to get it. This adds activateOverPressableElements (default false, so out-of-the-box behavior from linearmouse#1273 is unchanged) to opt into that override per scheme. Unlike the old toggle, this is a pure function of the current hit-test rather than depending on prior click/drag history, which was the root of linearmouse#1237's unreliability. Manually verified both directions with the setting live in a running build: a real AXLink hit still activates auto scroll when enabled, and does not activate it when disabled (default), confirming no regression of linearmouse#1273's fix.
gilang-gunawan
marked this pull request as ready for review
August 7, 2026 15:59
Collaborator
|
Thanks! There used to be a Pressing and dragging over a clickable element failing to trigger Auto Scroll is a regression that needs to be fixed. The performance issue also needs to be addressed, though I’m concerned that the current optimization may stop the AX ancestor traversal too early and change the classification behavior. I’ll test and take a closer look when I have time. |
YuriNachos
pushed a commit
to YuriNachos/linearmouse
that referenced
this pull request
Aug 10, 2026
…mouse#1350) ## Summary - Avoid unnecessary cross-process accessibility queries while classifying native UI elements. - Replace nearby-point sampling with a single retry at the original click position. - Retry only for browser accessibility signals or recoverable AX errors (`cannotComplete` and `notImplemented`). - Lazily collect expensive action, geometry, child, and scrollbar information only when required. ## Background PR linearmouse#1340 first identified that `AutoScrollAccessibilityActivationClassifier` performed nearby-point resampling for every non-pressable hit. Because Auto Scroll normally starts on non-pressable areas, native views such as Finder could perform up to nine additional synchronous AX hit tests before showing the Auto Scroll indicator. linearmouse#1340 addressed the latency by restricting nearby sampling to web content and stopping ancestor traversal at list containers. This PR supersedes that approach with a more targeted implementation: - Native non-pressable elements return immediately without additional hit tests. - Full ancestor traversal is preserved so list containers do not change classification semantics. - Expensive AX attributes are queried lazily instead of truncating the ancestor walk. - Nearby coordinates are no longer sampled, avoiding decisions based on adjacent controls. - Browser uncertainty is handled by waiting 5 ms and retrying the original position once. Chromium documents that its first synchronous accessibility hit test can be an approximate bounding-box result while the renderer resolves the precise result asynchronously. Its regression test likewise expects the first cached hit test to miss and the second hit test at the same point to succeed. - Architecture documentation: https://chromium.googlesource.com/chromium/src/+/main/docs/accessibility/browser/how_a11y_works_3.md#Hit-testing - Chromium regression test: https://chromium.googlesource.com/chromium/src/+/HEAD/content/browser/accessibility/hit_testing_browsertest.cc#710 Safari was also observed returning a transient `kAXErrorNotImplemented` during a cold web accessibility hit test. The retry is therefore limited to browser signals and recoverable AX errors. Permanent errors such as `invalidUIElement` retain their diagnostics and return immediately. The `activateOverPressableElements` option proposed by linearmouse#1340 is intentionally not included. The press-and-drag workflow from linearmouse#1339 has since been addressed separately by linearmouse#1348 using long-press activation, without restoring a native middle-click override. Thanks to @gilang-gunawan for identifying the unconditional AX resampling bottleneck, providing measurements, and proposing the original fix in linearmouse#1340. ## Testing - Verified Auto Scroll classification in the current Finder list view. - Steady-state classification decreased from approximately 480–500 ms to 1.2–1.4 ms. - Native non-pressable elements perform one hit test without the retry delay. - Verified a cold Chrome hit changes from a generic non-pressable container to an `AXLink` after retrying the same position. - Verified a cold Safari hit changes from `hitTest.notImplemented` to an `AXLink` after retrying the same position. - Verified `cannotComplete` and `notImplemented` retry. - Verified permanent AX errors do not retry. - All 557 unit tests pass. - Strict SwiftLint passes with no violations. Closes linearmouse#1340 Co-authored-by: Gilang Gunawan <[email protected]>
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
Auto Scroll used to feel broken in two common situations:
lag — sometimes close to a second — before scrolling actually kicked in. It's now
effectively instant.
click always went to the app instead. This adds an off-by-default setting to let
Auto Scroll win in that case when you want it to.
Why this matters
Scroll activation goes through, in any native app (Finder, Xcode, Mail, Notes, etc).
It just wasn't obvious why it lagged, so it was easy to write off as "Auto Scroll is
a bit slow" instead of catching it as a fixable bug.
Auto Scroll does not work when middle-click dragging over clickable items/links #1339), a delay or an outright block on activation isn't a minor annoyance — it's the
difference between the feature working or not.
removed in Fix Chromium tab-strip middle-click with Auto Scroll #1273 for being unreliable (Auto Scroll Preserve Native Middle-Click Option Buggy #1237, Middle click won't close Chrome tab when AutoScroll is enabled #1271). This closes that gap without
reintroducing the old bug: the new setting is off by default, and unlike the old one,
its behavior doesn't depend on click/drag history.
Technical details
AutoScrollAccessibilityActivationClassifier's nearby-point resampling(
refineActivationProbe) ran 9 extra synchronous AX hit-tests on every non-pressablehit, unconditionally — i.e. on every successful activation, since Auto Scroll only
starts on non-pressable elements. That resampling exists solely to compensate for
browser accessibility-tree imprecision near links/buttons, so it now only runs when
the hit is actually inside web content (
AXWebArea/AXScrollAreaancestor). MeasuredFinder activation latency: ~600-890ms before, ~7-120ms after.
activateOverPressableElementssetting (defaultfalse) so AutoScroll can start even when the initial click lands on a link, button, or clickable
file, at the cost of the native middle-click action on that element.
Related history
This touches the same code path as #1273, so some context on why this isn't a blind
revert of that change:
preserveNativeMiddleClicktoggle.previously been dragged, so native middle-click sometimes silently failed.
native click on pressable elements," explicitly to eliminate that inconsistency.
activateOverPressableElementsis not a reintroduction of the oldpreserveNativeMiddleClicktoggle: it's additive (defaultfalse, so out of the boxnothing changes from #1273's behavior) rather than replacing the always-on classifier
logic, and its correctness doesn't depend on click/drag history the way the old
toggle's bug did — the classifier is a pure function of the current hit-test, not
accumulated state.
Testing
log streamagainst a rebuilt/reinstalled app, not just unittests:
repeated activations on real Finder list rows.
activateOverPressableElements: true: a realAXLinkhit(
AXStaticText -> AXLink[press]) still activated Auto Scroll.activateOverPressableElements: false(default): four separate realAXLinkhits did not activate Auto Scroll, confirming no regression of Fix Chromium tab-strip middle-click with Auto Scroll #1273's fix.
Closes #1339