Closed
Bug 1012386
Opened 11 years ago
Closed 11 years ago
Canvas2D's getImageData/putImageData causes memory leak with huge values for "heap-unclassified"
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
VERIFIED
FIXED
mozilla32
Tracking | Status | |
---|---|---|
firefox30 | --- | unaffected |
firefox31 | + | verified |
firefox32 | --- | verified |
People
(Reporter: till, Assigned: mattwoodrow)
References
()
Details
(Keywords: regression, Whiteboard: [MemShrink])
Attachments
(1 file)
954 bytes,
patch
|
jrmuizel
:
review+
Sylvestre
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
No description provided.
Reporter | ||
Comment 1•11 years ago
|
||
(Accidentally submitted the form, sorry.)
Getting a 2D Canvas's image data and putting it back in a requestAnimationFrame loop leaks huge amounts of memory. Permanently until the browser is restarted.
A script as simple as this demonstrates the issue:
function loop() {
context.putImageData(context.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
requestAnimationFrame(loop);
}
var context = document.getElementById('canvas').getContext('2d');
loop();
With a 1000*1000px canvas, that leaks a few GB of memory within seconds, as the linked URL demonstrates.
Happens on Aurora for, but not on Beta.
Keywords: regression
Summary: Canvas2D's getImageData/putImageData causes memory leak with huge values for "heap unclassified → Canvas2D's getImageData/putImageData causes memory leak with huge values for "heap-unclassified"
Whiteboard: [MemShrink]
Updated•11 years ago
|
Flags: needinfo?(matt.woodrow)
Assignee | ||
Comment 2•11 years ago
|
||
Assignee: nobody → matt.woodrow
Attachment #8424522 -
Flags: review?(jmuizelaar)
Flags: needinfo?(matt.woodrow)
Comment 3•11 years ago
|
||
Comment on attachment 8424522 [details] [diff] [review]
Release the image
Review of attachment 8424522 [details] [diff] [review]:
-----------------------------------------------------------------
::: gfx/2d/DrawTargetCG.cpp
@@ +1252,5 @@
> }
> CGContextDrawImage(mCg, flippedRect, image);
>
> CGContextRestoreGState(mCg);
> + CGImageRelease(image);
Is there a a preferred ordering between CGContextRestoreGState and CGImageRelease? Are they fully independent, or should one always come before the other?
Comment 4•11 years ago
|
||
They're fully independent. The image doesn't remember which context it was painted into, and the context has already finished painting the image so it has probably already forgotten about it, too. The image can be released at any point after the CGContextDrawImage call where it was used.
Comment 5•11 years ago
|
||
Comment on attachment 8424522 [details] [diff] [review]
Release the image
Review of attachment 8424522 [details] [diff] [review]:
-----------------------------------------------------------------
::: gfx/2d/DrawTargetCG.cpp
@@ +1252,5 @@
> }
> CGContextDrawImage(mCg, flippedRect, image);
>
> CGContextRestoreGState(mCg);
> + CGImageRelease(image);
They should be independent.
Attachment #8424522 -
Flags: review?(jmuizelaar) → review+
Assignee | ||
Comment 6•11 years ago
|
||
Comment 7•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Assignee | ||
Updated•11 years ago
|
status-firefox31:
--- → affected
status-firefox32:
--- → fixed
tracking-firefox31:
--- → ?
Flags: needinfo?(matt.woodrow)
Assignee | ||
Updated•11 years ago
|
status-firefox30:
--- → unaffected
Assignee | ||
Comment 9•11 years ago
|
||
Comment on attachment 8424522 [details] [diff] [review]
Release the image
[Approval Request Comment]
Bug caused by (feature/regressing bug #): Bug 990854
User impact if declined: Memory leak with canvas putImageData
Testing completed (on m-c, etc.): Locally confirmed it fixes the memory leak.
Risk to taking this patch (and alternatives if risky): Very low risk.
String or IDL/UUID changes made by this patch: None
Attachment #8424522 -
Flags: approval-mozilla-aurora?
Comment 10•11 years ago
|
||
I just ran into this in Nightly (32.0a1 (2014-05-21), not sure if this patch has made it in yet). It appears that its due entirely to putImageData. See this fiddle: http://jsfiddle.net/vHzmW/2/
var canvas = document.querySelector('canvas'),
ctx = canvas.getContext('2d'),
imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
setInterval(function () {
ctx.putImageData(imageData, 0, 0);
}, 0)
Updated•11 years ago
|
Updated•11 years ago
|
Attachment #8424522 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 11•11 years ago
|
||
Comment 12•11 years ago
|
||
Reproduced in nightly 2014-05-18, OS X 10.9.2.
Verified fixed 32.0a1 (2014-05-26).
Status: RESOLVED → VERIFIED
Comment 13•11 years ago
|
||
"heap-unclassified" values stay low now.
Verified fixed FF 31b3 OS X 10.8.5.
Keywords: verifyme
You need to log in
before you can comment on or make changes to this bug.
Description
•