Annoying stutters on iPhone/iPad

When playing a level in our dualstick-shooter (http://revoltgame.info/) framerate is quite acceptable given the complexity. However, once in a while there’s a stutter of .5-1second that is probably due to unity loading resources in that are active for the first time in the scene.
Is there an easy way to force Unity that all this is preloaded at start of level? Of course I could force-instanciate everything at frame 0 and then destroy them again, but given the amount of models, effects and textures this would be quite an exercise:
247 FBX/animations
175 materials
131 prefabs
150 sounds
etc…
On an 1st gen iPod the stutters can even be multisecond (and we have decided to exclude 1st gen for this reason).

Any hints/solutions greatly appreciated, this is one of the last issues before publishing it (finally got OpenFeint sort-of-usable with 3.0 and hacked arround the movie bugs triggered in Unity3 - iOS3.2 combo).

Unity 3.0 loads everything in scene right away. Maybe loading from Resources? Anyway, bug report it and attach your project :wink:

It seems part of the problem is in audio playback, gonna delve deeper into it.

Instantiating objects during gameplay has long been none to be a source of framerate stutters, jerks, stops, etc. The only way around this is to instantiate all objects at level start, deactivate them on birth and activate them as needed.

Perhaps it could be garbage collection as well?

Sweet looking game btw. Do you mind if I ask how many people you have working on the project? Do you have a Publisher?

If in the end you decide to bugreport it - drop me a line with case number :wink:

2 people working on it. We have been contacted by numerous publishers but have not signed any deals.

As Graphicalgeek already said, basically it’s a 2 people project, but Sean Neville http://www.psneville.com/ did the music and arranged a voice actor http://www.michelleherrinvoice.com/ for an excellent voice-over for intro movie and we bought a few drawings used for the intromovie from http://shimmering-sword.deviantart.com/. That’s about it :slight_smile:

But back to the issues, the audio is compressed, set for hardware playback and 2d so it’s a bit weird that it results in the hickups. Other culprits could be indeed instantiating of objects, we already pool bullets but there are too many effects and explosion types to have them all pooled. I’m gonna do some testing in simple test project and let you know my findings (and file bug if needed).

After playing a while on my 3GS I start getting “Hardware codec is not available (Maybe iPod is playing?). Falling back on software” for no apparent reason, the ‘funny’ thing however is, that when the audio is software decoded I don’t get the startup lag. After a short suspend/resume of the game hardware encoding is working again (with a nice Error initializing AudioSession(errNO:1768843636) after resuming) and the startup lag is back… so there’s definitely something going on with starting audio playback using hardware decoder…

Wow, thats pretty impressive!

Bug filed: 377448
for iPod 1st gen it took about 0.5 seconds to start compressed audio using hardware decoder (0.08 without hardware decoder)
for iPhone 3GS it took about 0.25 seconds to start compressed audio using hardware decoder (0.003 without hardware decoder)
more than long enough to get a visible stutter in a game.

Thanks for heads-up - will look into it

Yeah, could reproduce the issue - i forwarded it to audio guys :wink:

Just out of curiosity, how long has this game been in development? It looks like it would take forever with only 2 guys!

You can follow the progress all the way back to the start.

http://revoltgame.blogspot.com/

Just wanted to add that we’re having the same problem with streamed audio … getting the “Hardware codec is not available (Maybe iPod is playing?). Falling back on software” warning in xcode.
Has there been updates or feedback regarding a possible fix?
Thanks

We got the same here also. “Hardware codec is not available (Maybe iPod is playing?). Falling back on software”

I’m getting the same on my iPad project.
The app uses a mixture of streaming WAV from /Documents/ folder and precompiled MP3 music assets imported/created in Unity.
After adding Primes31’s AudioRecorder package and specifically calling AudioPlayerBinding.play();
When audio is played back using one of the MP3’s I get the “hardware codec is not available…” warning.

I currently made a simple compressed audio playback plugin in Objective C to do playback of music and ambient effects (that now can be IMA4 compressed and played over the M4A music ‘layer’). It doesn’t solve all our stuttering but at least it frees lots of memory as music is now streamed from flash instead from RAM like unity always seem to do no matter what the settings are (maybe the playing back from RAM thing is fixed now, don’t know, doesn’t matter for us anymore now).