Bug 106621
Summary: | Web Audio Api noteoff/stop is not releasing memory - crash | ||
---|---|---|---|
Product: | WebKit | Reporter: | Ladislav Nevery <neuralll> |
Component: | Web Audio | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | crogers |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
Ladislav Nevery
Large or small. oneshot sources are not releasing buffers and will eat whole ram.
unfortunately there is no way to do it manually like it is in webgl right now.
following sample crashes webkit both mobile and dektop.as result of memory depletion ?
current ipad2 mobile safari ios 6.0.1 crash after 8 oneshots played.
current chrome 24.0.1312.52m crash after 17 oneshots played.
var context = new webkitAudioContext();
var total=0;
function onTouchStart(){
setInterval(function(){
total+=10;
var source = context.createBufferSource();
source.connect(context.destination);
source.buffer=context.createBuffer(1, 10*1024*1024, context.sampleRate);
source.noteOn(0);
source.noteOff(0); // acording to w3c spec resources should be deleted immediately.
console.log(total,'mb');
},1000);
}
document.addEventListener( "touchstart", onTouchStart );
document.addEventListener( "click", onTouchStart );
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Chris Rogers
(In reply to comment #0)
> Large or small. oneshot sources are not releasing buffers and will eat whole ram.
> unfortunately there is no way to do it manually like it is in webgl right now.
> following sample crashes webkit both mobile and dektop.as result of memory depletion ?
> current ipad2 mobile safari ios 6.0.1 crash after 8 oneshots played.
> current chrome 24.0.1312.52m crash after 17 oneshots played.
>
>
> var context = new webkitAudioContext();
> var total=0;
>
> function onTouchStart(){
> setInterval(function(){
> total+=10;
> var source = context.createBufferSource();
> source.connect(context.destination);
> source.buffer=context.createBuffer(1, 10*1024*1024, context.sampleRate);
It's very unusual to create a "new" distinct buffer for playing each sound. It's much better to
create a single buffer, then use the same one for each AudioBufferSourceNode.
This is a very artificial test which creates very huge buffers, which will of course eat up memory very quickly.
It's also possible to do this in a number of other ways such as creating huge Float32Arrays, etc.
> source.noteOn(0);
> source.noteOff(0); // acording to w3c spec resources should be deleted immediately.
> console.log(total,'mb');
> },1000);
> }
>
> document.addEventListener( "touchstart", onTouchStart );
> document.addEventListener( "click", onTouchStart );