Closed
Bug 1419339
Opened 7 years ago
Closed 7 years ago
IntersectionObserver doesn’t fire on 'transform' animations unless rAF
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
VERIFIED
FIXED
mozilla60
People
(Reporter: surma, Assigned: hiro)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36
Steps to reproduce:
1. Open https://io-raf-bug.glitch.me/ and don’t move the mouse or trigger any other form of event. The text in the blue box does not update (or at least not consistently).
2. Move the mouse frantically to see the blue box update
Code: https://glitch.com/edit/#!/io-raf-bug?path=index.html:67:0
Expected results:
Box should update without mouse movements
Updated•7 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
Comment 1•7 years ago
|
||
NI someone involved with IntersectionObserver to look at after the holiday.
Flags: needinfo?(dholbert)
Comment 2•7 years ago
|
||
Comment 3•7 years ago
|
||
CC'ing mstange who's also reviewed some intersectionobserver code.
It looks to me like this is a case where the animation is being performed in the compositor -- and back on the main thread, we're not correctly detecting that the intersection is changing due to these operations happening over in the compositor & that we need to fire events accordingly. (Strengthening that theory: if I adjust the testcase to use relative positioning instead of transforms, and I animate the "left" property instead of transform, then the bug goes away. This makes sense, because we don't handle 'left' animations in the compositor.)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: IntersectionObserver doesn’t fire on animations unless rAF → IntersectionObserver doesn’t fire on 'transform' animations unless rAF
Comment 4•7 years ago
|
||
Flags: needinfo?(dholbert)
Updated•7 years ago
|
Flags: needinfo?(dholbert)
Comment 5•7 years ago
|
||
That seems like the right explanation. CC'ing hiro and birtles - I know we have a workaround for updating scrollbars with some rate-limit under similar circumstances. So we may need to do something like that in the presence of intersection observers. (I don't really know how those rate-limited reflows are triggered, though.)
See also bug 1305976 which has a similar problem.
| Assignee | ||
Comment 6•7 years ago
|
||
Yeah, Markus is right. We unthrottle (synchronize to the compositor) transform animations every 200ms if the parent element has scrollbars. Actually I see the unthrottle behavior with attachment 8931026 [details] on my environment somehow. :)
| Assignee | ||
Comment 7•7 years ago
|
||
Like this. Actually this is not perfect, if we want to update IntersectionObserver more precisely we have to not run the transform animations on the compositor.
Assignee: nobody → hikezoe
Comment 8•7 years ago
|
||
(Thanks, hiro! Clearing my needinfo, since it seems like you've got this.)
Flags: needinfo?(dholbert)
Updated•7 years ago
|
Attachment #8931151 -
Attachment is patch: true
Comment 9•7 years ago
|
||
I wonder what the desired frequency is of updates to IntersectionObserver. Perhaps it would be enough to unthrottle every 200ms or so like we do for scrolling? It would be unfortunate if authors have to choose between good perf (i.e. not restyling every frame) or using IntersectionObserver.
(Also I think attachment 8931151 [details] [diff] [review] adds the check too late in the function? We return true earlier in the function if the platform doesn't show scrollbars meaning we'll still end up throttling on Android with this patch.)
| Assignee | ||
Comment 10•7 years ago
|
||
(In reply to Brian Birtles (:birtles) from comment #9)
> (Also I think attachment 8931151 [details] [diff] [review] adds the check
> too late in the function? We return true earlier in the function if the
> platform doesn't show scrollbars meaning we'll still end up throttling on
> Android with this patch.)
Yep, right. I couldn't test it because I can't reproduce this bug locally. Also for this bug, I think we need a test case similar to the test case which has been failed intermittently (bug 1413370), and I think the intermittent bug will be fixed by bug 1413817 (at least it should get more robust by that bug). So I'd like to fix this bug after bug 1413817.
Updated•7 years ago
|
Priority: -- → P2
| Assignee | ||
Comment 11•7 years ago
|
||
I and Brian had discussed about this and decided to land the fix without any test cases here. And we will add test cases in later bug after bug 1193394 fixed.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2123846021d2aae2b7c02d55d7ca3f4a09049a78
| Assignee | ||
Comment 12•7 years ago
|
||
I thought I did push a request review here.
| Comment hidden (mozreview-request) |
Comment 14•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8948815 [details]
Bug 1419339 - Unthrottle transform animations periodically if there is any IntersectionObservers.
https://reviewboard.mozilla.org/r/218190/#review224038
::: dom/animation/KeyframeEffectReadOnly.cpp:1543
(Diff revision 1)
> + GetRenderedDocument()->HasIntersectionObservers();
> +
> // If we know that the animation cannot cause overflow,
> // we can just disable flushes for this animation.
>
> - // If we don't show scrollbars, we don't care about overflow.
> + // If we don't show scrollbars and have no intersection observer, we don't
Super minor nit: s/observer/observers/
::: dom/animation/KeyframeEffectReadOnly.cpp:1554
(Diff revision 1)
> + // If we have any intersection observers, we do unthrottle this transform
> + // animation periodically.
Another minor nit: s/we do/we/
Attachment #8948815 -
Flags: review?(bbirtles) → review+
Comment 15•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8948815 [details]
Bug 1419339 - Unthrottle transform animations periodically if there is any IntersectionObservers.
https://reviewboard.mozilla.org/r/218190/#review224040
::: dom/animation/KeyframeEffectReadOnly.cpp:1537
(Diff revision 1)
> + bool hasIntersectionObservers =
> + GetRenderedDocument()->HasIntersectionObservers();
On further thought, is there any possibility GetRenderedDocument could return null? If not, should we add a comment or assertion about this?
| Assignee | ||
Comment 16•7 years ago
|
||
(In reply to Brian Birtles (:birtles) from comment #15)
> Comment on attachment 8948815 [details]
> Bug 1419339 - Unthrottle transform animations periodically if there is any
> IntersectionObservers.
>
> https://reviewboard.mozilla.org/r/218190/#review224040
>
> ::: dom/animation/KeyframeEffectReadOnly.cpp:1537
> (Diff revision 1)
> > + bool hasIntersectionObservers =
> > + GetRenderedDocument()->HasIntersectionObservers();
>
> On further thought, is there any possibility GetRenderedDocument could
> return null? If not, should we add a comment or assertion about this?
Oh right, indeed. I believe with current setup, this function is called with the target element which is associated with a document. But I will add a check that bails out in the case, just in case.
| Assignee | ||
Comment 17•7 years ago
|
||
A finial try but it got involved with a bug (bug 1392391) that was already backed out in m-c because of jsreftest failures on Android.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7fc48584a353b67582039fabe99b9b2b7ecb5b95
So, here is another try on Android
https://treeherder.mozilla.org/#/jobs?repo=try&revision=39834845653346d9a9aa5587f7173a5e80fc21b7
| Comment hidden (mozreview-request) |
Comment 19•7 years ago
|
||
Pushed by hikezoe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c149e5048e65
Unthrottle transform animations periodically if there is any IntersectionObservers. r=birtles
Comment 20•7 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Updated•7 years ago
|
QA Whiteboard: [good first verify]
Comment 21•7 years ago
|
||
I managed to reproduce the bug using an older version of Nightly (2018-02-21) on Windows 10 x64.
I retested everything on latest Nightly 61.0a1 (20180107100322) and beta 60.0b4 using Windows 10 x64, macOS 10.13 and Ubuntu 16.04 and the bug is not reproducing anymore.
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•