Skip to content
Permalink
Browse files
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.


Canonical link: https://commits.webkit.org/240243@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Aug 4, 2021
1 parent f616b56 commit 03e65e95213369fba2e94444e2d4a2a18d329ece
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 25 deletions.
@@ -1,3 +1,16 @@
2021-08-04 Tim Horton <timothy_horton@apple.com>

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 <lmoura@igalia.com>

[WPE] Remove deprecated color-scheme baselines and expectations
@@ -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);
}
@@ -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

This file was deleted.

This file was deleted.

@@ -1,3 +1,32 @@
2021-08-04 Tim Horton <timothy_horton@apple.com>

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 <cgarcia@igalia.com>

Add missing null-check in Touch constructor
@@ -111,16 +111,8 @@ using namespace HTMLNames;
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 size_t maxActivePixelMemoryForTesting = 0;
static std::optional<size_t> maxCanvasAreaForTesting;
static std::optional<size_t> maxActivePixelMemoryForTesting;

HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
@@ -212,7 +204,7 @@ void HTMLCanvasElement::setSize(const IntSize& newSize)
static inline size_t maxActivePixelMemory()
{
if (maxActivePixelMemoryForTesting)
return maxActivePixelMemoryForTesting;
return *maxActivePixelMemoryForTesting;

static size_t maxPixelMemory;
static std::once_flag onceFlag;
@@ -227,11 +219,31 @@ static inline size_t maxActivePixelMemory()
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 @@ void HTMLCanvasElement::createImageBuffer() const

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;
}
@@ -128,7 +128,8 @@ class HTMLCanvasElement final : public HTMLElement, public CanvasBase, public Ac
// 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();
@@ -600,7 +600,8 @@ void Internals::resetToConsistentState(Page& page)
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 @@ void Internals::setMaxCanvasPixelMemory(unsigned size)
HTMLCanvasElement::setMaxPixelMemoryForTesting(size);
}

void Internals::setMaxCanvasArea(unsigned size)
{
HTMLCanvasElement::setMaxCanvasAreaForTesting(size);
}

int Internals::processIdentifier() const
{
return getCurrentProcessID();
@@ -346,6 +346,7 @@ class Internals final : public RefCounted<Internals>, private ContextDestruction
void setUserPreferredAudioCharacteristic(const String&);

void setMaxCanvasPixelMemory(unsigned);
void setMaxCanvasArea(unsigned);

ExceptionOr<unsigned> wheelEventHandlerCount();
ExceptionOr<unsigned> touchEventHandlerCount();
@@ -937,6 +937,7 @@ enum AutoplayPolicy {
undefined markContextAsInsecure();

undefined setMaxCanvasPixelMemory(unsigned long size);
undefined setMaxCanvasArea(unsigned long size);

[Conditional=VIDEO] readonly attribute NowPlayingState nowPlayingState;

0 comments on commit 03e65e9

Please sign in to comment.