Drawing some gradients on <canvas> seems to cause memory leak
Categories
(Core :: Graphics: Canvas2D, defect, P3)
Tracking
()
People
(Reporter: v910JQK, Unassigned)
References
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Steps to reproduce:
I'm using Firefox 69.0.1 (x86_64) on Windows10.
The problem happened when I try to create a simple HSL color picker for web development. Open the uploaded sample HTML file, it renders a <canvas> and a 'Draw' button. Click the button many times, you can see the memory used by Firefox grows rapidly.
Actual results:
It seems that drawing a slice plane of the HSL color cylinder on <canvas> could cause memory leak. This problem may have something to do with CanvasRenderingContext2D.createLinearGradient()
Expected results:
Chromium does not have the same problem.
Actually the garbage collector (? or other memory management tech) works when the used memory reaches a big amount. But it is too late. The browser tab may crash before the GC starting to work.
Comment 2•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 3•5 years ago
|
||
Can you upload the contents of about:support as a text file?
Comment 5•5 years ago
•
|
||
Happens in nightly as well, both with webrender and non-webrender.
Comment 6•5 years ago
|
||
The memory system seems to clean up, but only after switching away and back to the tab. As far as I can see, memory logs don't show major differences between high and low usage.
Attached memory reports. (Content tab PID=23056)
Comment 7•5 years ago
|
||
Comment 8•5 years ago
|
||
Updated•5 years ago
|
Comment 10•5 years ago
|
||
(In reply to Kris Taeleman (:kris/kris) from comment #9)
Lee, can you take a look?
My suspicion is this has to do with gfx/thebes/gfxGradientCache, wherein when we purge the caches all is fine, but otherwise we may be too aggressively caching gradients. It looks like we haven't really evaluated whether the amount of caching there even made sense since this code was written originally by Andreas Gal.
This might actually be a good bug for you to check out if there are any simple tweaks we could make here with the nsExpirationTracker usage, like lowering the timer interval and/or number of generations to see if it found a less obnoxiously memory hungry equilibrium. Would you be willing to dig further?
Updated•5 years ago
|
Updated•5 years ago
|
Comment 12•4 years ago
|
||
This probably causes a massive memory issue when using the Falstad circuit simulator: http://falstad.com/circuit/
Particularly bad example: https://tinyurl.com/yh22cd7n
Updated•4 years ago
|
Comment 13•4 years ago
|
||
In the latest Beta (89), I landed a change to limit the number of cached gradients, because of the large amount of memory the related Direct2D objects hold.
If you would be able to retest these issues on Beta that would be great.
https://www.mozilla.org/en-US/firefox/channel/desktop/
Comment 14•4 years ago
|
||
Beta 89 seems to have fixed the problem, thank you!
Memory runaway in the circuit simulator solved.
Comment 15•4 years ago
|
||
(In reply to Jaroslav Malec from comment #14)
Beta 89 seems to have fixed the problem, thank you!
Memory runaway in the circuit simulator solved.
Thanks for confirming, I'm going to close this as fixed.
Updated•4 years ago
|
Description
•