New issue
Advanced search Search tips

Issue 833725 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

IntersectionObserver stops invoking callback in a background tab

Reported by simon....@gmail.com, Apr 17 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:59.0) Gecko/20100101 Firefox/59.0

Steps to reproduce the problem:
https://codepen.io/simonpai/pen/BxBBbR
1. Open the link above. Open the console to see intersectionRatio reported every 2 secs.
2. Switch to another tab. IntersectionObserver stops to invoke the callback.

What is the expected behavior?
AFAICS the w3c does not explicitly specify the behavior in a background tab, so I am certain if this should be considered as a defect. But since it is unspecified, I would expect it behaves the same as in active tabs.

In FireFox, IntersectionObserver works as expected, and they explicitly state the behavior in their documentation:
https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

What went wrong?
IntersectionObserver stops invoking callback in a background tab

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 65.0.3325.146  Channel: stable
OS Version: OS X 10.12
Flash Version: Shockwave Flash 29.0 r0

I think it's up to Chrome team to define IntersectionObserver's behavior in background tabs.

However, it's a fact that in the current state Chrome offers a weaker API than FireFox, as it gives us less information, especially inside an iframe. In addition, I may have to ditch the use of IntersectionObserver with Chrome, falling back to the traditional way (setInterval + getBoundingClientRect), which ironically counteracts the performance purpose of throttling cycles in background tabs.
 
chrome-intersection-observer-background-tabs.html
479 bytes View Download

Comment 1 by simon....@gmail.com, Apr 17 2018

I offered the wrong link of FireFox doc. It should be:
https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API/Timing_element_visibility

See the part:
"... The Intersection Observer API doesn't take this (page visibility) into account when detecting intersection, since intersection isn't affected by page visibility."
Components: Blink>Layout
Labels: Needs-Triage-M65
Labels: Needs-Feedback Triaged-ET
Unable to reproduce the issue on chrome reported version 833725 using Mac 10.12.6 with steps mentioned below:
1) Launch chrome reported version and navigated to URL: https://codepen.io/simonpai/pen/BxBBbR
2) Opened Devtools>Console, able to see intersectionratio invoking
3) Switched to new tab and again checked the Intersectionratio invoking 

@Reporter: Please find the attached screencast for your reference and let us know if we missed anything in reproducing the issue, provide your feedback on it which help in further triaging it in better way.

Thanks!
833725.mp4
1.7 MB View Download

Comment 5 by simon....@gmail.com, Apr 18 2018

Hi,

Thank you for your quick response and sorry for causing misunderstanding.

What I stated was that the IntersectionObserver does not work WHEN the tab is in background. As you switch back to the tab, of course it comes back alive and starts to invoke the callback. 

Please detach your console from the original browser window and observe it during the time period when you switch off to another tab.

Thanks!
Project Member

Comment 6 by sheriffbot@chromium.org, Apr 18 2018

Cc: viswa.karala@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 7 by e...@chromium.org, Apr 23 2018

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

Comment 8 by szager@chromium.org, Apr 23 2018

Status: WontFix (was: Assigned)
This is working as intended.  IntersectionObserver is integrated into the frame rendering pipeline, which doesn't run for tabs in the background.

I'm curious, though, about the assertion than "Chrome offers a weaker API than FireFox."  I would be surprised to learn that Firefox does something different here; is that the case?

Comment 9 by simon....@gmail.com, Apr 24 2018

Yes, I have supplied the reference link. Please read Comment 1 of this thread. 

Thanks for your effort!

Sign in to add a comment