Overhead Retrieving UI Object Attributes
So yesterday I spent half a day scratching my head trying to figure out why 'for' loop was so slow. After all, it was doing some very basic operations 100 times per second.
I was trying to see if Appcelerator was cut out for creating a sidescroller. I was merely doing some collision detection. However, the collision detection was being down on a UI object and within the loop I was calling .top and .left on that object. Sure, it was kinda silly not to have called them just once outside the loop but had I not done this I don't think anyone would know about this performance bug.
Turns out the overhead for calling .top and .left on just about any UI object is so ridiculously high that calling it 100 times a seconds will make an iPod touch limp like an old man kicked in the crotch.
1) I suppose this could be the same as the 'View performance' ticket that keeps getting pushed back release after release. I have another app that makes extensive use of UI objects and noticed it was slow at drawing them on screen but I had never equated the problem to the overhead of reading top, left, height and width attributes.
2) This problem seems to be getting little love by the Appcelerator team…if this falls into the 'View performance' problem, I noticed that it got pushed to 1.4.
3) I know Appcelerator isn't meant for creating games and that other tools may be more appropriate but the game I was trying to create was very basic…there was nothing much going on but the scrolling of a view and some very basic collision detection. Is there any incoming APIs or API changes in Appcelerator that may alleviate this performance problem? Is the 'native Canvas API' going to allow Appcelerator apps to draw things rapidly without the use of a WebView and Webkit?
4) Drawing the game using Webkit/HTML/Javascript would certainly fix the problem, but I would only do this as a last resort thing.
2 Answers
-
I would like some input on this as well.
-
If you would be willing to share your example code, it would help us in addressing the performance issues you noticed. Thanks…