Performance Nastiness. Framerate, Framedrops, Lag.

This has been getting to me for the past few weeks. I have a few apps that rely on enterFrame events to drive animations. In the previous versions of Corona (the regular and Game Edition), everything works super smooth. The enterframe fires every time.

These same projects look really laggy when compiled with the .243 release. The smooth framerate is not there. I previously thought it was a physics problem, but now that I’m back on an app that didn’t use physics, I see the exact same performance issue – dropping frames. It looks really bad. It’s tested on an iPhone 3GS and iPad.

Could this be because of the new added sound API taking up more memory?

Thanks. [import]uid: 4454 topic_id: 4640 reply_id: 304640[/import]

is there some code that we can look at that demonstrate the issue really well?

anyone else experiencing p4mance issues like this?

c [import]uid: 24 topic_id: 4640 reply_id: 14700[/import]

Hi Carlos,

My code’s pretty big and finished, so I’ll demonstrate with something else…

Here is a simple (and slightly exaggerated) example that demonstrates the problem I see.

I took the “fishes” example from Corona Version 2.0.0 (2010.9.16.148), and increased the amount of fishes to 500. Published it with that same version, and put it on my 3GS. Although 500 is pushing it, after a second or so, the framerate is consistent and smooth. Maybe it’s at 20fps, but it’s steady, and doesn’t drop frames.

I take that same code and compile it with Corona v243 (the latest one to download). I run it on the same iPhone, and I can visually see the difference.

At least twice a second, the animation stops for about 50ms. So, it’s not really “dropping” frames, it stutters. And, it’s not totally consistent, but it regularly will stutter. It is highly annoying to see, and I saw this on all my projects done up to the new release. Meanwhile, I’m continuing to use the .148.

Perhaps you can check this out tell me if you see this yourself?

Thanks
Mike

[import]uid: 4454 topic_id: 4640 reply_id: 14702[/import]

I confirmed this and filed bug 2549.

It does appear to be audio engine related, but not actually about audio. It seems that under iOS, the thread scheduling is behaving badly. There is a background worker thread that does some simple management and bookkeeping. In the Fishies example since there is essentially no audio playing, it ends up trying to sleep all the time to yield and be nice to the rest of the system. Paradoxically, the calls to sleep are sucking up an unexpectedly high amount of CPU. I might blame this as an Apple/iOS performance bug especially because Mac doesn’t seem to demonstrate this bizarre behavior. I have a couple of ideas on how to work around this, but we’ll need to experiment a bit more to not break the audio engine in other bad ways.

[import]uid: 7563 topic_id: 4640 reply_id: 14799[/import]

ewing,

Thanks for looking into it. Good to hear that you’ve isolated the problem. [import]uid: 4454 topic_id: 4640 reply_id: 14807[/import]

I’m getting major stuttering on the iPhone similar to what oz describes. When I tried lowering the fps from 60 to 30 the stuttering wasn’t quite as bad but the physics interactions were mangled (ragdoll joints ripped apart).

I’m not sure how to proceed since I’ve already updated my audio code to use the new audio API. Should I revert to an older version of Corona using the old audio calls or wait for a work-around or fix for the latest version?

Imo this is a pretty serious bug since it potentially degrades EVERY app. built for iOS, even ones that don’t use audio at all. I certainly wouldn’t have upgraded to the latest Corona if I had known about it. [import]uid: 9422 topic_id: 4640 reply_id: 14816[/import]

I understand Xenon’s pain. What I don’t understand is, how did this release make it out the door? I immediately noticed the difference upon running my projects compiled with the new version.

I initially changed a project to use the new audio api, noticed the stutter-blocking, thought it may have been an audio format issue, and spent many hours trying to get past the problems. I really noticed what was going on after I made some changes to an existing project for my employer. Big whoops. Glad I save all the Corona releases I download. [import]uid: 4454 topic_id: 4640 reply_id: 14817[/import]

Well, it looks like we screwed up and there are no excuses.

We are looking at fixing this right away and hopefully have a fix asap that we can release an updated version that works.-

Carlos [import]uid: 24 topic_id: 4640 reply_id: 14834[/import]

its good to hear a company admit when they screwed up instead of trying to blame others lol [import]uid: 7911 topic_id: 4640 reply_id: 14836[/import]

Just to not open another topic, and since it’s related to performance :slight_smile:
Will it be implemented a less cpu consuming text? To display score or things that updates often, hopefully without hiccups.
I saw on cocos2D forums that they have a LabelAtlas function that it’s just for this purpose.
If it’s already there, or will not be implemented, then I’ll have to wrap my head around with images, but using text is sooo much simpler. [import]uid: 8486 topic_id: 4640 reply_id: 14860[/import]

@H4ch1

I’m doing some dynamic text printing with fonts, but I’m not noticing low frame rates on text alone. (iPhone 3GS)
To be precise, I’m actually printing quite long sentences char by char - which should be quite more intensive than printing score and similar.

Be sure you’re not *creating* text objects on the fly every time you update.
[import]uid: 5750 topic_id: 4640 reply_id: 15045[/import]

@erpy
I’m not creating other text object, just changing the object.text value.
It does affect performance though, cause it goes along with the leak of the physics bodies I posted in this section, filling up my ram faster (although text is not leaking, it seems that big strings fills up my ram faster than some 32x32 imgs for the numbers), and I can notice various hiccups related to the text update, that are totally gone away now that I use images for the score (it’s updated almost any enterFrame).
As I said, people on cocos2D forums noticed the same problem with the normal text creation when making their scores function, thus they have another function, specifically for text that updates a lot of time.
So, now I’m ok with imgs, but I had to struggle a little to not have any hiccups or slowdown :stuck_out_tongue: would have been easier with simple, plain text.
[import]uid: 8486 topic_id: 4640 reply_id: 15069[/import]

@H4ch1

I see.
For the sake of it - probably not your case - concatenating large strings (even using the “…” operator) can also get quite slow on portable devices. But that’s Lua. [import]uid: 5750 topic_id: 4640 reply_id: 15073[/import]

@erpy
Yep, I’m not using the “…” operator, just passing it a variable containing the score. I also tried to change it to string before passing it to the object.text with tostring(score), same results. [import]uid: 8486 topic_id: 4640 reply_id: 15075[/import]

Not sure how this got derailed into a discussion about text. The original subject of this thread was to point out a pretty serious bug in the latest Corona build, with no apparent workaround, causing major stuttering on iPhone devices.

Carlos, you acknowledged this is a serious issue to be addressed “ASAP”, and while I know the holidays probably meant the lights were off at Ansca HQ I’m a little anxious to know when a fix will be in. Any news?

[import]uid: 9422 topic_id: 4640 reply_id: 15367[/import]

Within the next two weeks.

We are implementing other features as well that also makes use of the p4mance so we are back and everyone is in testing and feature lockdown mode.

carlos [import]uid: 24 topic_id: 4640 reply_id: 15368[/import]

Coolio. Welcome back, all @ Ansca! [import]uid: 9422 topic_id: 4640 reply_id: 15371[/import]

Ansca,

Very happy to say that the latest release (.268) solved the performance problems I mentioned above. Thanks for all the hard work!
[import]uid: 4454 topic_id: 4640 reply_id: 18950[/import]

I have the following experience.
If I build my app for Android with 268 release it’s visibly slower then the same app build with 243 release.
It’s most obvious when I touch the screen and a new object is being generated in my game.
I remember that there was similar issue with touch events in previous releases but it has been fixed in 243 one.

Does someone experience the same?

Thanks,
Dusan
[import]uid: 5411 topic_id: 4640 reply_id: 19182[/import]