Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Issue 11854013: Use input events to improve vsync scheduling (Closed)

Created:
7 years, 11 months ago by Sami
Modified:
7 years, 6 months ago
Reviewers:
jamesr, brianderson
CC:
chromium-reviews, cc-bugs_chromium.org, darin-cc_chromium.org
Visibility:
Public.

Description

On some platforms like Android input events are buffered and delivered right before the vsync notification signifying the start of a new frame. We can use this information to improve vsync render scheduling in two ways: 1) Normally subscribing to a vsync notification incurs one frame of lag, because the first event is only delivered for the next frame instead of the current one. Instead, we can use an input event to synthesize a virtual vsync event and start rendering the new frame immediately. 2) Input events and vsync notifications are sent as separate IPC messages. Since input events arrive first, we can increase the time available for rendering by using them instead of waiting for the vsync notification. The difference is about 1 ms on a Nexus 4. This patch also avoids setting the "last input event before vsync" bit on pages that have JavaScript touch handlers. This is because on such pages touch events may be sent after the vsync notification depending on what the JavaScript touch handler does with the events. BUG=168459 TEST=VSyncTimeSourceTest.SynthesizeVSyncFromInput

Patch Set 1 #

Patch Set 2 : Use current time to estimate frame time for synthetic vsync. Add test. #

Patch Set 3 : Remove vsync bit from TouchMove. Improve test. #

Patch Set 4 : Don't set last-input-for-vsync bit on pages with touch handlers. #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+133 lines, -6 lines) Patch
M cc/input_handler.h View 1 chunk +2 lines, -0 lines 0 comments Download
M cc/layer_tree_host_impl.h View 2 chunks +2 lines, -0 lines 0 comments Download
M cc/layer_tree_host_impl.cc View 1 1 chunk +5 lines, -0 lines 0 comments Download
M cc/layer_tree_host_impl_unittest.cc View 1 1 chunk +1 line, -0 lines 0 comments Download
M cc/single_thread_proxy.h View 1 chunk +1 line, -0 lines 0 comments Download
M cc/test/fake_layer_tree_host_impl_client.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M cc/thread_proxy.h View 1 chunk +1 line, -0 lines 0 comments Download
M cc/thread_proxy.cc View 1 chunk +8 lines, -0 lines 0 comments Download
M cc/vsync_time_source.h View 1 3 chunks +6 lines, -0 lines 0 comments Download
M cc/vsync_time_source.cc View 1 3 chunks +33 lines, -1 line 3 comments Download
M cc/vsync_time_source_unittest.cc View 1 2 2 chunks +61 lines, -2 lines 0 comments Download
M content/browser/android/content_view_core_impl.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/android/content_view_core_impl.cc View 1 2 3 3 chunks +4 lines, -3 lines 2 comments Download
M webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc View 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Sami
This patch gets rid of the one frame lag when requesting a vsync notification from ...
7 years, 11 months ago (2013-01-14 17:19:34 UTC) #1
brianderson
Should VSyncTimeSourceTest.SynthesizeVSyncFromInput verify that input after a vsync also triggers a tick? Otherwise, lgtm.
7 years, 11 months ago (2013-01-15 02:29:38 UTC) #2
Sami
> Should VSyncTimeSourceTest.SynthesizeVSyncFromInput verify that input after a > vsync also triggers a tick? Great ...
7 years, 11 months ago (2013-01-15 11:19:02 UTC) #3
jamesr
https://codereview.chromium.org/11854013/diff/13001/cc/vsync_time_source.cc File cc/vsync_time_source.cc (right): https://codereview.chromium.org/11854013/diff/13001/cc/vsync_time_source.cc#newcode58 cc/vsync_time_source.cc:58: // We can use input events to synthesize vsync ...
7 years, 11 months ago (2013-01-16 04:13:26 UTC) #4
Sami
7 years, 11 months ago (2013-01-16 10:49:15 UTC) #5
https://codereview.chromium.org/11854013/diff/13001/cc/vsync_time_source.cc
File cc/vsync_time_source.cc (right):

https://codereview.chromium.org/11854013/diff/13001/cc/vsync_time_source.cc#n...
cc/vsync_time_source.cc:58: // We can use input events to synthesize vsync
events, but we must be careful
On 2013/01/16 04:13:26, jamesr wrote:
> this logic seems really fishy to me.  I think you need to decide if the smarts
> for vsync are going to be in the renderer or not and stick to that - we
> shouldn't have one process second-guessing the other

I suppose you're right. Doing this in the browser seems better because it has
global visibility across all renderers and all the funky input event queuing
happens there anyway. I'll give this another go to move the logic there.

https://codereview.chromium.org/11854013/diff/13001/content/browser/android/c...
File content/browser/android/content_view_core_impl.cc (left):

https://codereview.chromium.org/11854013/diff/13001/content/browser/android/c...
content/browser/android/content_view_core_impl.cc:873: event->type ==
WebInputEvent::TouchMove)
On 2013/01/16 04:13:26, jamesr wrote:
> whaaaa? why was this here?
> 
> actually, this whole function seems kind of like bullshit.  we don't have any
> way to tell that we're in this mode from the android framework?

From Android's point of view input events are always delivered right before
vsync if we're on JB+, but the problem is that we have at least two different
event queues between the framework and the renderer which affect which events
get sent and when.

Here I'm limiting the vsync bit to those events that are guaranteed to be sent
at the right time -- it doesn't make sense to do it for, e.g., the touch handler
case because the real vsync signal will have reached the renderer by the time we
get an ack from JS.

Maybe it would help if I move this logic to where the events are generated in
Java?

Powered by Google App Engine
This is Rietveld 408576698