Bug 107804

Summary: [mac] ImageBuffer should create accelerated buffers for small canvases, but we shouldn't force them to create compositing layers
Product: WebKit Reporter: Tim Horton <thorton>
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, buildbot, eric, ojan.autocc, rniwa, sam, simon.fraser, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 108310    
Bug Blocks:    
Attachments:
Description Flags
patch
simon.fraser: review-, buildbot: commit-queue-
patch
none
patch
simon.fraser: review-
Simon really doesn't like it when you touch Platform.h simon.fraser: review+

Description Tim Horton 2013-01-24 01:45:50 PST
<rdar://problem/11752381>

Mac WebKit is slower than it needs to be on http://www.mikechambers.com/html5/javascript/QuadTree/examples/collision.html because it makes lots of tiny canvases and draws them into a big one. The tiny ones fall below ImageBufferCG's "minIOSurfaceSize", so they are created in main memory. The big one is big, so it's an IOSurface. Painting between these is incredibly slow.

The reason we cap ImageBuffer acceleration by size is so that small canvases (for example, http://typeface.neocracy.org/examples.html) don't force compositing (and then potentially cause overlap, and huge memory cost). But, we can still make IOSurfaces and still not pop them into compositing layers. So, let's do that!
Comment 1 Tim Horton 2013-01-24 01:52:55 PST
Created attachment 184441 [details]
patch

name of the constant is a little wonky
Comment 2 Tim Horton 2013-01-24 01:54:14 PST
Comment on attachment 184441 [details]
patch

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

> Source/WebCore/rendering/RenderLayerCompositor.cpp:1907
> +        return canvas->renderingContext() && canvas->renderingContext()->isAccelerated() && (canvas->size().area() > canvasAreaThresholdRequiringCompositing);

This is shared code, I wonder if this is reasonable for everyone...
Comment 3 Build Bot 2013-01-24 05:09:15 PST
Comment on attachment 184441 [details]
patch

Attachment 184441 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/16082655

New failing tests:
fast/canvas/webgl/gl-pixelstorei.html
fast/canvas/webgl/tex-image-webgl.html
compositing/layer-creation/spanOverlapsCanvas.html
Comment 4 Simon Fraser (smfr) 2013-01-24 08:38:46 PST
Comment on attachment 184441 [details]
patch

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

>> Source/WebCore/rendering/RenderLayerCompositor.cpp:1907
>> +        return canvas->renderingContext() && canvas->renderingContext()->isAccelerated() && (canvas->size().area() > canvasAreaThresholdRequiringCompositing);
> 
> This is shared code, I wonder if this is reasonable for everyone...

We should probably #ifdef it. Maybe USE_COMPOSITING_FOR_SMALL_CANVASES or something, disabled for PLATFORM(MAC) and PLATFORM(IOS).
Comment 5 Tim Horton 2013-01-24 10:52:00 PST
(In reply to comment #3)
> (From update of attachment 184441 [details])
> Attachment 184441 [details] did not pass mac-ews (mac):
> Output: http://queues.webkit.org/results/16082655
> 
> New failing tests:
> fast/canvas/webgl/gl-pixelstorei.html
> fast/canvas/webgl/tex-image-webgl.html

... not a clue, but I can reproduce, so I'll look.

> compositing/layer-creation/spanOverlapsCanvas.html

This one uses a canvas at exactly the threshold and demonstrates that I should have used >= instead of > to match the < from before.
Comment 6 Tim Horton 2013-01-30 14:40:23 PST
Created attachment 185580 [details]
patch
Comment 7 Tim Horton 2013-01-30 14:42:22 PST
Needs a WTF changelog.
Comment 8 Tim Horton 2013-01-30 14:43:28 PST
Created attachment 185582 [details]
patch
Comment 9 Simon Fraser (smfr) 2013-01-30 14:54:54 PST
Comment on attachment 185582 [details]
patch

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

> Source/WTF/wtf/Platform.h:1218
> +#if !PLATFORM(MAC) && !PLATFORM(IOS)
> +#define WTF_USE_COMPOSITING_FOR_SMALL_CANVASES 1
> +#endif

Please don't cause megawatts of energy use in making us all rebuild because of this #ifdef that's only used in one place.
Comment 10 Tim Horton 2013-01-30 14:57:52 PST
Created attachment 185589 [details]
Simon really doesn't like it when you touch Platform.h
Comment 11 Simon Fraser (smfr) 2013-01-30 15:05:47 PST
Comment on attachment 185589 [details]
Simon really doesn't like it when you touch Platform.h

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

> Source/WebCore/rendering/RenderLayerCompositor.cpp:1921
> +        bool isCanvasLargeEnoughToForceCompositing = canvas->size().area() >= canvasAreaThresholdRequiringCompositing;

Hmm, this looks at element size. Maybe we should composite based on the renderer dimensions? You might have a small canvas scaled up via CSS.
Comment 12 Simon Fraser (smfr) 2013-01-30 15:33:20 PST
Comment on attachment 185589 [details]
Simon really doesn't like it when you touch Platform.h

I think this is fine.
Comment 13 Tim Horton 2013-01-30 15:36:39 PST
Thanks!

http://trac.webkit.org/changeset/141333