Closed
Bug 891986
Opened 11 years ago
Closed 11 years ago
Keep the source ArrayBuffer to a decodeAudioData call alive until the decoding is complete
Categories
(Core :: Web Audio, defect)
Core
Web Audio
Tracking
()
RESOLVED
FIXED
mozilla25
People
(Reporter: padenot, Assigned: padenot)
References
Details
(Whiteboard: [blocking-webaudio+][qa-])
Attachments
(5 files, 2 obsolete files)
No description provided.
Attachment #773408 -
Flags: feedback?(ehsan)
Comment 1•11 years ago
|
||
Comment on attachment 773408 [details] [diff] [review]
WIP, crashes somewhere, plus I have no idea what I'm doing
Review of attachment 773408 [details] [diff] [review]:
-----------------------------------------------------------------
This looks good to me, I can't imagine what you're doing wrong. Andrew, do you mind taking a look please?
Attachment #773408 -
Flags: feedback?(ehsan) → feedback?(continuation)
Comment 2•11 years ago
|
||
Can you include the crash stacks?
TRAVERSE and UNLINK need to visit CCed fields, like AudioContext, but that should only cause leaks, not crashes.
Clear mArrayBuffer in unlink and the destructor, call drop in the destructor. You aren't calling drop right now, so XPConnect will end up with a dangling pointer to the job object after it dies. Maybe that is the crash.
Updated•11 years ago
|
Attachment #773408 -
Flags: feedback?(continuation)
Assignee | ||
Comment 3•11 years ago
|
||
Assignee | ||
Comment 4•11 years ago
|
||
Assignee | ||
Updated•11 years ago
|
Attachment #773408 -
Attachment is obsolete: true
Assignee | ||
Comment 5•11 years ago
|
||
If I uncomment:
> NS_IMPL_CYCLE_COLLECTION_UNLINK(mArrayBuffer)
I get this, which I don't understand.
Comment 6•11 years ago
|
||
That crash is because you need to clear the JS pointer before you do DROP. That's really only to make the thing that checks if the clear has happened happy.
Comment 7•11 years ago
|
||
(In reply to Paul Adenot (:padenot) from comment #5)
> I get this, which I don't understand.
The UNLINK is templated, and the Heap<> stuff is pretty new, so there's no case for it. We may not actually have any cases for JS stuff, come to think of it...
Assignee | ||
Comment 8•11 years ago
|
||
If I uncomment:
> NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArrayBuffer)
I get this compile error.
Comment 9•11 years ago
|
||
JS pointers, like mArrayBuffer, are in TRACE, so the GC can use them, too. Then, in TRAVERSE, you need to add the line NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS to invoke the TRACE from the TRAVERSE. Sorry, I forgot about that part.
Assignee | ||
Comment 10•11 years ago
|
||
I don't have the crash anymore, and my testcase passes, but since I can't visit the field because it is not implemented, does that mean I leak?
Flags: needinfo?(continuation)
Comment 11•11 years ago
|
||
It should be Traversing mArrayBuffer via the Trace method, and unlinking it manually.
The leak problem I'd worry about is the other cycle-collected things that this class points to, like mContext. All of those need to be added to TRAVERSE and UNLINK, with the macros.
Flags: needinfo?(continuation)
Assignee | ||
Comment 12•11 years ago
|
||
So, I wanted to know if I leaked, so I fired up valgrind, and now it crashes during the collect, with this stack (only in valgrind, though, it is fine when running normally).
About the need to cycle collect all the other stuff going from the WebAudioDecodeJob, I have no idea.
Comment 13•11 years ago
|
||
For some reason, the WebAudioDecodeJob is reporting a refcount of 0 to the cycle collector. Is it being addrefed anywhere?
Comment 14•11 years ago
|
||
Hmm, so currently WebAudioDecodeJob's lifetime is managed explicitly. For hooking it up to CC, this object needs to be refcounted, which means that you cannot allocate it on the stack, put it in nsAutoPtr's, etc. This means that you need to change the consumers (AudioContext::CreateBuffer/DecodeAudioData, mDecodeJobs, etc.) and then you probably need to traverse and unlink the stuff that are cycle collected (such as mContext) as well.
Comment 15•11 years ago
|
||
Yup, that sounds right to me.
Assignee | ||
Comment 16•11 years ago
|
||
I don't crash anymore, valgrind does not complain (not sure if this is a
reliable tool for CC/GC work), and my testcase passes.
Attachment #775743 -
Flags: review?(continuation)
Assignee | ||
Updated•11 years ago
|
Attachment #774039 -
Attachment is obsolete: true
Comment 17•11 years ago
|
||
Comment on attachment 775743 [details] [diff] [review]
Keep the source ArrayBuffer to a decodeAudioData call alive until the decoding is complete. r=
Review of attachment 775743 [details] [diff] [review]:
-----------------------------------------------------------------
The CC stuff looks okay to me, aside from the callback stuff I mention below. Ehsan should review it, too, as I don't know anything about WebAudio. :)
::: content/media/webaudio/MediaBufferDecoder.cpp
@@ +24,5 @@
> #include "nsCxPusher.h"
>
> namespace mozilla {
>
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebAudioDecodeJob)
I think the two callbacks also need to be traversed and unlinked, because they are some kind of WebIDL-y thing.
Attachment #775743 -
Flags: review?(ehsan)
Attachment #775743 -
Flags: review?(continuation)
Attachment #775743 -
Flags: review+
Comment 18•11 years ago
|
||
Comment on attachment 775743 [details] [diff] [review]
Keep the source ArrayBuffer to a decodeAudioData call alive until the decoding is complete. r=
Review of attachment 775743 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/webaudio/MediaBufferDecoder.cpp
@@ +24,5 @@
> #include "nsCxPusher.h"
>
> namespace mozilla {
>
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebAudioDecodeJob)
Yes.
Attachment #775743 -
Flags: review?(ehsan) → review+
Updated•11 years ago
|
status-firefox24:
--- → affected
status-firefox25:
--- → affected
tracking-firefox24:
--- → ?
tracking-firefox25:
--- → ?
Whiteboard: [blocking-webaudio+]
Assignee | ||
Comment 20•11 years ago
|
||
Landed with the UNLINK and TRAVERSE macros for the callbacks.
https://hg.mozilla.org/integration/mozilla-inbound/rev/8352522283e4
Comment 21•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
Updated•11 years ago
|
Updated•11 years ago
|
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 22•11 years ago
|
||
Keywords: checkin-needed
Comment 23•11 years ago
|
||
Assuming no verification needed here. Please add the verifyme keyword and remove the [qa-] whiteboard tag to request verification.
Whiteboard: [blocking-webaudio+] → [blocking-webaudio+][qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•