Closed Bug 857653 Opened 8 years ago Closed 8 years ago
Audio channel agents leak the world
In bug 844323 I'm writing unit tests which exercise the process priority manager. As part of this effort, I modified the audio channel agent code in nsHTMLMediaElement to be controlled by a pref, instead of #ifdef B2G. I then flip this pref in my test. I discovered that flipping this pref and playing an <audio> is enough to leak a page until shutdown. Looking at the audio code, an AudioChannelAgent holds a strong reference to its <audio> element. So this means that the window which contains the <audio> can be GC'ed only once the AudioChannelAgent is destroyed. Leak the AudioChannelAgent and you leak its window. It's not clear to me exactly how we're leaking the AudioChannelAgent, but it's happening somehow. I have the testcase, so I'll write a fix.
Assignee: nobody → justin.lebar+bug
This fixes it for me. There must have been a cycle somewhere. Even if there isn't a cycle, holding a weak ref seems sane here; we don't want the AudioChannelAgent to keep the node alive, I think.
Blocks a blocker. This is also a pretty bad leak.
blocking-b2g: --- → tef?
> This fixes it for me. To be clear, we no longer leak the window or the AudioChannelAgent with this patch.
Comment on attachment 732965 [details] [diff] [review] Patch, v1 The IDL should document that the passed-in object needs to implement nsISupportsWeakReference to actually work. r=me with that
Attachment #732965 - Flags: review?(bzbarsky) → review+
And how about we make nsHTMLMediaElement implement nsISupportsWeakReference while we're at it? Apparently this is not tested so well...
> And how about we make nsHTMLMediaElement implement nsISupportsWeakReference All elements implement nsISupportsWeakReference, via a tearoff. See http://hg.mozilla.org/mozilla-central/file/f20b0ce9e528/content/base/src/FragmentOrElement.cpp#l1698
Ah, perfect. Thanks.
blocks a blocker
blocking-b2g: tef? → tef+
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Hi Justin, I found that the code as below will return null for callback pointer. Could you help to take a look? Thanks. And this will cause media element malfunctional on AudioChannelService. http://mxr.mozilla.org/mozilla-central/source/dom/audiochannel/AudioChannelAgent.cpp#148
Hi Justing, This is my fault on Bug 859244 - nsIAudioChannelAgentCallback didn't be added into nsHTMLMediaElement::QueryInterface().
Depends on: 859244
Ah, I have unit tests for this, but I haven't run them on the b2g branch. Thanks for catching this!
You need to log in before you can comment on or make changes to this bug.