Title: [280630] trunk
Revision
280630
Author
[email protected]
Date
2021-08-04 02:40:46 -0700 (Wed, 04 Aug 2021)

Log Message

fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
https://bugs.webkit.org/show_bug.cgi?id=228747

Reviewed by Simon Fraser.

Source/WebCore:

The test fast/canvas/canvas-crash.html intends to test changes made
to actual canvas code (see r215632); however, on the iOS simulator
the test doesn't even manage to make a canvas context because of
"maximum area" and "maximum backing store size" limits, which differ
per-platform. This results in unique test results for iOS, as well
as the test not actually exercising the code it was intended to.

Fix this by adding an override for the maximum area limit (we already
had one for maximum backing store size), and overriding them in
this test (and another similarly afflicted test).

* html/HTMLCanvasElement.cpp:
(WebCore::maxCanvasArea):
(WebCore::HTMLCanvasElement::setMaxCanvasAreaForTesting):
(WebCore::HTMLCanvasElement::createImageBuffer const):
* html/HTMLCanvasElement.h:
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setMaxCanvasArea):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/canvas/canvas-crash.html:
* fast/canvas/canvas-skia-excessive-size.html:
* platform/ios-simulator/fast/canvas/canvas-crash-expected.txt: Removed.
* platform/ios-simulator/fast/canvas/canvas-skia-excessive-size-expected.txt: Removed.
Delete the iOS-specific results, and adopt the new overrides in these two tests.

Modified Paths

Removed Paths

  • trunk/LayoutTests/platform/ios-simulator/fast/canvas/

Diff

Modified: trunk/LayoutTests/ChangeLog (280629 => 280630)


--- trunk/LayoutTests/ChangeLog	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/LayoutTests/ChangeLog	2021-08-04 09:40:46 UTC (rev 280630)
@@ -1,3 +1,16 @@
+2021-08-04  Tim Horton  <[email protected]>
+
+        fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=228747
+
+        Reviewed by Simon Fraser.
+
+        * fast/canvas/canvas-crash.html:
+        * fast/canvas/canvas-skia-excessive-size.html:
+        * platform/ios-simulator/fast/canvas/canvas-crash-expected.txt: Removed.
+        * platform/ios-simulator/fast/canvas/canvas-skia-excessive-size-expected.txt: Removed.
+        Delete the iOS-specific results, and adopt the new overrides in these two tests.
+
 2021-08-03  Lauro Moura  <[email protected]>
 
         [WPE] Remove deprecated color-scheme baselines and expectations

Modified: trunk/LayoutTests/fast/canvas/canvas-crash.html (280629 => 280630)


--- trunk/LayoutTests/fast/canvas/canvas-crash.html	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/LayoutTests/fast/canvas/canvas-crash.html	2021-08-04 09:40:46 UTC (rev 280630)
@@ -12,6 +12,10 @@
 
 function canvastest()
 {
+    if (window.internals) {
+        window.internals.setMaxCanvasPixelMemory(16384 * 16384 * 4);
+        window.internals.setMaxCanvasArea(13951 * 11138);
+    }
     var ctx = document.getCSSCanvasContext("2d", "canvastest", 13951, 11138);
     ctx.putImageData(ctx.getImageData(1431655766, document.getElementById("a").appendChild(document.createElement("media")).clientWidth, 4096, -1024), 128, -65535, 127, -2147483648, 2147483647, -2147483648);
 }

Modified: trunk/LayoutTests/fast/canvas/canvas-skia-excessive-size.html (280629 => 280630)


--- trunk/LayoutTests/fast/canvas/canvas-skia-excessive-size.html	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/LayoutTests/fast/canvas/canvas-skia-excessive-size.html	2021-08-04 09:40:46 UTC (rev 280630)
@@ -11,6 +11,11 @@
     if (window.testRunner)
         testRunner.dumpAsText();
 
+    if (window.internals) {
+        window.internals.setMaxCanvasPixelMemory(16384 * 16384 * 4);
+        window.internals.setMaxCanvasArea(134217728);
+    }
+
     var canvas = document.getElementById("bigCanvas");
     var width = canvas.width;
     // We need to perform a context fetch to force allocation of

Modified: trunk/Source/WebCore/ChangeLog (280629 => 280630)


--- trunk/Source/WebCore/ChangeLog	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/ChangeLog	2021-08-04 09:40:46 UTC (rev 280630)
@@ -1,3 +1,32 @@
+2021-08-04  Tim Horton  <[email protected]>
+
+        fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=228747
+
+        Reviewed by Simon Fraser.
+
+        The test fast/canvas/canvas-crash.html intends to test changes made
+        to actual canvas code (see r215632); however, on the iOS simulator
+        the test doesn't even manage to make a canvas context because of
+        "maximum area" and "maximum backing store size" limits, which differ
+        per-platform. This results in unique test results for iOS, as well
+        as the test not actually exercising the code it was intended to.
+
+        Fix this by adding an override for the maximum area limit (we already
+        had one for maximum backing store size), and overriding them in
+        this test (and another similarly afflicted test).
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::maxCanvasArea):
+        (WebCore::HTMLCanvasElement::setMaxCanvasAreaForTesting):
+        (WebCore::HTMLCanvasElement::createImageBuffer const):
+        * html/HTMLCanvasElement.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::Internals::setMaxCanvasArea):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2021-08-04  Carlos Garcia Campos  <[email protected]>
 
         Add missing null-check in Touch constructor

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (280629 => 280630)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-08-04 09:40:46 UTC (rev 280630)
@@ -111,17 +111,9 @@
 const int defaultWidth = 300;
 const int defaultHeight = 150;
 
