-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leaked 2D contexts might consume all OS global GPU resources
https://bugs.webkit.org/show_bug.cgi?id=273326 rdar://95930955 Reviewed by Matt Woodrow. Limit all the GPUP accelerated image buffers to certain numbers: - 30000 total limit - 3000 layer tile, 2D Context backing stores limit per WP - 1000 2D Context backing stores limit per WP Store the per-WP limit to the RemoteSharedResourceCache. This is shared with all the RemoteRenderingBackend instances of a particular WP: main thread rendering and Web Worker rendering. If GPUP allocates unlimited amount of accelerated image buffers, the allocations cause all of system IOSurface handles. The failures are handled ok in GPUP code, but might cause problems in other parts of the WebKit as well as in other processes. The underlying CGContexts will also run into per-process Metal object count limits. * LayoutTests/fast/canvas/image-buffer-backend-count-limit-expected.txt: Added. * LayoutTests/fast/canvas/image-buffer-backend-count-limit.html: Added. * Source/WebKit/GPUProcess/RemoteSharedResourceCache.cpp: (WebKit::RemoteSharedResourceCache::didAddAcceleratedImageBuffer): (WebKit::RemoteSharedResourceCache::didTakeAcceleratedImageBuffer): (WebKit::RemoteSharedResourceCache::adjustAcceleratedImageBufferRenderingMode const): * Source/WebKit/GPUProcess/RemoteSharedResourceCache.h: * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::didCreateImageBuffer): (WebKit::RemoteRenderingBackend::allocateImageBuffer): (WebKit::RemoteRenderingBackend::releaseImageBuffer): (WebKit::RemoteRenderingBackend::takeImageBuffer): Canonical link: https://commits.webkit.org/278304@main
- Loading branch information
1 parent
33411be
commit 78038e7
Showing
8 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
LayoutTests/fast/canvas/image-buffer-backend-count-limit-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Test creates many 2D contexts and checks when they are not created accelerated anymore | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS Effective rendering mode switches to Unaccelerated at instance: 1000 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
64 changes: 64 additions & 0 deletions
64
LayoutTests/fast/canvas/image-buffer-backend-count-limit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!DOCTYPE HTML><!-- webkit-test-runner [ runSingly=true ] --> | ||
<html> | ||
<body> | ||
<script src="../../resources/js-test.js"></script> | ||
<script> | ||
description("Test creates many 2D contexts and checks when they are not created accelerated anymore") | ||
|
||
function pixelsEqual(a, b) { | ||
for (let i = 0; i < 4; ++i) { | ||
if (a[i] != b[i]) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
var transparentBlack = [0, 0, 0, 0]; | ||
var lime = [0, 255, 0, 255]; | ||
var imageData; | ||
var context; | ||
function runTest() { | ||
if (typeof CanvasRenderingContext2D.prototype.getEffectiveRenderingModeForTesting === "undefined") { | ||
testFailed("Need effective rendering mode API"); | ||
return; | ||
} | ||
let canvases = []; | ||
for (let i = 0; i < 15000; ++i) { | ||
let canvas = document.createElement('canvas'); | ||
canvases.push(canvas) | ||
canvas.height = 100; | ||
canvas.width = 100; | ||
context = canvas.getContext("2d"); | ||
if (!context) { | ||
testFailed(`Context ${i} not created`); | ||
return; | ||
} | ||
context.fillStyle = "lime"; | ||
context.fillRect(0, 0, canvas.width, canvas.height); | ||
imageData = context.getImageData(0, 0, 1, 1); | ||
if (!imageData) { | ||
testFailed("Context failed to allocate imageData"); | ||
return; | ||
} else if (pixelsEqual(imageData.data, transparentBlack)) { | ||
testFailed("Context was lost"); | ||
return; | ||
} else if (!pixelsEqual(imageData.data, lime)) { | ||
shouldBe("imageData.data", "lime"); | ||
return; | ||
} | ||
let renderingMode = context.getEffectiveRenderingModeForTesting(); | ||
if (renderingMode != "Accelerated") { | ||
testPassed(`Effective rendering mode switches to ${renderingMode} at instance: ${i}`); | ||
canvases.length = 0; | ||
delete context; | ||
delete canvas; | ||
gc(); | ||
return; | ||
} | ||
} | ||
testFailed(`All ${i} contexts accelerated. Currently unexpected`); | ||
} | ||
runTest(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters