Closed Bug 1159420 Opened 9 years ago Closed 8 years ago

[E10s][APZ] Scrolling twitter flashes the bottom part of the top image

Categories

(Core :: Graphics: Layers, defect)

36 Branch
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
Tracking Status
e10s - ---

People

(Reporter: smaug, Unassigned)

References

(Depends on 1 open bug, )

Details

(Whiteboard: gfx-noted)

Will try to repro on Windows.
Flags: needinfo?(dvander)
Whiteboard: gfx-noted
The page is updating the transform property on the <img> element in response to scroll events in order to implement a parallax-scrolling effect. Of course with APZ the scroll events are async from the actual scrolling so there's some lag causing the flashing effect. Not sure if there's much we can do about this without providing alternative parallax implementation mechanisms. There's some stuff in progress on that front although I'm not current on what the latest news is there.
Scroll events are dispatched using a WillPaintObserver, so they are usually async anyhow,
and those are called
http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp?rev=530555a2d6d4&mark=8805-8805#8785
Should we dispatch scroll events at different time? Or detect that we have pending scroll events and
dispatch them sync before APZ does its magic?


Given that this is showing up with Twitter (among others), I think we must fix this on our side.

Do I recall correctly that Mats has been dealing with scroll event dispatching in non-apz case?
Any ideas for this bug?
Flags: needinfo?(mats)
What I mean is that with APZ you can scroll even if the main thread is blocked, so the scroll event that gets to content may be very delayed relative to what the user sees on screen. This just an inherent tradeoff in allowing async panning at all. Any website that attempts to reimplement fixed-position or sticky-position type behaviour using scroll events will exhibit this problem.
And I'm saying that we can't have that problem exposed on desktop at least.
Somehow we need to inform the parent process that it needs to wait for the child to dispatch scroll 
and paint before parent can continue scrolling. Anything else would break too much web content.
Sure, it does kind of disable apz for the particular web page, but it is its problem.

How do other browsers deal with this issue?
Scrolling the URL works perfectly in Linux Nightly - no lag or flicker whatsoever.
Do I need to enable some pref to reproduce the problem?
Flags: needinfo?(bugs)
(In reply to Olli Pettay [:smaug] from comment #3)
> Should we dispatch scroll events at different time? Or detect that we have
> pending scroll events and dispatch them sync before APZ does its magic?

I think roc can probably give you a better answer.
Flags: needinfo?(mats) → needinfo?(roc)
e10s + layers.async-pan-zoom.enabled = true
Flags: needinfo?(bugs)
This is a tough problem, and I've talked to Chrome devs about it a fair bit over the last few months. There's a fundamental tension between honoring what the Web developer is trying to do and providing a good user experience when what they're trying to do isn't working well.

I think first we should be conservative and if a page or element has a scroll event listener, we should disable async scrolling for that page or element. Then enabling APZ won't make things worse and will make many pages better.

Then I think we should introduce a per-page mode switch with two settings: "Page is keeping up", "page is not keeping up". If the frame rate drops below a reasonable target (e.g. 30fps over a second) we set the switch to "page is not keeping up". In that mode, we enable async scrolling no matter what (and potentially could do other things to improve the user experience by ignoring page settings). We should also fire an event to say that we've done that; obviously that event would need to be standardized. This would give developers the chance to back off and/or send telemetry. Chrome people I've talked to like this approach.

There's been discussion of an intermediate approach, a CSS property "scroll-blocks-on" which lets the author control whether they get sync or async scrolling. I hope if we do the above we won't need a property like that.
Flags: needinfo?(roc)
I wonder if it's really e10s related, because I see bug 1103394 both with/without e10s enabled. But maybe I'm just confused and it's a different bug?
The fact that APZ doesn't wait on scroll handlers can lead to lag and sometimes jitter, but it shouldn't lead to the header image randomly flashing in the wrong position, which I think is what smaug filed this bug about.

I have a theory of how that "flash" happens in bug 1103394 comment 8. It's because Twitter relies on a certain ordering of scroll events and requestAnimationFrame callbacks, which is true in Chrome but not in Firefox and Safari.
smaug, are you still seeing this issue in a recent nightly? We have made some changes that should help with this.
Flags: needinfo?(dvander) → needinfo?(bugs)
I don't think I've seen this particular issue very recently.

I'll open a new bug if I see similar issues.
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(bugs)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.