New issue
Advanced search Search tips

Issue 737228 link

Starred by 7 users

Issue metadata

Status: Assigned
Owner:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

IntersectionObserver boundingClientRect has inaccurate width/height

Reported by nolan.la...@gmail.com, Jun 27 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063

Steps to reproduce the problem:
1. Go to http://bl.ocks.org/nolanlawson/raw/a44f0022f28b798c439bbfce62e3a917/
2. Notice that the reported width/height from the IntersectionObserverEntry's boundingClientRect differs from getBoundingClientRect()

What is the expected behavior?
The width and height should be the same. Per the spec (https://wicg.github.io/IntersectionObserver/), it says "boundingClientRect: A DOMRectReadOnly obtained by running the getBoundingClientRect() algorithm on the target."

What went wrong?
The values appear to be rounded – they are reported as integers rather than at subpixel precision. Also even the rounded values appear to be off by quite a bit (see attached screenshot).

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 59.0.3071.115  Channel: stable
OS Version: 10.0
Flash Version:
 
intersection-observer-gBCR.png
402 KB View Download
Slight bug in the original index.html (repeated ids). Here's an updated repro.
index.html
2.5 KB View Download
Labels: Needs-Triage-M59
Update: it appears entry.rootBounds has a similar bug. Here's a demo: http://bl.ocks.org/nolanlawson/raw/a4c5d7cd764297c6a2e7a71e1ebc8b89/.

Note in the screenshot that Firefox and Edge report the same height for entry.rootBounds.height as observer.root.getBoundingClientRect().height, but Chrome does not.
intersection-observer-rootBounds.png
174 KB View Download
Labels: M-61 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
Tested this issue using #59.0.3071.115 on Mac 10.12.5, Win 10 and Linux Ubuntu 14.04 and was able to reproduce the issue.

Observing the same behavior since M51, hence considering this issue as Non-Regression issue. Untriaged the issue so that it get's addressed.

Note:
1. Same behavior is observed in M61 as well
2. Not able to reproduce the issue in M51 and < M51 as above attached html is not showing any data on the page.

Thans!!

Comment 5 by e...@chromium.org, Jun 30 2017

Owner: szager@chromium.org
Status: Assigned (was: Untriaged)

Comment 6 by szager@chromium.org, Jun 30 2017

I can only reproduce this when the browser window is zoomed.  Does that agree with your observations?
I can reproduce in Windows 10 by setting the system zoom to something other than 100%. (Settings -> Display -> "Change the size of text, apps, and other items".) I can also reproduce by changing the browser's zoom (either zoomed in or zoomed out). You're correct though that I can't reproduce the inaccuracy in the first demo (http://bl.ocks.org/nolanlawson/raw/a44f0022f28b798c439bbfce62e3a917/) when both the browser and the OS are zoomed to 100%.

However, in the second demo (http://bl.ocks.org/nolanlawson/raw/a4c5d7cd764297c6a2e7a71e1ebc8b89/), I can reproduce the fact that entry.rootBounds.height !== observer.root.getBoundingClientRect().height because the former is a rounded integer whereas the latter is a decimal. You can reproduce this with a 100% zoom on both the OS and the browser.

I've also written a third demo (http://bl.ocks.org/nolanlawson/raw/004844253920db80da807af9d23cc2e9/) which can reproduce the fact that entry.boundingClientRect.height !== entry.target.getBoundingClientRect().height because of this rounding issue. Like the second demo, this can be reproduced with both browser and OS zoom set to 100%.
FWIW I can also repro the lack of precision (integer rounding) on Chrome 63.0.3219.0 on Android. This is causing a scrolling perf issue for Mastodon because we have to detect the Chrome bug (https://github.com/tootsuite/mastodon/blob/63b77f23202a6dece419e2eb7180395b2e276b09/app/javascript/mastodon/features/ui/util/get_rect_from_entry.js) and then fall back to getBoundingClientRect which forces layout: https://toot.cafe/@nolan/1700613

Sign in to add a comment