Bug 95661 - [Chromium] Multiple commits without invalidation allowed per redraw.
Summary: [Chromium] Multiple commits without invalidation allowed per redraw.
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: David Reveman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-02 19:53 PDT by David Reveman
Modified: 2012-09-11 13:53 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.07 KB, patch)
2012-09-02 20:00 PDT, David Reveman
no flags Details | Formatted Diff | Diff
Patch (8.43 KB, patch)
2012-09-02 21:11 PDT, David Reveman
no flags Details | Formatted Diff | Diff
Patch (9.71 KB, patch)
2012-09-06 17:10 PDT, David Reveman
no flags Details | Formatted Diff | Diff
Patch (9.68 KB, patch)
2012-09-07 14:46 PDT, David Reveman
no flags Details | Formatted Diff | Diff
Patch (10.29 KB, patch)
2012-09-07 16:02 PDT, David Reveman
no flags Details | Formatted Diff | Diff
Patch (10.27 KB, patch)
2012-09-07 16:21 PDT, David Reveman
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-09-02 19:53:14 PDT
There's no mechanism in place to prevent multiple commits per redraw. Multiple commits with resource updates are prevented as a side-effect of how the current incremental resource update mechanism works.
Comment 1 David Reveman 2012-09-02 20:00:13 PDT
Created attachment 161855 [details]
Patch

Unit tests and change that prevents all types of commits from happening twice between vsync ticks
Comment 2 WebKit Review Bot 2012-09-02 20:03:42 PDT
Comment on attachment 161855 [details]
Patch

Attachment 161855 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13733388
Comment 3 Peter Beverloo (cr-android ews) 2012-09-02 20:12:36 PDT
Comment on attachment 161855 [details]
Patch

Attachment 161855 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/13734298
Comment 4 David Reveman 2012-09-02 20:17:14 PDT
The current patch breaks some existing unit tests but I'll fix that before landing. The important part of the patch is the new unit tests. My current understanding is that all these tests should pass and the change included enforces that. Is that correct?
Comment 5 James Robinson 2012-09-02 20:42:09 PDT
Comment on attachment 161855 [details]
Patch

Setting this bit on the scheduler feels redundant with the state transitions we already have.  We should go from commit -> waiting for draw -> draw -> ready for commit again.  How are we falling out of waiting_for_first_draw without drawing?

Why 50 in the unit tests?  Is there anything in particular interesting about that number, or is it meant as a blind fuzz test of sorts?  It doesn't really feel appropriate as a unit test.
Comment 6 David Reveman 2012-09-02 21:11:53 PDT
Created attachment 161856 [details]
Patch

Only call setCanBeginFrame(true) when no more resource updates
Comment 7 WebKit Review Bot 2012-09-02 21:15:32 PDT
Comment on attachment 161856 [details]
Patch

Attachment 161856 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13726920
Comment 8 Peter Beverloo (cr-android ews) 2012-09-02 21:22:36 PDT
Comment on attachment 161856 [details]
Patch

Attachment 161856 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/13741013
Comment 9 James Robinson 2012-09-04 17:50:05 PDT
Comment on attachment 161856 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp:94
>      m_stateMachine.beginFrameComplete();
> +    m_stateMachine.setCanBeginFrame(false);

These still seem redundant to me. Telling the state machine beginFrameComplete should put us into the waiting for draw state.  Once we get into this state, how are we returning ACTION_BEGIN_FRAME before we actually draw?  I think fixing that will fix this class of bugs without needing redundant state sets.
Comment 10 David Reveman 2012-09-06 17:10:00 PDT
Created attachment 162622 [details]
Patch

Use COMMIT_STATE_WAITING_FOR_FIRST_DRAW to enforce a draw after each commit.
Comment 11 James Robinson 2012-09-06 17:25:46 PDT
Comment on attachment 162622 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp:209
> +        if (!m_needsForcedCommit)
>              m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
>          else
>              m_commitState = COMMIT_STATE_IDLE;

After ACTION_COMMIT you should unconditionally enter COMMIT_STATE_WAITING_FOR_FIRST_DRAW.  If we need a forced commit, we'll go ahead and emit ACTION_BEGIN_FRAME even if we're in COMMIT_STATE_WAITING_FOR_FIRST_DRAW.

I can't figure out for the life of me what the conditions "(m_needsCommit || !m_visible) && !m_needsForcedCommit" were supposed to do
Comment 12 Nat Duca 2012-09-06 17:29:55 PDT
Comment on attachment 162622 [details]
Patch

Lets give this a try. I really think we need to do a patch to hoist the impl-side "dont actually commit now" out of the scheduler completely, but thats for another day.
Comment 13 James Robinson 2012-09-06 17:30:06 PDT
Comment on attachment 162622 [details]
Patch

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

> Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp:2915
> +        if (m_numDidCommit < 50) {

this is not a good unit test. a unit test should test for a specific case, not just blindly loop a bunch.  run through the states you care about and then end the test - you definitely don't care about 50 different states

> Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp:2972
> +        if (m_numAnimate < 50) {

same here. make the test specific
Comment 14 David Reveman 2012-09-07 14:46:53 PDT
Created attachment 162873 [details]
Patch

Check number of commits between first and second draw instead of ending the tests after a random number of commits.
Comment 15 James Robinson 2012-09-07 15:11:45 PDT
Comment on attachment 162873 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp:209
> +        if (!m_needsForcedCommit)
>              m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
>          else
>              m_commitState = COMMIT_STATE_IDLE;

Why didn't you fix this?
Comment 16 David Reveman 2012-09-07 16:02:17 PDT
Created attachment 162894 [details]
Patch

Always update commit state to COMMIT_STATE_WAITING_FOR_FIRST_DRAW from ACTION_COMMIT
Comment 17 James Robinson 2012-09-07 16:03:39 PDT
Comment on attachment 162894 [details]
Patch

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

Great!

> Source/WebCore/ChangeLog:9
> +        Enter COMMIT_STATE_WAITING_FOR_FIRST_DRAW after commit unless we need
> +        a forced commit. This ensures we draw before beginning a new frame.

update this - I think the "unless..." is stale now
Comment 18 David Reveman 2012-09-07 16:21:16 PDT
Created attachment 162896 [details]
Patch

Fix changelog
Comment 19 WebKit Review Bot 2012-09-07 17:25:01 PDT
Comment on attachment 162896 [details]
Patch

Clearing flags on attachment: 162896

Committed r127940: <http://trac.webkit.org/changeset/127940>
Comment 20 WebKit Review Bot 2012-09-07 17:25:04 PDT
All reviewed patches have been landed.  Closing bug.