Open Bug 2017563 Opened 9 months ago Updated 9 days ago

codepen.io - It scrolls the page from time to time when using the mouse wheel to zoom in/out the SVG

Categories

(Core :: Panning and Zooming, defect, P3)

Desktop
Windows 10
defect

Tracking

()

People

(Reporter: ctanase, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [webcompat-source:web-bugs])

Attachments

(2 files)

Environment:
Operating system: Windows 10
Firefox version: Firefox 147.0/149

Steps to reproduce:

  1. Go to https://codepen.io/CAYdenberg/pen/ExMOMMo
  2. Hover over the element in the results window.
  3. Scroll up and down fast using the mouse wheel.

Expected Behavior:
The element gets zoomed in/out.

Actual Behavior:
Besides the element getting zoomed in/out, from time to time section gets scrolled as well.

Notes:

  • Reproduces regardless of the status of ETP
  • Reproduces in firefox-nightly, and firefox-release
  • Does not reproduce in chrome

Created from https://github.com/webcompat/web-bugs/issues/207284

Not a real site, not a WebCompat bug

Component: Site Reports → Performance: General
Product: Web Compatibility → Core

The severity field is not set for this bug.
:bas.schouten, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(bas)

This does not appear to be a performance issue. Moving to event handling which is likely to be where the difference is.

Component: Performance: General → DOM: Events
Flags: needinfo?(bas)

When the scroll occurs, I got this stack:

xul.dll!mozilla::ScrollContainerFrame::ScrollToImpl(nsPoint aPt, const nsRect & aRange, mozilla::ScrollOrigin aOrigin, mozilla::ScrollTriggeredByScript) Line 2971 (m:\src2\layout\generic\ScrollContainerFrame.cpp:2971)
xul.dll!mozilla::ScrollContainerFrame::CompleteAsyncScroll(const nsPoint & aStartPosition, const nsRect & aRange, std::unique_ptr<mozilla::ScrollSnapTargetIds,std::default_delete<mozilla::ScrollSnapTargetIds>> aSnapTargetIds, mozilla::ScrollOrigin aOrigin) Line 2336 (m:\src2\layout\generic\ScrollContainerFrame.cpp:2336)
xul.dll!mozilla::ScrollContainerFrame::ScrollToWithOrigin(nsPoint aScrollPosition, const nsRect * aRange, mozilla::ScrollContainerFrame::ScrollOperationParams && aParams) Line 2513 (m:\src2\layout\generic\ScrollContainerFrame.cpp:2513)
xul.dll!mozilla::ScrollContainerFrame::ScrollToCSSPixelsForApz(const mozilla::gfx::PointTyped<mozilla::CSSPixel,float> & aScrollPosition, mozilla::ScrollSnapTargetIds && aLastSnapTargetIds) Line 2441 (m:\src2\layout\generic\ScrollContainerFrame.cpp:2441)
[Inline Frame] xul.dll!mozilla::layers::ScrollFrameTo(mozilla::ScrollContainerFrame * aFrame, const mozilla::layers::RepaintRequest & aRequest, bool & aSuccessOut) Line 134 (m:\src2\gfx\layers\apz\util\APZCCallbackHelper.cpp:134)
xul.dll!mozilla::layers::ScrollFrame(nsIContent * aContent, const mozilla::layers::RepaintRequest & aRequest) Line 186 (m:\src2\gfx\layers\apz\util\APZCCallbackHelper.cpp:186)
xul.dll!mozilla::layers::APZCCallbackHelper::UpdateSubFrame(const mozilla::layers::RepaintRequest & aRequest) Line 419 (m:\src2\gfx\layers\apz\util\APZCCallbackHelper.cpp:419)
xul.dll!mozilla::dom::BrowserChild::UpdateFrame(const mozilla::layers::RepaintRequest & aRequest) Line 249 (m:\src2\dom\ipc\BrowserChild.cpp:249)
[Inline Frame] xul.dll!mozilla::layers::APZTaskRunnable::Run::RequestProcessor::operator()(const mozilla::layers::RepaintRequest & aRequest) Line 36 (m:\src2\gfx\layers\apz\util\APZTaskRunnable.cpp:36)
[Inline Frame] xul.dll!mozilla::detail::VariantImplementation<bool,0,mozilla::layers::RepaintRequest,mozilla::layers::APZTaskRunnable::APZStateChangeRequest>::match(mozilla::layers::APZTaskRunnable::Run::RequestProcessor && aMatcher, mozilla::Variant<mozilla::layers::RepaintRequest,mozilla::layers::APZTaskRunnable::APZStateChangeRequest> & aV) Line 262 (m:\fx64-dbg\dist\include\mozilla\Variant.h:262)
[Inline Frame] xul.dll!mozilla::Variant<mozilla::layers::RepaintRequest,mozilla::layers::APZTaskRunnable::APZStateChangeRequest>::match(mozilla::layers::APZTaskRunnable::Run::RequestProcessor && aMatcher) Line 855 (m:\fx64-dbg\dist\include\mozilla\Variant.h:855)
xul.dll!mozilla::layers::APZTaskRunnable::Run() Line 45 (m:\src2\gfx\layers\apz\util\APZTaskRunnable.cpp:45)
xul.dll!nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp aNowTime, nsRefreshDriver::IsExtraTick aIsExtraTick) Line 2379 (m:\src2\layout\base\nsRefreshDriver.cpp:2379)
[Inline Frame] xul.dll!mozilla::RefreshDriverTimer::TickDriver(nsRefreshDriver * driver, mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp now) Line 366 (m:\src2\layout\base\nsRefreshDriver.cpp:366)
xul.dll!mozilla::RefreshDriverTimer::TickRefreshDrivers(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp aNow, nsTArray<RefPtr<nsRefreshDriver>> & aDrivers) Line 344 (m:\src2\layout\base\nsRefreshDriver.cpp:344)
xul.dll!mozilla::RefreshDriverTimer::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp now) Line 362 (m:\src2\layout\base\nsRefreshDriver.cpp:362)
xul.dll!mozilla::VsyncRefreshDriverTimer::RunRefreshDrivers(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp aTimeStamp) Line 951 (m:\src2\layout\base\nsRefreshDriver.cpp:951)
xul.dll!mozilla::VsyncRefreshDriverTimer::TickRefreshDriver(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType> aId, mozilla::TimeStamp aVsyncTimestamp) Line 862 (m:\src2\layout\base\nsRefreshDriver.cpp:862)
xul.dll!mozilla::VsyncRefreshDriverTimer::NotifyVsyncOnMainThread(const mozilla::VsyncEvent & aVsyncEvent) Line 757 (m:\src2\layout\base\nsRefreshDriver.cpp:757)
xul.dll!mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::NotifyVsyncTimerOnMainThread() Line 592 (m:\src2\layout\base\nsRefreshDriver.cpp:592)

