Closed Bug 1225950 Opened 9 years ago Closed 9 years ago

Observing vsync blocks on the main thread, resulting in user-visible delays

Categories

(Core :: Graphics, defect)

Other Branch
Unspecified
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox42 --- affected
firefox43 --- affected
firefox44 --- affected
firefox45 --- fixed

People

(Reporter: kats, Assigned: kats)

Details

Attachments

(3 files, 2 obsolete files)

On Fennec, load http://people.mozilla.org/~kgupta/stall.html and wait a second or two. Then scroll down quickly. Note that as the toolbar slides off, the bottom content area is filled with white rather than more content. There's a big jank when it starts scrolling for real.

The page ties up the main thread for 1 second at a time using a spinloop. If you start scrolling during this time, the Java UI thread works fine and slides the toolbar off, and requests a composite from the compositor. If this composite actually happened, the clip rect would be extended and so you wouldn't see the misplaced green square or white space at the bottom of the page. However, the composite doesn't actually happen because we don't get vsync notifications. That in turn happens because the ObserveVsync() call gets stuck waiting on the main thread before it can actually register the vsync listener. The main thread, of course is busy with the spinloop.

This is a reduced test case but think it's the same root cause for behaviour I've observed on real-world sites as well such as nytimes.com - sometimes during page load the main thread is busy for a while and trying to pan during that time will result in jankiness.
Also note that in the STR above, by "scroll down quickly" I mean "put your finger down and aggressively drag the page once" rather than "fling". Your finger needs to be touching the screen for the dynamic toolbar sliding code to activate.
Attached patch Ugly hack (obsolete) — Splinter Review
The attached ugly hack fixes the problem for me locally - basically if we get a second composite request without having a composite happen in between it will do that composite ASAP rather than waiting for a vsync. It means we get unaligned composites, but at least it's not blocked on the main thread for who-knows-how-long. There's probably a better way to do this, maybe using a counter or a timestamp instead.
Assignee: nobody → bugmail.mozilla
Attached patch Maybe less ugly hack (obsolete) — Splinter Review
mchang, any thoughts?
Attachment #8689147 - Attachment is obsolete: true
Attachment #8689157 - Flags: review?(mchang)
Attachment #8689157 - Attachment is obsolete: true
Attachment #8689157 - Flags: review?(mchang)
Attachment #8689207 - Flags: review?(mchang)
Comment on attachment 8689205 [details] [diff] [review]
Part 1 - Remove useless argument, it's always true

Review of attachment 8689205 [details] [diff] [review]:
-----------------------------------------------------------------

Thx for the cleanup!
Attachment #8689205 - Flags: review?(mchang) → review+
Attachment #8689206 - Flags: review?(mchang) → review+
Attachment #8689207 - Flags: review?(mchang) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: