Bug 77049 - [Chromium] Force compositeAndReadback through regular scheduling flow
Summary: [Chromium] Force compositeAndReadback through regular scheduling flow
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nat Duca
URL:
Keywords:
: 72908 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-25 14:20 PST by David Reveman
Modified: 2012-03-12 13:08 PDT (History)
4 users (show)

See Also:


Attachments
Patch (5.54 KB, patch)
2012-01-25 14:23 PST, David Reveman
no flags Details | Formatted Diff | Diff
Patch (6.64 KB, patch)
2012-01-26 11:58 PST, David Reveman
no flags Details | Formatted Diff | Diff
Patch (29.80 KB, patch)
2012-03-09 01:45 PST, Nat Duca
no flags Details | Formatted Diff | Diff
Patch for landing (29.50 KB, patch)
2012-03-12 12:30 PDT, Nat Duca
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Reveman 2012-01-25 14:20:24 PST
Scheduler currently assumes that beginFrameComplete is only called after scheduledActionBeginFrame(). That's not the case for compositeAndReadback which might trigger a call to beginFrameComplete in different situations. This can currently cause an assertion failure in debug builds.
Comment 1 David Reveman 2012-01-25 14:23:48 PST
Created attachment 124011 [details]
Patch
Comment 2 David Reveman 2012-01-25 14:29:52 PST
The attached patch addresses this by simply changing the assumptions made about when beginFrameComplete can be called. Maybe we want to follow up with some larger changes to how compositeAndReadback interacts with the scheduler but I think this change is good enough as a bugfix+unittest patch.
Comment 3 David Reveman 2012-01-26 11:58:48 PST
Created attachment 124157 [details]
Patch
Comment 4 David Reveman 2012-01-26 12:01:06 PST
*** Bug 72908 has been marked as a duplicate of this bug. ***
Comment 5 David Reveman 2012-01-26 12:02:40 PST
Included a fix for https://bugs.webkit.org/show_bug.cgi?id=72908 as it's very much part of the same problem.
Comment 6 Nat Duca 2012-01-26 12:22:00 PST
Can you describe the sequence of events that is currently broken?
Comment 7 David Reveman 2012-01-26 13:31:51 PST
(In reply to comment #6)
> Can you describe the sequence of events that is currently broken?

The unit test covers the sequences I found to be broken. Here's one of them:

ImplThread - setVisible(false), e.g. the page is a background tab.
MainThread - setNeedsCommit, some change to the page cause this to be called.
MainThread - compositeAndReadback, is called before the scheduler schedules a BeginFrame action.
MainThread - beginFrameAndCommit, is called as pending commit exists.
ImplThread - beginFrameCompleteOnImplThread, blows up in debug mode as scheduler commit state is not COMMIT_STATE_FRAME_IN_PROGRESS when beginFrameComplete() is called.
Comment 8 James Robinson 2012-02-21 22:49:47 PST
Can we make compositeAndReadback() forcibly kick the scheduler into the right state instead of making the scheduler ASSERT()s universally more liberal? compositeAndReadback() is very much a special case, and one that we'd like to get rid of.  I can't speak for Nat but I know that I'd be happier with that particular codepath setting funky bits explicitly instead of all scheduler / state machine logic needing to be aware of otherwise nonsensical states.
Comment 9 Nat Duca 2012-03-07 12:26:39 PST
Thanks for the reproduce case!

I'm going to try to fix this by changing the compositeAndReadback flow to never create a beginFrameAndCommitTask in the first place.
Comment 10 Nat Duca 2012-03-09 01:45:50 PST
Created attachment 131007 [details]
Patch
Comment 11 James Robinson 2012-03-09 14:04:19 PST
Comment on attachment 131007 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=131007&action=review

Very nice! I think we have a wee bit o' a memory leak, but easily fixable.

R=me

> Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:397
> +    m_pendingBeginFrameRequest = new BeginFrameAndCommitState();

if we schedule a begin frame from the impl thread, but then start a shutdown from the main thread before we process the message will we end up leaking this pointer?  maybe m_pendingBeginFrameRequest should be an OwnPtr<> member - i think if we have to shut down the compositor with a beginFrame pending the right thing to do is to free up its memory and just don't worry about the scroll offsets/etc on it
Comment 12 Nat Duca 2012-03-09 14:05:38 PST
(In reply to comment #11)
> (From update of attachment 131007 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=131007&action=review
> 
> Very nice! I think we have a wee bit o' a memory leak, but easily fixable.
Hahaha whomp. Will fix that up. Thanks!
Comment 13 Nat Duca 2012-03-12 12:30:49 PDT
Created attachment 131381 [details]
Patch for landing
Comment 14 WebKit Review Bot 2012-03-12 13:08:38 PDT
Comment on attachment 131381 [details]
Patch for landing

Clearing flags on attachment: 131381

Committed r110464: <http://trac.webkit.org/changeset/110464>
Comment 15 WebKit Review Bot 2012-03-12 13:08:43 PDT
All reviewed patches have been landed.  Closing bug.