- Revision
- 287805
- Author
- mmaxfi...@apple.com
- Date
- 2022-01-07 19:18:59 -0800 (Fri, 07 Jan 2022)
Log Message
[GPU Process] Can't getImageData on canvas larger than 4096x4096
https://bugs.webkit.org/show_bug.cgi?id=234321
<rdar://problem/83575501>
Reviewed by Tim Horton.
Source/WebCore:
We already have a policy about how big canvases can be. Simply export that policy
so it can be consulted from the GPU process.
Test: fast/canvas/large-getImageData.html
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::maxActivePixelMemory):
(WebCore::maxActivePixelMemory): Deleted.
* html/HTMLCanvasElement.h:
Source/WebKit:
Consult the policy for how big a canvas can be, rather than hardcoding a number.
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::updateSharedMemoryForGetPixelBufferHelper):
LayoutTests:
* fast/canvas/large-getImageData-expected.txt: Added.
* fast/canvas/large-getImageData.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (287804 => 287805)
--- trunk/LayoutTests/ChangeLog 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/LayoutTests/ChangeLog 2022-01-08 03:18:59 UTC (rev 287805)
@@ -1,3 +1,14 @@
+2022-01-07 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [GPU Process] Can't getImageData on canvas larger than 4096x4096
+ https://bugs.webkit.org/show_bug.cgi?id=234321
+ <rdar://problem/83575501>
+
+ Reviewed by Tim Horton.
+
+ * fast/canvas/large-getImageData-expected.txt: Added.
+ * fast/canvas/large-getImageData.html: Added.
+
2022-01-07 Ryan Haddad <ryanhad...@apple.com>
REGRESSION (r283935): [ macOS wk1 ] imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html is a flaky failure
Added: trunk/LayoutTests/fast/canvas/large-getImageData-expected.txt (0 => 287805)
--- trunk/LayoutTests/fast/canvas/large-getImageData-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/large-getImageData-expected.txt 2022-01-08 03:18:59 UTC (rev 287805)
@@ -0,0 +1,5 @@
+PASS large getImageData worked
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/canvas/large-getImageData-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Rev URL
\ No newline at end of property
Added: trunk/LayoutTests/fast/canvas/large-getImageData.html (0 => 287805)
--- trunk/LayoutTests/fast/canvas/large-getImageData.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/large-getImageData.html 2022-01-08 03:18:59 UTC (rev 287805)
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ runSingly=true ] -->
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+var width = 4096;
+var height = 4097;
+
+if (window.internals) {
+ window.internals.setMaxCanvasPixelMemory(width * height * 4);
+ window.internals.setMaxCanvasArea(width * height);
+}
+
+var canvas = document.createElement('canvas');
+canvas.width = width;
+canvas.height = height;
+var ctx = canvas.getContext("2d");
+try {
+ var data = "" 0, width, height);
+ if (data)
+ testPassed("large getImageData worked");
+ else
+ testFailed("large getImageData returned false");
+} catch {
+ testFailed("large getImageData threw");
+}
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (287804 => 287805)
--- trunk/Source/WebCore/ChangeLog 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/Source/WebCore/ChangeLog 2022-01-08 03:18:59 UTC (rev 287805)
@@ -1,3 +1,21 @@
+2022-01-07 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [GPU Process] Can't getImageData on canvas larger than 4096x4096
+ https://bugs.webkit.org/show_bug.cgi?id=234321
+ <rdar://problem/83575501>
+
+ Reviewed by Tim Horton.
+
+ We already have a policy about how big canvases can be. Simply export that policy
+ so it can be consulted from the GPU process.
+
+ Test: fast/canvas/large-getImageData.html
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::maxActivePixelMemory):
+ (WebCore::maxActivePixelMemory): Deleted.
+ * html/HTMLCanvasElement.h:
+
2022-01-07 Alex Christensen <achristen...@webkit.org>
Make FullscreenManager::requestFullscreenForElement more robust
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (287804 => 287805)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2022-01-08 03:18:59 UTC (rev 287805)
@@ -202,7 +202,7 @@
reset();
}
-static inline size_t maxActivePixelMemory()
+size_t HTMLCanvasElement::maxActivePixelMemory()
{
if (maxActivePixelMemoryForTesting)
return *maxActivePixelMemoryForTesting;
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (287804 => 287805)
--- trunk/Source/WebCore/html/HTMLCanvasElement.h 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h 2022-01-08 03:18:59 UTC (rev 287805)
@@ -137,6 +137,8 @@
bool isControlledByOffscreen() const;
+ WEBCORE_EXPORT static size_t maxActivePixelMemory();
+
private:
HTMLCanvasElement(const QualifiedName&, Document&);
Modified: trunk/Source/WebKit/ChangeLog (287804 => 287805)
--- trunk/Source/WebKit/ChangeLog 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/Source/WebKit/ChangeLog 2022-01-08 03:18:59 UTC (rev 287805)
@@ -1,3 +1,16 @@
+2022-01-07 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [GPU Process] Can't getImageData on canvas larger than 4096x4096
+ https://bugs.webkit.org/show_bug.cgi?id=234321
+ <rdar://problem/83575501>
+
+ Reviewed by Tim Horton.
+
+ Consult the policy for how big a canvas can be, rather than hardcoding a number.
+
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::updateSharedMemoryForGetPixelBufferHelper):
+
2022-01-07 Alex Christensen <achristen...@webkit.org>
Make FullscreenManager::requestFullscreenForElement more robust
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (287804 => 287805)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-01-08 02:45:22 UTC (rev 287804)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-01-08 03:18:59 UTC (rev 287805)
@@ -40,6 +40,7 @@
#include "RemoteRenderingBackendMessages.h"
#include "RemoteRenderingBackendProxyMessages.h"
#include "WebCoreArgumentCoders.h"
+#include <WebCore/HTMLCanvasElement.h>
#include <wtf/CheckedArithmetic.h>
#include <wtf/StdLibExtras.h>
#include <wtf/SystemTracing.h>
@@ -198,8 +199,8 @@
{
MESSAGE_CHECK_WITH_RETURN_VALUE(!m_getPixelBufferSharedMemory || byteCount > m_getPixelBufferSharedMemory->size(), std::nullopt, "The existing Shmem for getPixelBuffer() is already big enough to handle the request");
- if (byteCount > 64 * MB) {
- // Just a sanity check. A 4K image is 36MB.
+ if (byteCount > HTMLCanvasElement::maxActivePixelMemory()) {
+ // Just a sanity check.
return std::nullopt;
}