Game Development Community

My Experience on optimisation on the iPhone

by Scott Wilson-Billing · in iTorque 2D · 02/23/2010 (4:53 pm) · 103 replies

Just thought I'd post some notes on what has really improved performance.

1. PVRTC

2. Atlas sprite sheets, mSourceRect etc.

3. Sprite pools, static and animated. Animations are put back into the pool at the end of the animation.

4. NO particle effects - just using animations generated from TimelineFX.

5. While loops replacing for loops - I kid you not!

6. Turn off updateCallBack - use timers for game loop events, dynamically change timer interval dependant on number of objects on screen - this smoothed stuff out.

7. Other stuff like collision groups to cut down on the noise from onCollision callbacks.

I've still got more PNGs to convert to PVRs but at the moment I'm very pleased:

3GS - 50+ FPS

iTouch 2nd Gen - 50+ FPS

I'm waiting feedback from our testers on the 3G.

The iPhone 2G is a bit of a no-go and I'm not going to put in any more effort here.

Thanks for all the advice from people on this forum.

Cheers
Page «Previous 1 2 3 4 5 6 Last »
#1
02/24/2010 (3:17 am)
Some feedback from the testers:

3G: 15-30 FPS
iTouch 1st Gen: 20 FPS

Mostly playable on these devices but still some optimisations I can do.

Typically on screen (at the start of each level) there are about 40 - 50 objects.

There is a preview here:

www.youtube.com/watch?v=N4MZ2fwnFsM
#2
02/24/2010 (4:49 am)
Very cool looking game, and the feedback on performance and how to obtain is good too. Thanks !
#3
02/24/2010 (6:51 am)
Thanks for the info!
#4
02/24/2010 (9:08 am)
hehe another fan of timelinefx :) yeah its great to generate performant particle effects for mobile :)

very good posting


as for the iphone 2g being a bit of a no go: the 3g and 2g are game wise the same. the 3g commonly has a chance to be at worst even less stable as the new capabilities lead to even more services eating memory ...

I've an ipod touch 1st gen if you want to test it on them too
#5
02/24/2010 (9:30 am)
Thanks for the 1st gen offer Marc, if you let me have your UUID I'll add you to the beta test list - same for anyone else who would like to try it out.
#6
02/24/2010 (9:37 pm)
I'm glad to see someone else has caught onto the loop optimization. As I've said before, a decrementing do-while loop is just faster than an incrementing for loop. :)
#7
02/25/2010 (5:25 am)
UUID is 9c299ed1cdbd002274b980139461afc088c0abff, you can use marc point schaerer aet gayasoft.ch to contact me directly :) (point and aet replaced through corresponding signs)
#8
02/25/2010 (6:30 am)
Marc, just registering your device and then I'll re-build and send you a link.

BTW: I have changed the profile from Anthony's name to my name - Anthony is the guy in our company who paid for the licence - I am the person doing the development work. I didn't realise I could edit that stuff otherwise I would have done it along time ago, doh!

Cheers
Scott
#9
02/25/2010 (7:48 am)
Marc, email and link sent.
#10
04/23/2010 (11:04 pm)
Excellent post! Thanks for the information.

I'm getting to the point where I need to start optimising, so this is really helpful information that is gratefully appreciated. I just wanted to ask one question regarding particle effects. Did you find that particle effects slowed things down a lot? I'm currently using some particle effects for explosions etc, and although I haven't haven't had any major slow downs so far I'm wondering if I should think about using animations instead. Any suggestions?

Thanks, Mark.
#11
04/24/2010 (1:05 am)
Hi Mark, I'd seriously suggest using no particle effects unless you really have very few sprites on screen. Animations are the way to go IMO and I can't recommend that TimelineFX enough - you can take the particle effect values from Torque and apply them into the TimelineFX editor to create the same effect, but as an animated sprite strip. It also comes with 100s of effects out of the box.

www.rigzsoft.co.uk/index.php?option=com_content&view=article&id=1&It...

Effects:

www.rigzsoft.co.uk/index.php?option=com_content&view=article&id=41&I...
#12
04/24/2010 (4:47 am)
Fully agree on the particles. They really kill the performance seriously.

Take the behavior shooter from 1.2 thats still present in the zip in 1.3 and run it with the effects and with them cut to get a feel for the difference
#13
04/24/2010 (4:21 pm)
Thanks for the feedback. I've taken a look at TimelineFX and it looks awesome, especially with all of those free effects downloads. I will definitely give it a try.

Also, good suggestion about using shooter example. It will be interesting to create similar explosion effects in TimelineFX and see how they perform compared to particles.
#14
04/25/2010 (4:17 pm)
Reducing sound quality to 22500khz is also a good way of saving disk space and memory. If your game does not use networking, disabling it will boost fps significantly, check out Marc Schaerer's post for more info.

update: fixed the typo in Marc's name ;-)
#15
04/26/2010 (3:45 am)
Actually the networking stuff shouldn't be required anymore by 1.3.x
To my knowledge the offending code was fixed (some incorrect code on the handling side that ensured that it would kill the performance)

Disabling (not enabling) networking if you don't need it though still is a good idea for battery and temperature reasons though


by the way: Its Schaerer hehe ;-)
Though Marc / Dreamora is fine :)
#16
05/03/2010 (8:56 pm)
Good point about the audio quality, since a lot of sound files tend to use CD quality, which is obviously overkill in most cases. It's very difficult to distinguish any difference in sound quality at more than about 20kHz. Actually, depending on the frequency content of the sound, you can sometimes reduce the rate to 16k or even lower, and for some of my sound files I use 8000 Hz. I use Audacity, which is free, and that tool makes it very easy to change the sampling rate and immediately hear the difference. Very nice tool, and highly recommended.
#17
05/08/2010 (12:50 pm)
Scott, I was wondering if you wrote all of your game in script or did you find that you had to rewrite certain parts of it in C++? I'm currently doing everything in script and the performance seems ok so far, but I would certainly consider porting things to C++ if that would make a significant different in overall performance. Any thoughts on that?
#18
05/08/2010 (1:03 pm)
Mark, I reverted to C++ for some of the more intensive parts of my game loop - I had to do this because performance was very poor on 1st gen touch and iphone 3g. I'd advise testing early on these devices if you haven't already.

One negative of C++ is I'm getting some really nasty random crashes and at the moment it seems that it might be a threading issue - me updating stuff on the C++ side whilst Torque does its stuff with triggers and callbacks. Can't say for sure but it is burning up a lot of my time and I didn't see any of these problems when it was all script.
#19
05/08/2010 (4:38 pm)
thats very well possible because scripts don't use any threading, they run all in the same thread as the application and you should do that too (TGE and thus TGB and iTGB aren't thread safe nor were they developped with multithreading in mind. T3D is the first Torque iteration aside of TX where multithreading is something I would consider to approach)

if you need script alike multithreading do what many if not most do: write a script function to expose the function to call and hook that one up through a code to con schedule request for that function for example

or alternatively try to use Obj C style shifted execution with selectors and delay assuming you don't work in pure C++
#20
05/08/2010 (4:49 pm)
Thanks Marc, I think i tracked down the problem but still am not sure if I have the "proper" solution. If you get a moment I'd appreciate it if you could give me your thoughts on this thread which I have just published:

www.torquepowered.com/community/forums/viewthread/115039

Cheers
Page «Previous 1 2 3 4 5 6 Last »