Bug 1296275 - Be better about exposing to active js in AudioBuffer::StealJSArrayDataIntoSharedChannels(). r=karlt draft
authorAndrew McCreight <continuation@gmail.com>
Mon, 29 Aug 2016 15:03:42 -0700
changeset 406927 74062157e6b0bfc4b4bc350c31c559b4625b39fe
parent 406926 1e6ee584eec3866b118348aee45d8c14c520437c
child 529798 0a8978f29e687659e1cc8116a11afd5378c84aa0
push id27881
push userbmo:continuation@gmail.com
push dateTue, 30 Aug 2016 00:53:46 +0000
reviewerskarlt
bugs1296275
milestone51.0a1
Bug 1296275 - Be better about exposing to active js in AudioBuffer::StealJSArrayDataIntoSharedChannels(). r=karlt MozReview-Commit-ID: GC8sncFJlPS
dom/media/webaudio/AudioBuffer.cpp
--- a/dom/media/webaudio/AudioBuffer.cpp
+++ b/dom/media/webaudio/AudioBuffer.cpp
@@ -366,22 +366,28 @@ AudioBuffer::StealJSArrayDataIntoSharedC
 
   // "2. Detach all ArrayBuffers for arrays previously returned by
   // getChannelData on this AudioBuffer."
   // "3. Retain the underlying data buffers from those ArrayBuffers and return
   // references to them to the invoker."
   RefPtr<ThreadSharedFloatArrayBufferList> result =
     new ThreadSharedFloatArrayBufferList(mJSChannels.Length());
   for (uint32_t i = 0; i < mJSChannels.Length(); ++i) {
+    if (mJSChannels[i]) {
+      JS::ExposeObjectToActiveJS(mJSChannels[i]);
+    }
     JS::Rooted<JSObject*> arrayBufferView(aJSContext, mJSChannels[i]);
     bool isSharedMemory;
     JS::Rooted<JSObject*> arrayBuffer(aJSContext,
                                       JS_GetArrayBufferViewBuffer(aJSContext,
                                                                   arrayBufferView,
                                                                   &isSharedMemory));
+    if (arrayBuffer) {
+      JS::ExposeObjectToActiveJS(arrayBuffer);
+    }
     // The channel data arrays should all have originated in
     // RestoreJSChannelData, where they are created unshared.
     MOZ_ASSERT(!isSharedMemory);
     auto stolenData = arrayBuffer
       ? static_cast<float*>(JS_StealArrayBufferContents(aJSContext,
                                                         arrayBuffer))
       : nullptr;
     if (stolenData) {