Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e1f2eaabdb5cd246aee4a328b8a81cbbe0043662
      
https://github.com/WebKit/WebKit/commit/e1f2eaabdb5cd246aee4a328b8a81cbbe0043662
  Author: Simon Fraser <[email protected]>
  Date:   2026-04-03 (Fri, 03 Apr 2026)

  Changed paths:
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-expected.txt
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-in-overflow-expected.txt
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-in-overflow.html
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold.html
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-below-threshold-expected.txt
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-below-threshold.html
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-large-cumulative-adjustment-expected.txt
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-large-cumulative-adjustment.html
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-renabled-after-delay-expected.txt
    A 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-renabled-after-delay.html
    A 
LayoutTests/fast/scrolling/scroll-anchoring/resources/scroll-anchoring-utils.js
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebCore/page/scrolling/ScrollAnchoringController.cpp
    M Source/WebCore/page/scrolling/ScrollAnchoringController.h

  Log Message:
  -----------
  [Scroll anchoring] Add a heuristic that disables scroll anchoring for 
frequent adjustments
https://bugs.webkit.org/show_bug.cgi?id=311227
rdar://173680821

Reviewed by Abrar Rahman Protyasha.

Some sites (e.g. depop.com, linkedin.com) suffer from scroll position 
oscillations triggered by scroll anchoring.
Such issues are easy to cause by accident by combining scroll position 
observation (e.g. via window.scrollY
or Intersection Observer) and content changes. Gecko has a heuristic to disable 
anchoring in cases like this,
so do something similar.

The goal here is to detect oscillations triggered by circular dependencies 
between anchoring scrolls
and content changes, which will generally show up with a single frame delay, 
but I allowed for about
two frames per update to account for slower web content, so I decided that 10 
adjustments in 350ms
is the threshold above which anchoring will be temporarily disabled. It will 
re-enable after 3s.
A user scroll will also re-enable it. The heuristic also computes the sum of 
the cumulative adjustments,
looking for a small mean adjustment (since this indicates an oscillation 
between two states).

webkit.org/b/311235 needs to be fixed before all the tests pass on iOS.

Tests: fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold.html
       fast/scrolling/scroll-anchoring/heuristic-enabled-below-threshold.html
       fast/scrolling/scroll-anchoring/heuristic-renabled-after-delay.html

* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-in-overflow-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold-in-overflow.html:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-disabled-above-threshold.html:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-below-threshold-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-below-threshold.html:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-large-cumulative-adjustment-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-enabled-large-cumulative-adjustment.html:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-renabled-after-delay-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/heuristic-renabled-after-delay.html:
 Added.
* 
LayoutTests/fast/scrolling/scroll-anchoring/resources/scroll-anchoring-utils.js:
 Added.
(toggleHeight):
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/page/scrolling/ScrollAnchoringController.cpp:
(WebCore::ScrollAnchoringController::scrollPositionDidChange):
(WebCore::ScrollAnchoringController::adjustScrollPositionForAnchoring):
(WebCore::ScrollAnchoringController::DisablementHeuristic::disabledByHeuristic):
(WebCore::ScrollAnchoringController::DisablementHeuristic::reset):
* Source/WebCore/page/scrolling/ScrollAnchoringController.h:

Canonical link: https://commits.webkit.org/310545@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to