Skip to content

Commit

Permalink
Big drop in canvas performance above 3840px
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=236173
rdar://88536159

Reviewed by Simon Fraser.

Limiting the accelerted canvas 2d context to arbitrary 5120*2880 is
not useful. The performance difference gets more beneficial to
hardware rasterization the higher the resolution.

The limit did not protect against hitting hardware rasterization
limits, since the limits are always per dimension, not per area.

As per above, capping based on any upper limit is not useful. Thus
remove the upper limit.

Reuse the unused lower limit as the trigger. The lower limit is
justified, as very small areas might be useful to rasterize with CPU.
Start the limit at 0, to match the previous behavior.

The hardware acceleration limits are checked in the respective
ImageBufferBackends, e.g. ImageBufferIOSurfaceBackend::calculateSafeSize.
This is done in WP for both GPUP mode and in-process mode. Both will
fall back to Unaccelerated.

Changes the RemoteRenderingBackend::createImageBuffer() to use
buffer options instead of rendering mode. The the buffer
options may be honored, but rendering mode would imply that it must
be honored. Later on when the rendering mode is more policy based on
rendering purpose, this is more clear.

* LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt:
* LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html:
* LayoutTests/compositing/canvas/accelerated-small-canvas-compositing-expected.txt: Removed.
* LayoutTests/compositing/canvas/accelerated-small-canvas-compositing.html: Removed.
* LayoutTests/fast/canvas/image-buffer-backend-variants-expected.txt:
* LayoutTests/platform/ios/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt: Removed.
* LayoutTests/platform/ios/fast/canvas/image-buffer-backend-variants-expected.txt:
* LayoutTests/platform/mac-wk1/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt: Added.
* LayoutTests/platform/mac-wk1/fast/canvas/image-buffer-backend-variants-expected.txt:
* LayoutTests/platform/mac-wk2/TestExpectations:
* LayoutTests/platform/mac-wk2/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt: Removed.
* LayoutTests/platform/wincairo/TestExpectations:
* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::shouldAccelerate const):
(WebCore::CanvasBase::allocateImageBuffer const):
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/page/Settings.yaml:

Canonical link: https://commits.webkit.org/268440@main
  • Loading branch information
kkinnunen-apple committed Sep 26, 2023
1 parent 55bd335 commit 45446c5
Show file tree
Hide file tree
Showing 30 changed files with 250 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,60 @@
Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456).
Verifies Canvas 2D Context accelerated backing store behavior.

