Jump to content

Occasionally iPad Mini 1 (iOS 8.3, Mobile Safari) plays audio at half speed


claycr4ne
 Share

Recommended Posts

Hi all,

I just upgraded the Phaser version of my game from 2.1.2 to 2.2.2. I did this because I was experiencing many, many issues playing the game on iPad Mini 1 (iOS 8.3, Mobile Safari). Now, although the game works a bit more fluently, I noticed a strange issue: sometimes when I start the game by doing a clean start by clearing cache all the audio starts to play at half speed. It's like everything is in slow motion except graphics. Do you have any idea what could be causing this?

 

To play audio, I first load them in my Preload-state like this:

this.load.audio('menuMusic', ['assets/audio/music/MenuMusic.ogg', 'assets/audio/music/MenuMusic.m4a']);

I also make sure that the audio file has been decoded before I start my Main Menu -state.

 

When audio starts play at half speed, it's not only a single audio file but every other file as well, including all SFXs.

 

This hasn't happened using PC or Android mobile devices. Also my iPad 2 (which should have the same specs as iPad Mini 1) plays the game flawlessly. The iPad 2 is running the same iOS version 8.3.

 

This problem doesn't usually repeat if I press the update button of the browser and let the game start all over again.

 

 

Link to comment
Share on other sites

I'd like to add that it's not happening only on this particular iPad Mini 1. I have two of them and it happens on both devices.

 

The game is also running on WebGL. I've tried using canvas but it kicks the frames-per-second from 30-40 down to about 10.

 

Sometimes iPad Mini 1 also crashes either in preload or in the beginning of some random state. It's difficult to track down because the crash always occurs in a different time. I've also noticed that sometimes it doesn't load a random file during preload (Phaser.Loader error loading file *) which makes the game crash eventually.

 

So many crashes, and all these are happening only using iPad Mini 1.  :( Sadly, my game is going to be played at schools and all the students there are using iPad Mini 1s.

Link to comment
Share on other sites

Yes, I've used Google's Dev tools to monitor my game's memory usage. In fact I previously had some memory leaks because in my game I load dozens of images in every new level and I wasn't removing them from cache before. Now the memory usage stays steady, but I still have to say that my game is quite heavy. By this I mean that I have tens of different graphic files (in addition to level-specific images), some of them are quite big, and I also have tens of sound files. I'm not using texture atlases yet so maybe they could make an improvement?

Even though my game would take a huge place from memory I'm still wondering why it makes the audio play at half speed. It plays like in 50% tempo. This didn't ever happen in Phaser 2.1.2.

Link to comment
Share on other sites

If Safari just randomly crashes back to the home screen with no warning then it has run out of memory. This is almost exclusively the cause of it. Texture Atlases will help massively here - it's not about the file sizes, it's about the image dimensions.

 

As for the audio issue yes I have seen this happen sometimes as well, usually when iPad is under heavy load, and once it starts it never stops until a refresh. I've yet to find a cause for it, but it's not limited to Phaser, I've seen it happen on lots of other (non Phaser) games and sites, but have never found an exact cause, sorry.

Link to comment
Share on other sites

I'm wondering if it might be to do with the audio context being locked into a certain playback rate. For you the audio plays half speed, for me I was hearing it run around twice speed - so I'm now thinking the audio context is locked at the rate the SoundManager sets when touch unlocking it (which is 22Hz):

            var buffer = this.context.createBuffer(1, 1, 22050);            this._unlockSource = this.context.createBufferSource();            this._unlockSource.buffer = buffer;            this._unlockSource.connect(this.context.destination);

The update loop then checks the playing state, and if ok it nulls the source:

            this._unlockSource = null;

Most of the time this is fine and works flawlessly. But now I'm thinking maybe there is a delay when nulling the source and if you try and do too much through the context, too soon, it might get locked into place. Sadly this is extremely hard for me to test here as I'd need a clear example of if happening all the time :(

Link to comment
Share on other sites

Btw I also have audio issue exclusively on Ipad Mini 1. Main music theme doesn't loop.

 

It works on other ios and android devices, even on iPhone 4 (which is very similar to iPad Mini 1).

 

But not on Mini. It just stop playing after 1st time, no crashing, no errors etc.

 

Audio file ~1.9MB, m4a

Link to comment
Share on other sites

If Safari just randomly crashes back to the home screen with no warning then it has run out of memory. This is almost exclusively the cause of it. Texture Atlases will help massively here - it's not about the file sizes, it's about the image dimensions.

 

As for the audio issue yes I have seen this happen sometimes as well, usually when iPad is under heavy load, and once it starts it never stops until a refresh. I've yet to find a cause for it, but it's not limited to Phaser, I've seen it happen on lots of other (non Phaser) games and sites, but have never found an exact cause, sorry.

 

When my iPad Mini 1 crashes it only says something like "A problem occured with this webpage so it was reloaded." It doesn't go back to home screen but I guess this is the same case? At least when my iPad 2 crashed when I had memory leaks it did the same thing. It's just strange that with iPad Mini 1 it sometimes happens during preload and sometimes it lets me play a couple of levels before it happens.

 

Gotta try putting all my graphics into texture atlases next, then. Maybe it will help. Thanks for the tips!

 

Luckily this audio issue happens quite rarely.

Link to comment
Share on other sites

I'm wondering if it might be to do with the audio context being locked into a certain playback rate. For you the audio plays half speed, for me I was hearing it run around twice speed - so I'm now thinking the audio context is locked at the rate the SoundManager sets when touch unlocking it (which is 22Hz):

            var buffer = this.context.createBuffer(1, 1, 22050);            this._unlockSource = this.context.createBufferSource();            this._unlockSource.buffer = buffer;            this._unlockSource.connect(this.context.destination);

The update loop then checks the playing state, and if ok it nulls the source:

            this._unlockSource = null;

Most of the time this is fine and works flawlessly. But now I'm thinking maybe there is a delay when nulling the source and if you try and do too much through the context, too soon, it might get locked into place. Sadly this is extremely hard for me to test here as I'd need a clear example of if happening all the time :(

 

I tested this audio thing a few times more and for me it seems to happen only in my game's version which runs in Phaser 2.2.2. This hasn't happened yet with Phaser 2.1.2. So I'm wondering if there are any differences in the way SoundManager works between these versions that could be causing it?

 

I would much like to share a link to my game but unfortunately my clients wouldn't like if I share it here in public.  :ph34r:

Link to comment
Share on other sites

Right we did quite a bit of research into this tonight, as it popped up on another project. And in the end the problem was the encoding rate of the audio files. In this specific project we were using 44000Hz audio and iPad 2 would just generate a horrendous 'buzz' sound instead. We dropped to 44100 and it worked perfectly.

 

So that is what I'd suggest for you now - check the rate of your audio files and try encoding them differently.

Link to comment
Share on other sites

Right we did quite a bit of research into this tonight, as it popped up on another project. And in the end the problem was the encoding rate of the audio files. In this specific project we were using 44000Hz audio and iPad 2 would just generate a horrendous 'buzz' sound instead. We dropped to 44100 and it worked perfectly.

 

So that is what I'd suggest for you now - check the rate of your audio files and try encoding them differently.

 

Okay, that's interesting. I, however, just checked my audio files and they are all 44100Hz.

 

I'll pass this information to my audio guy and let's see what he thinks. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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