[Webkit-unassigned] [Bug 189337] decodeAudioData memory garbage collected too late
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Sep 11 11:27:40 PDT 2018
https://bugs.webkit.org/show_bug.cgi?id=189337
--- Comment #7 from ae at seven.systems ---
(In reply to Jer Noble from comment #6)
> (In reply to ae from comment #5)
> > (In reply to Jer Noble from comment #4)
> > > I'm
> > > guessing that there's an AudioBufferSourceNode which is retaining the
> > > decoded AudioBuffer and that the ABSN is being kept alive long after its
> > > playback has completed.
> >
> > As I said, I do not play back the buffer. I just use it for generating an
> > overview. Here's the complete code (it's Tea, our in-house programming
> > language that transcompiles to JS, but I hope it's readable enough!)
> >
> > HTTP.get("sevenapp:///#{encodeURIComponent(@playingPath)}", (audioData) =>
> > if not audioData?
> > @clearPeaks()
> > <-
> > Audio.context.decodeAudioData(audioData, (buffer) =>
> > if not buffer?
> > @clearPeaks()
> > <-
> > samples = buffer.getChannelData(0)
>
> Unless your in-house transpiler adds scoping statements to these variables,
> your going to be setting window.samples to a large Float32Array. If your
> in-house transpiler /is/ adding scoping statements, it would be much more
> useful to post the transpiled source.
Oh sorry, of course it makes 'samples' local (var samples), I'm just so used to this that I forgot. Here's the transpiled code (not too readable):
getPeaks: function() {
element('player-peaks').classList.remove('show');
if (this.peaks[this.playingPath] != null) {
timer(0.5, (function(_this) {
return function() {
_this.renderPeaks();
};
})(this));
return;
}
if (Audio.context == null) {
this.needPeaksOnResume = true;
return;
}
this.needPeaksOnResume = false;
HTTP.get("sevenapp:///" + (encodeURIComponent(this.playingPath)), (function(_this) {
return function(audioData) {
if (audioData == null) {
_this.clearPeaks();
return;
}
Audio.context.decodeAudioData(audioData, function(buffer) {
var frame, i, index, j, peaks, ref, ref1, ref2, samples, step, sum;
if (buffer == null) {
_this.clearPeaks();
return;
}
samples = buffer.getChannelData(0);
step = buffer.sampleRate / 30;
_this.peaks[_this.playingPath] = peaks = [];
for (frame = i = 0, ref = samples.length / step; 0 <= ref ? i < ref : i > ref; frame = 0 <= ref ? ++i : --i) {
sum = 0;
for (index = j = ref1 = frame * step, ref2 = (frame + 1) * step; j < ref2; index = j += 256) {
if (index >= samples.length) {
break;
}
sum += Math.abs(samples[Math.floor(index)]);
}
sum /= step / 256;
peaks.push(sum);
}
_this.renderPeaks();
});
};
})(this));
},
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180911/ebce43d6/attachment.html>
More information about the webkit-unassigned
mailing list