Jump to content

Game freeze caused by audio playback

Michel (Starnut)

Recommended Posts

Hey guys,


has anyone encountered glitches or even complete game freezes based on audio playback with Phaser 1.1.4?


I'm playing back short WAVs in the course of my game and every once in a while the game freezes up completely for half a second or so on an iPhone 4S iOS7. It's not as tremendous on an iPhone 5 with iOS7 but still glitching. Feels like a garbage collector is getting to work there.


I was able to track the issue back to audio playback since no freeze appears if I turn it off. Also, I tested on my iPad1 and (apart from the fact that Safari under iOS 5.1.1 doesn't manage do actually play the sound) I could see the game slowing down every time sound playback was triggered. The whole game runs smoothly with sound playback turned off, though.


Here is the code I use:

// create sounds and stack themthis.sounds.push(this.game.add.audio("someAudio", 1, false));// ... later in the game, play themthis.sounds[i].play('', 0, volume, false, true);

Am I missing something? Is there a proper way to reuse sounds without filling up memory?

Link to comment
Share on other sites

Thanks, guys. Don't get me wrong, though: the wav samples do play fine on iOS 6/7 just the mem fills up apparently. But I'll go with m4a then. Which format is best for android devices? Ogg?

@rich: actually I chose wav cause you mentioned in some thread that it's great for short samples because it doesn't need decoding. Any bit rates you can recommend? Or is it just try&error? Have little experience with audio.

Link to comment
Share on other sites

I still mostly use wav for short sounds outside of iOS as it seems to work great on Android. On iOS I encode to m4a though, anything possible to help reduce decoding time really. It's definitely not "normal" for the game to pause like that though, so it must be working overtime doing something (decoding audio possibly)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...