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

Issue 11362054: Use message passing for BeginFrameAndCommitState and clean up forced commit logic (Closed)

Created:
8 years, 1 month ago by jamesr
Modified:
8 years, 1 month ago
Reviewers:
nduca, enne (OOO)
CC:
chromium-reviews, cc-bugs_chromium.org, brianderson
Visibility:
Public.

Description

Use message passing for BeginFrameAndCommitState and clean up forced commit logic This passes the BeginFrameAndCommitState struct along with messages instead of relying on (racy) shared memory and slightly simplifies the forced commit logic. This logic is for compositeAndReadback() and is trying to go through the normal commit flow while the main thread is blocked. The normal commit flow is this: 1.) Main thread posts task to compositor thread requesting commit 2.) Compositor thread receives notification, after some delay posts task to main to run the beginFrame logic 3.) Main thread runs the beginFrameTask, posts a blocking task to compositor thread 4.) With the main thread is blocked, compositor thread runs the beginFrameComplete task and signals the main thread to get on with life 5.) Compositor thread waits for an opportunity to draw (vsync) then goes back to the initial state. compositeAndReadback() requires that we run through the whole flow up through 5 without yielding the main thread at all. However, while it's doing this there may very well be another beginFrame task pending on the main thread's message queue. When this task does eventually run it needs to have a valid BFAC state and the reply has to be expected on the compositor side. This patch always passes the BFAC state on the beginFrame task and uses a null BFAC state for compositeAndReadback-forced beginFrame()s. This means when we do a compositeAndReadback we won't "see" state that has updated only on the compositor thread, but that's fine since we'll apply that state once we process the beginFrame task later on and BFAC state addition is additive. The tricky bit from the compositor side is keeping track of whether there's a pending beginFrame message after going through the forced commit flow. To keep track of this I've added SchedulerStateMachine::m_expectImmediateBeginFrame that keeps the scheduler in a state that expects a beginFrameComplete after finishing the readback. Typical flow: 1.) Main thread enters compositeAndReadback(), posts a blocking forceBeginFrame task to compositor thread 2.) Compositor thread posts beginFrame task to main thread 3.) Compositor thread processes forceBeginFrame task, sets scheduler bits, signals main thread to continue 4.) Main thread runs beginFrame(NULL), posts beginFrameComplete to compositor thread 5.) Compositor thread processes beginFrameComplete, runs through state machine up to draw and then goes back to waiting for a reply to the beginFrame it posted in step (2) 6.) Main thread issues sync readback, finishes compositeAndReadback() 7.) Main thread processes beginFrame message posted in (2), posts reply 8.) Profit! Note that steps (2) and (3) can happen in any order. BUG=158747 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=167537

Patch Set 1 #

Total comments: 3

Patch Set 2 : don't animate forced beginFrames, add tests, DCHECK for memory #

Patch Set 3 : Rebase and add state machine comment #

Patch Set 4 : fix windows signed/unsigned warning #

Unified diffs Side-by-side diffs Delta from patch set Stats (+216 lines, -87 lines) Patch
M cc/layer_tree_host.cc View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M cc/layer_tree_host_unittest.cc View 1 2 4 chunks +48 lines, -6 lines 0 comments Download
M cc/scheduler.cc View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M cc/scheduler_state_machine.h View 1 2 2 chunks +3 lines, -0 lines 0 comments Download
M cc/scheduler_state_machine.cc View 1 2 4 chunks +18 lines, -5 lines 0 comments Download
M cc/scheduler_state_machine_unittest.cc View 1 2 23 chunks +117 lines, -33 lines 0 comments Download
M cc/thread_proxy.h View 1 2 4 chunks +2 lines, -5 lines 0 comments Download
M cc/thread_proxy.cc View 1 2 3 13 chunks +25 lines, -36 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
jamesr
8 years, 1 month ago (2012-11-02 01:15:31 UTC) #1
enne (OOO)
Does layer_tree_host_unittest.cc need to be extended with more compositeAndReadback cases. It looks like the coverage ...
8 years, 1 month ago (2012-11-02 18:02:57 UTC) #2
nduca
Can you walk through the sequence that causes the failure in the exisitng thing? If ...
8 years, 1 month ago (2012-11-05 07:08:02 UTC) #3
jamesr
On 2012/11/05 07:08:02, nduca wrote: > Can you walk through the sequence that causes the ...
8 years, 1 month ago (2012-11-05 17:04:53 UTC) #4
jamesr
nat - ping
8 years, 1 month ago (2012-11-10 02:22:20 UTC) #5
nduca
> When this task does eventually run it needs to have a valid BFAC state ...
8 years, 1 month ago (2012-11-10 02:37:51 UTC) #6
jamesr
On 2012/11/10 02:37:51, nduca wrote: > > When this task does eventually run it needs ...
8 years, 1 month ago (2012-11-12 03:03:44 UTC) #7
nduca
Why can't we fix it with a judiciously placed mutex?
8 years, 1 month ago (2012-11-12 19:39:25 UTC) #8
jamesr
On 2012/11/12 19:39:25, nduca wrote: > Why can't we fix it with a judiciously placed ...
8 years, 1 month ago (2012-11-12 20:34:53 UTC) #9
nduca
LGTM. Might put a comment in scheduler state machine explaining on the new state setter ...
8 years, 1 month ago (2012-11-12 22:24:51 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/11362054/12001
8 years, 1 month ago (2012-11-13 21:40:29 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/11362054/3003
8 years, 1 month ago (2012-11-13 22:03:50 UTC) #12
commit-bot: I haz the power
8 years, 1 month ago (2012-11-14 00:46:20 UTC) #13
Change committed as 167537

Powered by Google App Engine
This is Rietveld 408576698