Bug 230855 - Canvas memory limit of 4096 × 4096 pixels when calling ctx.getImageData
Summary: Canvas memory limit of 4096 × 4096 pixels when calling ctx.getImageData
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-09-27 13:21 PDT by Bramus
Modified: 2021-10-12 16:54 PDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bramus 2021-09-27 13:21:35 PDT
Spotted on Twitter [1], by Rik Schennink

“Safari 15 has a canvas memory limit of 4096 × 4096 pixels where Safari 14 could deal with resolutions up to 16384 x 16384”

Can verify via the CodePen Demo [2] Rik also shared, in which he creates a 4097x4097 canvas. Upon calling `ctx.getImageData(0, 0, size, size)` the code fails.

“Unable to get image data from canvas. Requested size was 4097 x 4097”

While searching for bugs I did find [3] where the limit was added for iOS, but this is now applied on macOS too apparently. Is this a regression?

[1] https://twitter.com/rikschennink/status/1442443774748082185
[2] https://codepen.io/rikschennink/pen/YzQRdwZ
[3] https://bugs.webkit.org/show_bug.cgi?id=145998
Comment 1 Bramus 2021-09-27 13:23:15 PDT
I read in https://bugs.webkit.org/show_bug.cgi?id=229237 that the “2D memory limit” test got marked as expected to Crash, so I guess that that explains why this went undetected?
Comment 2 Bramus 2021-09-28 02:40:03 PDT
Update: Creating a canvas of 16384 x 16384 on macOS and drawing on it still works. It's only when calling `ctx.getImageData` that Safari fails to cooperate.
Comment 3 Kevin Neal 2021-09-29 08:22:24 PDT
Thank you for filing. The appropriate engineers have been notified.
Comment 4 Radar WebKit Bug Importer 2021-09-29 08:22:34 PDT
<rdar://problem/83671710>
Comment 5 Myles C. Maxfield 2021-10-12 16:45:33 PDT
<rdar://problem/83575501>
Comment 6 Myles C. Maxfield 2021-10-12 16:46:34 PDT
static const float MaxClampedLength = 4096;
static const float MaxClampedArea = MaxClampedLength * MaxClampedLength;
Comment 7 Myles C. Maxfield 2021-10-12 16:47:39 PDT
Might have been caused by https://bugs.webkit.org/show_bug.cgi?id=144335?
Comment 8 Simon Fraser (smfr) 2021-10-12 16:54:33 PDT
Or by the GPU Process?