(GraphicsLayer

(GraphicsLayer
(anchor 0.00 0.00)
(bounds 5208.00 6171.00)
(bounds 800.00 600.00)
(children 1
(GraphicsLayer
(bounds 5208.00 6171.00)
(bounds 800.00 600.00)
(contentsOpaque 1)
(children 3
(acceleratesDrawing 1)
(children 7
(GraphicsLayer
(position 112.00 94.00)
(anchor 0.50 0.49)
(bounds 100.00 57.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 216.00 94.00)
(anchor 0.50 0.49)
(bounds 100.00 57.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 50.00)
(bounds 512.00 288.00)
(position 320.00 94.00)
(bounds 100.00 56.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 342.00)
(bounds 5120.00 2880.00)
(usingTiledLayer 1)
(position 424.00 94.00)
(bounds 100.00 56.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 3226.00)
(bounds 5200.00 2900.00)
(usingTiledLayer 1)
(position 528.00 96.00)
(bounds 100.00 54.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 632.00 112.00)
(anchor 0.50 0.49)
(bounds 100.00 39.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 154.00)
(bounds 100.00 32.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<style>
canvas {
-webkit-transform: translateZ(0);
width: 100px;
}
</style>
<script>
Expand All @@ -18,7 +19,7 @@
var ctx = c.getContext('2d');
if (!ctx)
continue;
ctx.fillStyle = 'rgba(255,0,0,1)';
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
ctx.fillRect(0,0,c.width, c.height);
}
if (window.testRunner) {
Expand All @@ -31,10 +32,16 @@
</script>
</head>
<body>
<p>Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.</p>
<p>Verifies Canvas 2D Context accelerated backing store behavior.</p>
<canvas id="c0" width="10" height="10"></canvas>
<canvas id="c1" width="512" height="288"></canvas>
<canvas id="c2" width="5120" height="2880"></canvas>
<canvas id="c3" width="5200" height="2900"></canvas>
<canvas id="c4" width="8000" height="4444"></canvas>
<canvas id="c5" width="10344" height="5555"></canvas>
<canvas id="c6" width="17334" height="6669"></canvas>
<canvas id="c7" width="33444" height="10649"></canvas>

<pre id="layers">Layer tree goes here in DRT</pre>
</body>
</html>

This file was deleted.

This file was deleted.

30 changes: 15 additions & 15 deletions LayoutTests/fast/canvas/image-buffer-backend-variants-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 1000x16384 (area: 16384000)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 1000x32768 (area: 32768000)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Expand All @@ -95,10 +95,10 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 2048x8192 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 2048x16384 (area: 33554432)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 2048x32768 (area: 67108864)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Expand All @@ -116,13 +116,13 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 4096x4096 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 4096x8192 (area: 33554432)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 4096x16384 (area: 67108864)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 4096x32768 (area: 134217728)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Expand All @@ -137,16 +137,16 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 8192x2048 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 8192x4096 (area: 33554432)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 8192x8192 (area: 67108864)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 8192x16384 (area: 134217728)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 8192x32768 (area: 268435456)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Expand All @@ -157,19 +157,19 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 16384x1000 (area: 16384000)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 16384x2048 (area: 33554432)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 16384x4096 (area: 67108864)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 16384x8192 (area: 134217728)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 16384x16384 (area: 268435456)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 16384x32768 (area: 536870912)
PASS Context was lost
Testing 16384x32769 (area: 536887296)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,61 @@
Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 16777216).
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 16777216).
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 16777216).
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 16777216).
Verifies Canvas 2D Context accelerated backing store behavior.

(GraphicsLayer

(GraphicsLayer
(anchor 0.00 0.00)
(bounds 5208.00 6175.00)
(bounds 800.00 600.00)
(children 1
(GraphicsLayer
(bounds 5208.00 6175.00)
(bounds 800.00 600.00)
(contentsOpaque 1)
(acceleratesDrawing 1)
(children 3
(children 7
(GraphicsLayer
(position 112.00 96.00)
(anchor 0.50 0.50)
(bounds 100.00 56.50)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 216.00 96.00)
(anchor 0.50 0.50)
(bounds 100.00 56.50)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 320.00 96.00)
(bounds 100.00 56.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 424.00 96.00)
(bounds 100.00 56.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 52.00)
(bounds 512.00 288.00)
(position 528.00 98.00)
(bounds 100.00 54.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 345.00)
(bounds 5120.00 2880.00)
(usingTiledLayer 1)
(position 632.00 114.00)
(anchor 0.50 0.49)
(bounds 100.00 38.50)
(drawsContent 1)
(acceleratesDrawing 1)
)
(GraphicsLayer
(position 8.00 3230.00)
(bounds 5200.00 2900.00)
(usingTiledLayer 1)
(position 8.00 157.00)
(bounds 100.00 32.00)
(drawsContent 1)
(acceleratesDrawing 1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 2048x8192 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 2048x16384 (area: 33554432)
PASS Context was lost
Testing 2048x32768 (area: 67108864)
Expand All @@ -183,7 +183,7 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 4096x4096 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 4096x8192 (area: 33554432)
PASS Context was lost
Testing 4096x16384 (area: 67108864)
Expand All @@ -200,7 +200,7 @@ PASS imageData.data is red
Effective renderingMode: Accelerated
Testing 8192x2048 (area: 16777216)
PASS imageData.data is red
Effective renderingMode: Unaccelerated
Effective renderingMode: Accelerated
Testing 8192x4096 (area: 33554432)
PASS Context was lost
Testing 8192x8192 (area: 67108864)
Expand Down

0 comments on commit 45446c5

Please sign in to comment.