And EventStateManager::DoScrollText() does not handle anything when I see the scroll. So, it must be a bug of APZC.

Component: DOM: Events → Panning and Zooming

So the scroll is prevented by doing preventDefault() in a wheel event handler;

document.getElementById('container').addEventListener('wheel', ev => {
  ev.preventDefault();
})

Unfortunately sometimes it doesn't work because the main-thread doesn't respond whether the event was preventDefaulted or not within apz.content_response_timeout value, the default pref value is 400ms.

So I'd say it's kinda performance issue. I am not sure where to start other than performance. Bas?

Flags: needinfo?(bas)

Chrome has this jank as well, so this feels like it's more of a case of how it's handled.

I had Claude make this simple testcase, it illustrates the behavior difference well, in Chrome this never causes the container to Scroll, in Firefox main thread jank -does- cause the container to scroll.

Flags: needinfo?(bas) → needinfo?(hikezoe.birchill)

in Firefox main thread jank -does- cause the container to scroll.

This is a deliberate responsiveness vs. correctness tradeoff that we make: if the answer to "should we scroll" does not arrive within a 400ms time limit, we go ahead and scroll, so that slow script does not have the ability to delay scrolling by an arbitrarily long amount in cases where the answer would have been "yes". The correctness tradeoff is that we may end up scrolling even if the answer would have been "no", as in this test case.

It looks like Chrome is choosing to make a different tradeoff here?

We discussed this bug in a team meeting and decided to change our behavior to wait forever just like Chrome in cases of active event listeners.

This bug will be tracked in FFXP-3691 (APZ 2026 H1 Maintenance Quick Fixes).

Severity: -- → S3
Flags: needinfo?(hikezoe.birchill)
Priority: -- → P3

A note about how to implement this:

We have a mechanism to accomplish something similar already: the eRequiresTargetConfirmation flag that's set over regions containing an inactive scroll frame with an overscroll-behavior value of contain or none, to ensure that scrolls over that region don't scroll the enclosing frame even if the content process is slow to activate the scroll frame / confirm that an input block over the region should target the newly activated scroll frame.

Two differences between that mechanism and what we want here are:

  1. The eRequiresTargetConfirmation flag is about ensuring we wait for the SetConfirmedTargetAPZC message regardless of the timeout, whereas here we want to wait for the ContentReceivedInputBlock message which carries the "content response" (whether preventDefault() was called on the event or not).
  2. For eRequiresTargetConfirmation, the current behaviour is to drop the event from APZ's input queue if the message does not arrive before the timeout. It's not clear to me whether we want to do the same here, or keep the event in the queue? (Presumably we need some mechanism to remove the event from the queue to avoid the queue stalling.)
See Also: → 1866028
See Also: → 2091199
Blocks: 2095165
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: