Open Bug 1905441 Opened 5 months ago Updated 2 months ago

IntersectionObserver callback does not fire for zero-height element at the bottom of the document at some DPI scales (which breaks infinite-scroll on some sites)

Categories

(Core :: Layout, defect)

defect

Tracking

()

REOPENED

People

(Reporter: dholbert, Assigned: hiro)

References

(Depends on 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Attached file testcase 1

STR:

  1. Make sure Firefox for Android has the dynamic toolbar enabled (this is the default config "Scroll to hide toolbar" enabled)
  2. Load attached testcase.
  3. Scroll to the very bottom of the page.

EXPECTED RESULTS:
The background should turn lime when you reach the bottom.

ACTUAL RESULTS:
The background never turns lime. It just stays pink.

I'm pretty sure this is the root cause of bug 1884144 at Taobao.

Firefox 127 release and 129 Nightly on Android give ACTUAL RESULTS -- though if I turn off the dynamic toolbar, they give EXPECTED RESULTS.

Chrome gives EXPECTED RESULTS, as does Firefox on Desktop.

The setup in the testcase here is:

  • zero-height element at the very end of the document.
  • an IntersectionObserver watching for that element to come into view and reach an intersectionRatio of 1.

Obviously it's a bit edge-casey to consider whether a zero-height element at the end of the document is intersecting or not-intersecting when you're scrolled to the very end. (It's zero-height and it coincides precisely with the edge of the viewport, so it's not exactly on-screen.)

But apparently there's consensus that it is intersecting with an intersectionRatio of 1, based on the browsers/configs that yield EXPECTED RESULTS in comment 0. Only Firefox-with-dynamic-toolbar considers it non-intersecting.

No longer blocks: 1884144

I guess this is bug 1788504, actually.

Status: NEW → RESOLVED
Closed: 5 months ago
Duplicate of bug: 1788504
Resolution: --- → DUPLICATE

Hmm, dupe-target bug 1788504 landed last week, but I'm still able to reproduce this bug here with the attached testcase, in Nightly 2024-07-22 (built from a m-c commit that landed yesterday, much more recently than bug 1788504's patches).

So bug 1788504 didn't fix this, i.e. this bug is not a dupe of bug 1788504 after all.

--> moving dupe relationship to see-also relationship. emilio or hiro, maybe you could take a look here?

Status: RESOLVED → REOPENED
No longer duplicate of bug: 1788504
Flags: needinfo?(emilio)
Resolution: DUPLICATE → ---
See Also: → 1788504
Blocks: 1884144

FWIW, on my local built GeckoView example based on this revision, the test case sometimes works, sometimes doesn't work. Odd.

Flags: needinfo?(hikezoe.birchill)

Since bug 1788504 the root scroll container's clipped region had been
over-clipped because GetScrollPortRectAccountingForMaxDynamicToolbar returns
the toolbar height divided by the current pinch zoom ratio. For example, given
that the toolbar height is 60px (in screen units) and the pinch zoom ratio is
2.0, then GetScrollPortRectAccountingForMaxDynamicToolbar returns 30px (in CSS
units), it's not sufficient for the clipped region.

The JUnit test in this change fails without this change, succeeds with this
change.

Assignee: nobody → hikezoe.birchill

Comment on attachment 9416512 [details]
Bug 1905441 - Revert bug 1788504 partially. r?emilio

Revision D217924 was moved to bug 1909181. Setting attachment 9416512 [details] to obsolete.

Attachment #9416512 - Attachment is obsolete: true

The bug number was wrong. :/

Note that I can see this issue with static toolbar, FWIW.

This repros as well on desktop at some zoom levels, afaict. E.g., on 130% zoom I see:

window.innerHeight // 553
let div = document.createElement("div"); div.style = "position: fixed; inset: 0;"; document.documentElement.appendChild(div); // undefined
div.getBoundingClientRect().height // 553.9166870117188
myTarget.getBoundingClientRect().y // 554.0999755859375 

So it seems that at some zoom levels we don't grow the scroll range to cover that?

This is likely to be due to this snapping here... Hiro, you have more context than me on that code, any idea of what is that trying to achieve?

Flags: needinfo?(emilio)
Summary: In Fenix with Dynamic Toolbar, IntersectionObserver callback does not fire for zero-height element at the bottom of the document (which breaks infinite-scroll on some sites) → IntersectionObserver callback does not fire for zero-height element at the bottom of the document at some DPI scales (which breaks infinite-scroll on some sites)

I suspected it so that I tried to see with layout.scroll.disable-pixel-alignment=true, but the issue still happened, that's what I did yesterday.

Now I tried it again before leaving the above comment, with layout.scroll.disable-pixel-alignment=true the test case in comment 0 works fine on my Pixel 3 and on Android emulator. Maybe I didn't reload the test case after changing the pref.

Depends on: 1852884
Flags: needinfo?(hikezoe.birchill)

I can confirm that the testcase works fine (changes to lime when I reach the end) if I set layout.scroll.disable-pixel-alignment=true in Firefox Nightly on my Pixel 8.

See Also: → 1847924
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: