Jump to content

Trying to play audio on iOS 5 kills performance


tackle
 Share

Recommended Posts

Using Safari or Chrome on iOS 5.1.1, an iPhone 4S, I'm trying to play audio.

In a simple test case with 60 fps, trying to play a ~10kb wav file kills the performance instantly and puts it to ~2-3 fps and it stays there.

 

If the main Phaser sound engine is muted before playing, this still results in this performance loss.

 

In my game I'm working on, I've resorted to user agent sniffing in all calls to sound.play(), making sure I don't call any sound plays on iOS 5 at all.

 

Would you try another solution? What I'm doing now works basically and it's a lost cause adhering to ALL os's and devices but since I have this in my arsenal I might as well adjust to it.

Link to comment
Share on other sites

Does it work if you use mp3 or m4a? Could you provide an example? I've created audio in iOS games before using mp3 and it appears to work fine.

 

Sure, I've set one up here:

http://waikiki.macklin.se/livefolder/audiotest/

 

Whichever I try to play on both Safari and Chrome on my iPhone with iOS 5.1.1, it jumps from 60fps to 5-7 fps and stays there.

Just one play will do it.

 

All except the OGG one which doesn't do anything, which is expected. That would be relevant when digging through the code. I've been looking at the source but I'm lost when it comes to finding where it actually triggers and fires the audio tag play. I assume it's the audio element tag in this case, since iOS5 doesn't have webaudio.

 

If you have iOS 5 anywhere and try that page, please let me know how it turns out!

Link to comment
Share on other sites

Hmm, odd. I can't see anything wrong with the code (I kinda expected a problem like the play call being done in the update function or something silly) and it works fine on iOS 7.1 on my iPhone 4S. Don't have an iOS 5 device to test it on but I'd probably go so far as to say that it'd be best to write it off as unsupported. I would've thought m4a would be smooth as silk on an Apple device but clearly the issue isn't the format...

 

Weirdly, I'm only getting 10fps on my laptop in Chrome, even without playing a sound.

Link to comment
Share on other sites

Yeah you're probably right.

 

The big issue is that even if you've muted the game, it still slows down like that.

Also, once it's slowed down, it's staying there. So you can't mute it after the fact to mitigate the problem.

 

Also, during my testing, I've had some random firing of the actual sound in my phone. As in, I did hear the sound, but maybe 30 seconds from the press of the button.

 

So, for now, my solution is to just make sure it's not iOS before I try to play a sound.

Link to comment
Share on other sites

iOS5 doesn't support web audio, so falls back to the supremely slow html audio tag - so make sure you're using a single audio sprite, have preloaded and decoded it and have padded it out properly with lots of spacing between samples. Or just ignore iOS5 (as iOS6+ supports web audio fully, which doesn't have these issues), which is what I would do, as no-one uses it any more. It hasn't featured significantly in any of our games stats for a good while now.

Link to comment
Share on other sites

iOS5 doesn't support web audio, so falls back to the supremely slow html audio tag - so make sure you're using a single audio sprite, have preloaded and decoded it and have padded it out properly with lots of spacing between samples. Or just ignore iOS5 (as iOS6+ supports web audio fully, which doesn't have these issues), which is what I would do, as no-one uses it any more. It hasn't featured significantly in any of our games stats for a good while now.

 

Is there a way to disable the HTML audio tag use in Phaser?

I'm all for pushing development forward and only use WebAudio. Disabling HTML audio tag would solve both that and my problem.

 

Or I suppose I could just check the Device for webAudio API availability and if it's not there, just don't call the .play() on my sounds.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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