Leak calling AudioContext on removed iframe

RESOLVED FIXED in Firefox 20

Status

()

defect
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: jruderman, Assigned: mccr8)

Tracking

(Blocks 2 bugs, {memory-leak, regression, testcase})

Trunk
mozilla21
x86_64
macOS
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox19 unaffected, firefox20 fixed, firefox21 fixed)

Details

(Whiteboard: [MemShrink])

Attachments

(2 attachments, 1 obsolete attachment)

Reporter

Description

7 years ago
Posted file testcase
1. Set:
     user_pref("media.webaudio.enabled", true);
2. Run a debug build of Firefox with XPCOM_MEM_LEAK_LOG=2
3. Load the testcase
4. Quit Firefox

Result: trace-refcnt reports that a bunch of stuff leaked.

Updated

7 years ago
Blocks: webaudio
Assignee

Comment 1

7 years ago
I can do some initial analysis of what is happening here, if you'd like, Ehsan. Just assign it to me in that case.
Whiteboard: [MemShrink]
Assignee

Comment 2

7 years ago
(By that, I mean run the CC logging stuff...)

Comment 3

7 years ago
Never turn down an offer to help, said a wise man once.  :-)
Assignee: nobody → continuation

Comment 4

7 years ago
(FWIW, this _might_ have something to do with bug 814789.)
Assignee

Comment 5

7 years ago
Yeah, just looking at the patch I'd guess mAudioContexts needs to be added to a Traverse and Unlink function. ;)

Comment 6

7 years ago
(In reply to Andrew McCreight [:mccr8] from comment #5)
> Yeah, just looking at the patch I'd guess mAudioContexts needs to be added
> to a Traverse and Unlink function. ;)

Indeed.  If I had a penny for every time I missed something this simple with the CC.  :(
Assignee

Comment 7

7 years ago
Posted patch traverse mAudioContexts (obsolete) — Splinter Review
This fixes the leak for me.  I'm not sure what the right way to turn the test case into a Mochitest or crash test thing is.
Assignee

Comment 8

7 years ago
Oh, right, I should unlink it, too.

Comment 9

7 years ago
You want a mochitest for now so that you can enable the webaudio pref for now.
Assignee

Comment 10

7 years ago
The general rule of thumb is that if you add a ref counted field to a cycle collected class, you want to think very carefully about if you should add something to the Traverse and Unlink functions. :)

I reordered the fields a bit, but the only change should be that mAudioContexts gets added.
Attachment #701969 - Attachment is obsolete: true
Attachment #701993 - Flags: review?(ehsan)

Comment 11

7 years ago
(In reply to Andrew McCreight [:mccr8] from comment #10)
> Created attachment 701993 [details] [diff] [review]
> traverse+unlink mAudioContexts
> 
> The general rule of thumb is that if you add a ref counted field to a cycle
> collected class, you want to think very carefully about if you should add
> something to the Traverse and Unlink functions. :)

Yeah, and people keep forgetting to do it.  :(  Which is why I filed bug 570416 which was duped against bug 423032 back in the day.  Did that work ever get anywhere?  Dehydra is obsolete as I understand things...

Comment 12

7 years ago
Comment on attachment 701993 [details] [diff] [review]
traverse+unlink mAudioContexts

Review of attachment 701993 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks again for taking this!
Attachment #701993 - Flags: review?(ehsan) → review+
Assignee

Comment 13

7 years ago
> Did that work ever get anywhere?  Dehydra is obsolete as I understand things...

I worked on it for awhile, but there were too many weird special cases to make it useful.  It did find a few minor problems.

Comment 15

7 years ago
Comment on attachment 698892 [details]
testcase

><!DOCTYPE html>
><html>
><head>
><script>
>
>function boom()
>{
>  var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
>  document.body.appendChild(iframe);
>  var frameWin = iframe.contentWindow;
>  frameWin.mozAudioContext;

So I don't understand this part of the test case.  Will this create a new mozAudioContext object?  This just looks like a property access to me...
The testcase as-is doesn't seem to cause the AudioContext constructor to be called here. With () appended to this line, it works as expected.

I'm also super happy to report that this testcase is the first time my tool (bug 704240) was able to correctly report a leak (had to fix a couple bugs that this uncovered). Here's what I'm seeing right now in my about:refgraph page (of course, this is without the present patch applied):

type name: mozilla::dom::AudioContext
address: 0x7f99f6276560
size: 88 bytes
traversed edge
    type name: mozilla::dom::AudioDestinationNode
    address: 0x7f99f62776e0
    size: 88 bytes
    traversed edge
        type name: mozilla::dom::AudioContext
        address: 0x7f99f6276560
        size: 88 bytes
        traversed edge
            type name: mozilla::dom::AudioDestinationNode
            address: 0x7f99f62776e0
            size: 88 bytes
        traversed edge
            type name: nsGlobalWindow
            address: 0x7f99fabe3c40
            size: 1224 bytes
traversed edge
    type name: nsGlobalWindow
    address: 0x7f99fabe3c40
    size: 1224 bytes
    NON-traversed edge
        type name: 
        address: 0x7f99f3bc8940
        size: 260 bytes
    traversed edge
        type name: nsPrincipal
        address: 0x7f99f3cfeb00
        size: 80 bytes
        NON-traversed edge
            type name: nsStandardURL
            address: 0x7f99f9722d40
            size: 264 bytes
    NON-traversed edge
        type name: 
        address: 0x7f99f7524720
        size: 24 bytes
        NON-traversed edge
            type name: mozilla::dom::AudioContext
            address: 0x7f99f6276560
            size: 88 bytes
            *** CYCLE NOT TRAVERSED BY THE CC! ***
(snipped.)
Assignee

Comment 17

7 years ago
> I'm also super happy to report that this testcase is the first time my tool (bug 704240) was able to correctly report a leak 

Nice!

Comment 18

7 years ago
I pushed a follow-up to fix the test case, as I'm pretty sure that it's wrong.

https://hg.mozilla.org/integration/mozilla-inbound/rev/7b698ca72776
Assignee

Comment 19

7 years ago
Well, I just cut and pasted Jesse's test case. Hopefully the new one also leaks without the patch. ;)
Comment 16 says it does at least create a non-cycle-collected cycle ;-)
https://hg.mozilla.org/mozilla-central/rev/0ff42bab2f66
https://hg.mozilla.org/mozilla-central/rev/7b698ca72776
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Assignee

Comment 22

7 years ago
Comment on attachment 701993 [details] [diff] [review]
traverse+unlink mAudioContexts

[Approval Request Comment]
Bug caused by (feature/regressing bug #): 814789
User impact if declined: remote chance of leaks, but probably nothing without the webaudio pref turned on.
Testing completed (on m-c, etc.): m-c
Risk to taking this patch (and alternatives if risky): very low
String or UUID changes made by this patch: none
Attachment #701993 - Flags: approval-mozilla-aurora?
Comment on attachment 701993 [details] [diff] [review]
traverse+unlink mAudioContexts

Low risk, comes with test, approving since it's so early in Aurora.
Attachment #701993 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+

Updated

7 years ago
Keywords: checkin-needed
Whiteboard: [MemShrink] → [MemShrink][land-on-aurora]

Updated

7 years ago
Keywords: checkin-needed

Updated

7 years ago
Keywords: regression

Comment 26

6 years ago
Mass moving Web Audio bugs to the Web Audio component.  Filter on duckityduck.
Component: Video/Audio → Web Audio
You need to log in before you can comment on or make changes to this bug.