⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280630 in webkit


Ignore:
Timestamp:
Aug 4, 2021, 2:40:46 AM (5 years ago)
Author:
timothy_horton@apple.com
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.

Location:
trunk
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280625 r280630  
     12021-08-04  Tim Horton  <timothy_horton@apple.com>
     2
     3        fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=228747
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/canvas/canvas-crash.html:
     9        * fast/canvas/canvas-skia-excessive-size.html:
     10        * platform/ios-simulator/fast/canvas/canvas-crash-expected.txt: Removed.
     11        * platform/ios-simulator/fast/canvas/canvas-skia-excessive-size-expected.txt: Removed.
     12        Delete the iOS-specific results, and adopt the new overrides in these two tests.
     13
    1142021-08-03  Lauro Moura  <lmoura@igalia.com>
    215
  • trunk/LayoutTests/fast/canvas/canvas-crash.html

    r276877 r280630  
    1313function canvastest()
    1414{
     15    if (window.internals) {
     16        window.internals.setMaxCanvasPixelMemory(16384 * 16384 * 4);
     17        window.internals.setMaxCanvasArea(13951 * 11138);
     18    }
    1519    var ctx = document.getCSSCanvasContext("2d", "canvastest", 13951, 11138);
    1620    ctx.putImageData(ctx.getImageData(1431655766, document.getElementById("a").appendChild(document.createElement("media")).clientWidth, 4096, -1024), 128, -65535, 127, -2147483648, 2147483647, -2147483648);
  • trunk/LayoutTests/fast/canvas/canvas-skia-excessive-size.html

    r120683 r280630  
    1111    if (window.testRunner)
    1212        testRunner.dumpAsText();
     13
     14    if (window.internals) {
     15        window.internals.setMaxCanvasPixelMemory(16384 * 16384 * 4);
     16        window.internals.setMaxCanvasArea(134217728);
     17    }
    1318
    1419    var canvas = document.getElementById("bigCanvas");
  • trunk/Source/WebCore/ChangeLog

    r280629 r280630  
     12021-08-04  Tim Horton  <timothy_horton@apple.com>
     2
     3        fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=228747
     5
     6        Reviewed by Simon Fraser.
     7
     8        The test fast/canvas/canvas-crash.html intends to test changes made
     9        to actual canvas code (see r215632); however, on the iOS simulator
     10        the test doesn't even manage to make a canvas context because of
     11        "maximum area" and "maximum backing store size" limits, which differ
     12        per-platform. This results in unique test results for iOS, as well
     13        as the test not actually exercising the code it was intended to.
     14
     15        Fix this by adding an override for the maximum area limit (we already
     16        had one for maximum backing store size), and overriding them in
     17        this test (and another similarly afflicted test).
     18
     19        * html/HTMLCanvasElement.cpp:
     20        (WebCore::maxCanvasArea):
     21        (WebCore::HTMLCanvasElement::setMaxCanvasAreaForTesting):
     22        (WebCore::HTMLCanvasElement::createImageBuffer const):
     23        * html/HTMLCanvasElement.h:
     24        * testing/Internals.cpp:
     25        (WebCore::Internals::resetToConsistentState):
     26        (WebCore::Internals::setMaxCanvasArea):
     27        * testing/Internals.h:
     28        * testing/Internals.idl:
     29
    1302021-08-04  Carlos Garcia Campos  <cgarcia@igalia.com>
    231
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r280467 r280630  
    112112const int defaultHeight = 150;
    113113
    114 // Firefox limits width/height to 32767 pixels, but slows down dramatically before it
    115 // reaches that limit. We limit by area instead, giving us larger maximum dimensions,
    116 // in exchange for a smaller maximum canvas size. The maximum canvas size is in device pixels.
    117 #if PLATFORM(IOS_FAMILY)
    118 const unsigned maxCanvasArea = 4096 * 4096;
    119 #else
    120 const unsigned maxCanvasArea = 16384 * 16384;
    121 #endif
    122 
    123 static size_t maxActivePixelMemoryForTesting = 0;
     114static std::optional<size_t> maxCanvasAreaForTesting;
     115static std::optional<size_t> maxActivePixelMemoryForTesting;
    124116
    125117HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& document)
     
    213205{
    214206    if (maxActivePixelMemoryForTesting)
    215         return maxActivePixelMemoryForTesting;
     207        return *maxActivePixelMemoryForTesting;
    216208
    217209    static size_t maxPixelMemory;
     
    228220}
    229221
    230 void HTMLCanvasElement::setMaxPixelMemoryForTesting(size_t size)
     222void HTMLCanvasElement::setMaxPixelMemoryForTesting(std::optional<size_t> size)
    231223{
    232224    maxActivePixelMemoryForTesting = size;
     225}
     226
     227static inline size_t maxCanvasArea()
     228{
     229    if (maxCanvasAreaForTesting)
     230        return *maxCanvasAreaForTesting;
     231
     232    // Firefox limits width/height to 32767 pixels, but slows down dramatically before it
     233    // reaches that limit. We limit by area instead, giving us larger maximum dimensions,
     234    // in exchange for a smaller maximum canvas size. The maximum canvas size is in device pixels.
     235#if PLATFORM(IOS_FAMILY)
     236    return 4096 * 4096;
     237#else
     238    return 16384 * 16384;
     239#endif
     240}
     241
     242void HTMLCanvasElement::setMaxCanvasAreaForTesting(std::optional<size_t> size)
     243{
     244    maxCanvasAreaForTesting = size;
    233245}
    234246
     
    867879    auto checkedArea = size().area<RecordOverflow>();
    868880
    869     if (checkedArea.hasOverflowed() || checkedArea > maxCanvasArea) {
    870         auto message = makeString("Canvas area exceeds the maximum limit (width * height > ", maxCanvasArea, ").");
     881    if (checkedArea.hasOverflowed() || checkedArea > maxCanvasArea()) {
     882        auto message = makeString("Canvas area exceeds the maximum limit (width * height > ", maxCanvasArea(), ").");
    871883        document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, message);
    872884        return;
  • trunk/Source/WebCore/html/HTMLCanvasElement.h

    r280467 r280630  
    129129    void setImageBufferAndMarkDirty(RefPtr<ImageBuffer>&&);
    130130
    131     WEBCORE_EXPORT static void setMaxPixelMemoryForTesting(size_t);
     131    WEBCORE_EXPORT static void setMaxPixelMemoryForTesting(std::optional<size_t>);
     132    WEBCORE_EXPORT static void setMaxCanvasAreaForTesting(std::optional<size_t>);
    132133
    133134    bool needsPreparationForDisplay();
  • trunk/Source/WebCore/testing/Internals.cpp

    r280308 r280630  
    601601#endif
    602602
    603     HTMLCanvasElement::setMaxPixelMemoryForTesting(0); // This means use the default value.
     603    HTMLCanvasElement::setMaxPixelMemoryForTesting(std::nullopt);
     604    HTMLCanvasElement::setMaxCanvasAreaForTesting(std::nullopt);
    604605    DOMWindow::overrideTransientActivationDurationForTesting(std::nullopt);
    605606
     
    60106011}
    60116012
     6013void Internals::setMaxCanvasArea(unsigned size)
     6014{
     6015    HTMLCanvasElement::setMaxCanvasAreaForTesting(size);
     6016}
     6017
    60126018int Internals::processIdentifier() const
    60136019{
  • trunk/Source/WebCore/testing/Internals.h

    r280308 r280630  
    347347
    348348    void setMaxCanvasPixelMemory(unsigned);
     349    void setMaxCanvasArea(unsigned);
    349350
    350351    ExceptionOr<unsigned> wheelEventHandlerCount();
  • trunk/Source/WebCore/testing/Internals.idl

    r280308 r280630  
    938938
    939939    undefined setMaxCanvasPixelMemory(unsigned long size);
     940    undefined setMaxCanvasArea(unsigned long size);
    940941
    941942    [Conditional=VIDEO] readonly attribute NowPlayingState nowPlayingState;
Note: See TracChangeset for help on using the changeset viewer.