Bug 75062 - [chromium] Try to create graphics context thrice before giving up on acceleratedCompositing
Summary: [chromium] Try to create graphics context thrice before giving up on accelera...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nat Duca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-21 20:58 PST by Nat Duca
Modified: 2012-03-06 13:44 PST (History)
1 user (show)

See Also:


Attachments
Patch (4.64 KB, patch)
2011-12-21 21:01 PST, Nat Duca
no flags Details | Formatted Diff | Diff
Patch (4.60 KB, patch)
2012-01-10 16:47 PST, Nat Duca
no flags Details | Formatted Diff | Diff
Patch (5.45 KB, patch)
2012-01-11 11:17 PST, Nat Duca
jamesr: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nat Duca 2011-12-21 20:58:07 PST
[chromium] Try to create graphics context twice before giving up on acceleratedCompositing
Comment 1 Nat Duca 2011-12-21 21:01:07 PST
Created attachment 120264 [details]
Patch
Comment 2 James Robinson 2011-12-21 21:16:49 PST
Comment on attachment 120264 [details]
Patch

so we're relying on the style recalc timer to retry context creation?

should we just always be creating the compositor context off a timer? IOW in setRootLayer() just store the layer and set a timer, then when the timer fires go ahead and attempt to initialize the CCLayerTreeHost. if that fails, then we have to set accelerated compositing to false and force a style recalc to drop all the RenderLayerBackings
Comment 3 James Robinson 2011-12-21 22:08:46 PST
On second thought that might add too much latency in the normal case. Hmmmm
Comment 4 Nat Duca 2011-12-21 22:57:14 PST
(In reply to comment #3)
> On second thought that might add too much latency in the normal case. Hmmmm

OOh, that is a neat idea... lemme think.....

Suppose for a minute we had DoDeferredUpdate inside WebViewImpl (which we're always threatening to do). At that point, you'd have a central "DoDeferredUpdate" that would vector off to accelerated or software paint mode. So, when you got this, you'd just make sure a ddu was scheduled. And you'd stash a note saying "hey, this is the goal state for accelerated compositing."

Then, in DDU, the first thing you'd do is switch fully over to the other mode....
Comment 5 Nat Duca 2012-01-10 16:47:46 PST
Created attachment 121940 [details]
Patch
Comment 6 James Robinson 2012-01-10 17:45:32 PST
Comment on attachment 121940 [details]
Patch

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

> Source/WebKit/chromium/src/WebViewImpl.cpp:2996
> +            // If the context creaiton failed, there is a very good chance that

typo creation

> Source/WebKit/chromium/src/WebViewImpl.cpp:3003
> +            m_page->mainFrame()->document()->scheduleForcedStyleRecalc();

this will force every element in the document to get styles re-resolved, regardless of whether they were dirty. do we need to go this heavy?

it'll also work on the main frame's document and not any subdocuments, so if there's a compositing trigger in an iframe this won't hit it - will it still trigger the compositor? easy (hah) way to test would be window.open() a page that has an iframe with a 3d-transformed element inside the iframe

> Source/WebKit/chromium/src/WebViewImpl.h:659
> +        kMaxCompositorCreationAttempts = 2

i don't think we normally use the k prefix for constants in WebKit.

can you put this in the .cpp? it's not API

> Source/WebKit/chromium/src/WebViewImpl.h:661
> +    bool m_numCompositorCreationAttempts;

bool number wut
Comment 7 Nat Duca 2012-01-11 11:17:15 PST
Created attachment 122054 [details]
Patch
Comment 8 Nat Duca 2012-01-11 11:31:35 PST
(In reply to comment #6)
> > Source/WebKit/chromium/src/WebViewImpl.cpp:3003
> > +            m_page->mainFrame()->document()->scheduleForcedStyleRecalc();
> 
> this will force every element in the document to get styles re-resolved, regardless of whether they were dirty. do we need to go this heavy?
> 
> it'll also work on the main frame's document and not any subdocuments, so if there's a compositing trigger in an iframe this won't hit it - will it still trigger the compositor? easy (hah) way to test would be window.open() a page that has an iframe with a 3d-transformed element inside the iframe

Not sure what you had in mind instead of scheduleForced... This is what we've typically used for forcing ourselves into.

Checked the window.open case with the following:
http://www.corp.google.com/~nduca/test/window_open_iframe_with_css.html

Seems to work... might be good to learn from you "why" :)
Comment 9 Nat Duca 2012-01-17 14:16:22 PST
(In reply to comment #8)
@jamesr: ping?
Comment 10 James Robinson 2012-01-20 17:01:25 PST
(In reply to comment #8)
> (In reply to comment #6)
> > > Source/WebKit/chromium/src/WebViewImpl.cpp:3003
> > > +            m_page->mainFrame()->document()->scheduleForcedStyleRecalc();
> > 
> > this will force every element in the document to get styles re-resolved, regardless of whether they were dirty. do we need to go this heavy?
> > 
> > it'll also work on the main frame's document and not any subdocuments, so if there's a compositing trigger in an iframe this won't hit it - will it still trigger the compositor? easy (hah) way to test would be window.open() a page that has an iframe with a 3d-transformed element inside the iframe
> 
> Not sure what you had in mind instead of scheduleForced... This is what we've typically used for forcing ourselves into.
> 
> Checked the window.open case with the following:
> http://www.corp.google.com/~nduca/test/window_open_iframe_with_css.html
> 
> Seems to work... might be good to learn from you "why" :)

That testcase seems to work without any local patches. Looking in more detail...
Comment 11 Nat Duca 2012-01-20 17:05:31 PST
(In reply to comment #10)
> 
> That testcase seems to work without any local patches. Looking in more detail...

F! My bad! I can look if you've got other stuff to do...
Comment 12 James Robinson 2012-01-20 19:52:01 PST
Completely different approach here: https://chromiumcodereview.appspot.com/9141035/

If you don't mind let's take discussion to http://code.google.com/p/chromium/issues/detail?id=106815 for a bit and see if we can get consensus there.
Comment 13 James Robinson 2012-01-20 19:52:24 PST
For anyone curious, the way to repro this problem is to pass --force-compositing-mode. The window.open()'d window doesn't get compositing when it should.
Comment 14 James Robinson 2012-01-24 10:10:55 PST
Comment on attachment 122054 [details]
Patch

I have a chrome-side patch underway to make the compositor initialization succeed the first time, see crbug.com/106815. While that's not done I would prefer to pursue that avenue rather than adding more retry stuff here.
Comment 15 Nat Duca 2012-01-24 10:12:46 PST
For the record, I agree wholeheartedly. This patch was designed to be a fallback position in case we didn't have time to pursue a real fix.