iTGE 1.2 2D Performance issue..
by Stefan Eilers · in iTorque 2D · 09/01/2009 (10:15 am) · 11 replies
I need some help in order to increase the frame rate. I discover a significant drop of the frame rate if I use multiple animated sprites and don't see any reason for this:
My measurements:
Zero Sprites: Frame rate about 20 FPS
20 Sprites, Animation runs in loop, Sprite is _not_ moving: 8 FPS
20 Sprites, Animation stops after one cycle, Sprite is _not_ moving: 8 FPS (very surprising!)
If I activate the update callback with (%this.owner.enableUpdateCallback()) the frame rate drops to 5 FPS if the onUpdate() callback is empty.
If I change the speed of the sprite in the onUpdate() callback: The frame rate drops below 1 FPS.
I'm not very satisfied with this measures because I would like to show more than 20 Sprites.
Does anyone has an Idea how I can improve the frame rate? Every help is strongly appreciated!!
Thanks in advance!
I compile my Projekt using the "iTGB_Script" target which works quite well. Using "iTGB_Script_Optimize" does not work as it produces very strange behavior.
My measurements:
Zero Sprites: Frame rate about 20 FPS
20 Sprites, Animation runs in loop, Sprite is _not_ moving: 8 FPS
20 Sprites, Animation stops after one cycle, Sprite is _not_ moving: 8 FPS (very surprising!)
If I activate the update callback with (%this.owner.enableUpdateCallback()) the frame rate drops to 5 FPS if the onUpdate() callback is empty.
If I change the speed of the sprite in the onUpdate() callback: The frame rate drops below 1 FPS.
I'm not very satisfied with this measures because I would like to show more than 20 Sprites.
Does anyone has an Idea how I can improve the frame rate? Every help is strongly appreciated!!
Thanks in advance!
I compile my Projekt using the "iTGB_Script" target which works quite well. Using "iTGB_Script_Optimize" does not work as it produces very strange behavior.
About the author
#2
Well. I use the parallax scrolling behavior that uses this update callback which might cause this frame rate. There are two scrollers (one background and one middle ground). That's all.
.
09/01/2009 (10:37 am)
Quite low? What would you expect?Well. I use the parallax scrolling behavior that uses this update callback which might cause this frame rate. There are two scrollers (one background and one middle ground). That's all.
.
#3
1. Not use onUpdate ever in script. If you need it you need to write it in c++.
2. REcompile TGBGame with the optimize flags. Then you cna use the the optimizations because the DSO Files will match the iphone compile flags.
Do both of those and it'll give you decent framerate.
09/01/2009 (10:43 am)
update callbacks in iTGB are really slow because they make a script call almost every frame. What you need to do is:1. Not use onUpdate ever in script. If you need it you need to write it in c++.
2. REcompile TGBGame with the optimize flags. Then you cna use the the optimizations because the DSO Files will match the iphone compile flags.
Do both of those and it'll give you decent framerate.
#4
Can an employee / moderator please move this thread to the right board and remember iTGE licensees to stop missusing the iTGB / iT2D boards for their questions and causing unneeded confusion? The two techs are not really comparable.
09/01/2009 (10:46 am)
removed again. As this thread was by error posted on the wrong board again (these here are the iTGB boards, not the iTGE, so please post on iTGE if its for iTGE, which is seriously different from iTGB!!)Can an employee / moderator please move this thread to the right board and remember iTGE licensees to stop missusing the iTGB / iT2D boards for their questions and causing unneeded confusion? The two techs are not really comparable.
#5
09/01/2009 (10:50 am)
Wha...? What just happened? Oh, now we talking about iTGE wtf? I think the topic is a typo maybe as it refers to iTGB in the actual body of the post?
#6
Regarding 2.: What do you mean with "Recompile TGBGame"? Do you mean that I shoul recomple the game engine with the iTGB_Script_Optimize target? I tried that but my game started to behave really weird..
09/01/2009 (10:52 am)
Regariding 1.: Yes, onUpdate() is bad. I need to rewrite the ParallaxBehavior in order to call my sprites if its speed changes. Is there any example how to implement the observer pattern? The scrollers need to call the sprites it their speed changes.Regarding 2.: What do you mean with "Recompile TGBGame"? Do you mean that I shoul recomple the game engine with the iTGB_Script_Optimize target? I tried that but my game started to behave really weird..
#7
09/01/2009 (10:55 am)
Sorry.. No. Talking about iTGE. The XCode target is called "iTGB_Script". Don't know why.. :)
#8
09/01/2009 (11:00 am)
open up the regular xcode project and recompile the TGBGame for MAC. If you do that then when you use the script_optimize target it won't behave really weird.
#9
But this forum is in the group "Engine" and is called "Torque 2D for the iPhone". Therefore it is not obvious that this is wrong and not intended to discuss issues with the game engine!
Just to make it clear:
- I'm not having any problems with the game builder!
- I have problems with the game engine on the iPhone device!
09/01/2009 (11:05 am)
Sorry if posting into the wrong Forum and for any confusion. But this forum is in the group "Engine" and is called "Torque 2D for the iPhone". Therefore it is not obvious that this is wrong and not intended to discuss issues with the game engine!
Just to make it clear:
- I'm not having any problems with the game builder!
- I have problems with the game engine on the iPhone device!
#10
You also need to look into the setUsesPhysics method threads etc.
Anyway I'm getting tired of answering this question. It's been answered 100's of times on this forum and I really wish GG would hurry up with 1.3 to fix this issue so people don't continue use the non-script-optimize because they don't know all the steps required to work around the distribution issues.
09/01/2009 (1:52 pm)
Yes and the reason you are having those problems on the iphone device is because the SCRIPT files are compiled to DSO's by the Game Builder. The compiler options for the program that compiles the DSO's for the iphone must be compiled with the same options as the iphone game engine or it blows up. Compiling without the optimizations is part of your speed problem. The other problem is you need to not use onUpdate in script.You also need to look into the setUsesPhysics method threads etc.
Anyway I'm getting tired of answering this question. It's been answered 100's of times on this forum and I really wish GG would hurry up with 1.3 to fix this issue so people don't continue use the non-script-optimize because they don't know all the steps required to work around the distribution issues.
#11
Too bad that my original answer cached anymore
Generally: You will need to go into C++ for anything more complex / onUpdate / physics using.
Also if you create and destroy stuff on a regular base, ensure to implement pooling. Without it you will run up an ugly performance wall.
Another thing: If you don't use networking, ensure to comment out the whole code that initializes networking, because it otherwise will burn cpu time as it is not correctly shutdown again if you disable networking in the preferences
09/01/2009 (10:47 pm)
@Stefan: The thread title is iTGE and iTGE != iTGB (iTGE = Torque 3D for iPhone, not Torque 2D for iphone :) ). That somehow made me kill my original answer and replace it, I somehow managed to miss the last sentence.Too bad that my original answer cached anymore
Generally: You will need to go into C++ for anything more complex / onUpdate / physics using.
Also if you create and destroy stuff on a regular base, ensure to implement pooling. Without it you will run up an ugly performance wall.
Another thing: If you don't use networking, ensure to comment out the whole code that initializes networking, because it otherwise will burn cpu time as it is not correctly shutdown again if you disable networking in the preferences
Associate Craig Fortune