Open Bug 1402711 Opened 7 years ago Updated 2 years ago

Canvas drawImage() fails if texture size is large (16384x16384)

Categories

(Core :: Graphics: Canvas2D, defect, P2)

55 Branch
defect

Tracking

()

REOPENED
Tracking Status
firefox56 --- fix-optional
firefox57 --- fix-optional
firefox58 --- wontfix
firefox59 --- ?

People

(Reporter: mail, Unassigned)

Details

(Whiteboard: [gfx-noted])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Build ID: 20170824053622

Steps to reproduce:

I'm a developer at https://p3d.in/ and by user report we noticed that scaling down large images using HTML5 canvas fails on Firefox.

We have verified this bug on both Windows and Linux versions of Firefox 55.0.3. I also verified the issue on older Firefox versions 50.x, 45.x and 40.x. Google Chrome works fine.

Here is a very simple test case: https://jsfiddle.net/MiikaH/nLptc67f/

Its also worth noting that while the issue can be reproduced on any "real" site with other content (indluding JSFiddle), it for some reason doesn't happen on empty HTML file containing the same code.

How to redo the bug:
1) Open the JSFiddle link above (https://jsfiddle.net/MiikaH/nLptc67f/)
2) Wait for the 16384x16384 pixel image to load so that the status box says "Ready".
Javascript now draws downscaled version of the image on the canvas


Actual results:

The canvas box remains empty. The context.drawImage() call didn't draw anything at all on the canvas.


Expected results:

The canvas box should display a downscaled 256x256 version of the gradient image.
Component: Untriaged → Canvas: 2D
Product: Firefox → Core
Our current max is 32k in either dimension and less than 500,000,000 bytes.  This one is 1GB, so we reject it.  See bug 1282074
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Priority: -- → P2
Resolution: --- → DUPLICATE
Whiteboard: [gfx-noted]
In this case canvas is just 256x256, only the image drawn on the canvas is larger. Also if the drawImage call is rejected because of its size how come the same test case works on an empty html file? (As mentioned in the main report)
You're right, I didn't read this well in detail.  It's the other limit that we're hitting here.  The image itself is 1GB, and our image cache is 1GB by default.  Which means it doesn't last in the cache long enough.  Changing image.mem.surfacecache.max_size_kb preference to a larger value makes this example work (after a browser restart.)

We can modify this bug to "deal with images that are larger than cache"?
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.