Multiple songs aren't playing due to memory
Closed this issue · 8 comments
I tried to load around eight audios in 8 players with average song duration of 3minutes. But the audio stops in between.
This should be something to do with the memory since i tried same with same 8 players but with fewer duration. it worked fine.
Is there any error message? If there is not enough memory, then there should be some.
No, there is no error message in the console.
When is the audio stopping exactly? At the same point?
Not exactly. For example
- If i create around 6 song players with 3 minutes duration each. The players doesn't even play.
- If 8 song players with around 20 seconds duration each. It does play well.
But the same does not play at all when 16 players are created with 20-30 seconds. But trying to play only 8 players.
And again no console errors for any of these.
I would like to understand if there's a memory allocation limitation?
Hi @gaborszanto ,
We have followed this sample and hosted the reproduceable sample here.
To reproduce:
- Go to the site.
- Start -> 16 song buttons are presented -> Clicking on each one of them will play that song
- It can be noticed that the song cuts off when around 8 songs are playing at the same time and no errors in the console log.
NOTE: We have also observed that the ability to play multiple songs decreases against no of players loaded at the time.
Thanks.
Definitely doesn’t seem to be connected to memory. I log out the total byteLength of the buffers of all playing players and then tried with a different file of 3x the size and it was still stopping after the same number of players.
Initially it was always on the 10th player, then a little while later always on the 9th player, then always on the 8th player.
Each of these buttons calls seek(0) and play() on their respective player
Screen.Recording.2021-05-12.at.16.50.25.mov
Your code erases the contents of the outputBuffer when a player doesn't return with audio. Erase the contents of the outputBuffer only at the very end of processAudio.
Thanks @gaborszanto for your response. But changing it to the end of the file still doesn't resolve the issue:
`
processAudio(inputBuffer, outputBuffer, buffersize, parameters) {
let mix = false;
Object.keys(players).forEach((key, idx) => {
const player = players[key];
const hasAudioOutput = player.processStereo(
outputBuffer.pointer,
mix,
buffersize,
1
);
mix |= hasAudioOutput;
});
if (!mix) {
for (let n = 0; n < buffersize * 2; n++) outputBuffer.array[n] = 0;
}
}
`