-// Firefox limits width/height to 32767 pixels, but slows down dramatically before it
-// reaches that limit. We limit by area instead, giving us larger maximum dimensions,
-// in exchange for a smaller maximum canvas size. The maximum canvas size is in device pixels.
-#if PLATFORM(IOS_FAMILY)
-const unsigned maxCanvasArea = 4096 * 4096;
-#else
-const unsigned maxCanvasArea = 16384 * 16384;
-#endif
+static std::optional<size_t> maxCanvasAreaForTesting;
+static std::optional<size_t> maxActivePixelMemoryForTesting;
 
-static size_t maxActivePixelMemoryForTesting = 0;
-
 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
     , CanvasBase(IntSize(defaultWidth, defaultHeight))
@@ -212,7 +204,7 @@
 static inline size_t maxActivePixelMemory()
 {
     if (maxActivePixelMemoryForTesting)
-        return maxActivePixelMemoryForTesting;
+        return *maxActivePixelMemoryForTesting;
 
     static size_t maxPixelMemory;
     static std::once_flag onceFlag;
@@ -227,11 +219,31 @@
     return maxPixelMemory;
 }
 
-void HTMLCanvasElement::setMaxPixelMemoryForTesting(size_t size)
+void HTMLCanvasElement::setMaxPixelMemoryForTesting(std::optional<size_t> size)
 {
     maxActivePixelMemoryForTesting = size;
 }
 
+static inline size_t maxCanvasArea()
+{
+    if (maxCanvasAreaForTesting)
+        return *maxCanvasAreaForTesting;
+
+    // Firefox limits width/height to 32767 pixels, but slows down dramatically before it
+    // reaches that limit. We limit by area instead, giving us larger maximum dimensions,
+    // in exchange for a smaller maximum canvas size. The maximum canvas size is in device pixels.
+#if PLATFORM(IOS_FAMILY)
+    return 4096 * 4096;
+#else
+    return 16384 * 16384;
+#endif
+}
+
+void HTMLCanvasElement::setMaxCanvasAreaForTesting(std::optional<size_t> size)
+{
+    maxCanvasAreaForTesting = size;
+}
+
 ExceptionOr<std::optional<RenderingContext>> HTMLCanvasElement::getContext(JSC::JSGlobalObject& state, const String& contextId, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
 {
     if (m_context) {
@@ -866,8 +878,8 @@
 
     auto checkedArea = size().area<RecordOverflow>();
 
-    if (checkedArea.hasOverflowed() || checkedArea > maxCanvasArea) {
-        auto message = makeString("Canvas area exceeds the maximum limit (width * height > ", maxCanvasArea, ").");
+    if (checkedArea.hasOverflowed() || checkedArea > maxCanvasArea()) {
+        auto message = makeString("Canvas area exceeds the maximum limit (width * height > ", maxCanvasArea(), ").");
         document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, message);
         return;
     }

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (280629 => 280630)


--- trunk/Source/WebCore/html/HTMLCanvasElement.h	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h	2021-08-04 09:40:46 UTC (rev 280630)
@@ -128,7 +128,8 @@
     // It would be better to have the contexts own the buffers.
     void setImageBufferAndMarkDirty(RefPtr<ImageBuffer>&&);
 
-    WEBCORE_EXPORT static void setMaxPixelMemoryForTesting(size_t);
+    WEBCORE_EXPORT static void setMaxPixelMemoryForTesting(std::optional<size_t>);
+    WEBCORE_EXPORT static void setMaxCanvasAreaForTesting(std::optional<size_t>);
 
     bool needsPreparationForDisplay();
     void prepareForDisplay();

Modified: trunk/Source/WebCore/testing/Internals.cpp (280629 => 280630)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-08-04 09:40:46 UTC (rev 280630)
@@ -600,7 +600,8 @@
     WebCore::MediaRecorder::setCustomPrivateRecorderCreator(nullptr);
 #endif
 
-    HTMLCanvasElement::setMaxPixelMemoryForTesting(0); // This means use the default value.
+    HTMLCanvasElement::setMaxPixelMemoryForTesting(std::nullopt);
+    HTMLCanvasElement::setMaxCanvasAreaForTesting(std::nullopt);
     DOMWindow::overrideTransientActivationDurationForTesting(std::nullopt);
 
 #if PLATFORM(IOS)
@@ -6009,6 +6010,11 @@
     HTMLCanvasElement::setMaxPixelMemoryForTesting(size);
 }
 
+void Internals::setMaxCanvasArea(unsigned size)
+{
+    HTMLCanvasElement::setMaxCanvasAreaForTesting(size);
+}
+
 int Internals::processIdentifier() const
 {
     return getCurrentProcessID();

Modified: trunk/Source/WebCore/testing/Internals.h (280629 => 280630)


--- trunk/Source/WebCore/testing/Internals.h	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/testing/Internals.h	2021-08-04 09:40:46 UTC (rev 280630)
@@ -346,6 +346,7 @@
     void setUserPreferredAudioCharacteristic(const String&);
 
     void setMaxCanvasPixelMemory(unsigned);
+    void setMaxCanvasArea(unsigned);
 
     ExceptionOr<unsigned> wheelEventHandlerCount();
     ExceptionOr<unsigned> touchEventHandlerCount();

Modified: trunk/Source/WebCore/testing/Internals.idl (280629 => 280630)


--- trunk/Source/WebCore/testing/Internals.idl	2021-08-04 08:19:22 UTC (rev 280629)
+++ trunk/Source/WebCore/testing/Internals.idl	2021-08-04 09:40:46 UTC (rev 280630)
@@ -937,6 +937,7 @@
     undefined markContextAsInsecure();
 
     undefined setMaxCanvasPixelMemory(unsigned long size);
+    undefined setMaxCanvasArea(unsigned long size);
 
     [Conditional=VIDEO] readonly attribute NowPlayingState nowPlayingState;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to