Vector graphics and memory

Hi Guys,

Hopefully this is a simple question.

I’m using a rectangle which is the size of the device screen to register touch events. Does this shape get rendered as a texture, ie take up as much memory as is it was a png?

Also, the same question for polygon shapes. I am generating landscape using lots of polygons.

Is this is the case, are there any work arounds?

Thanks guys.

Hi @roballison182,

Vector objects don’t take up much room at all. Maybe a tiny tiny bit, but nowhere near what a screen-sized PNG would take up. You can test it by putting a bunch of vector objects on the screen and testing the amount of texture memory occupied via the standard testing method.

Best regards,

Brent

Hi, thanks for the reply.

I’m currently testing my game. I was getting REALLY low frame rates on my android phone. I took out all game loops and the frame rate was still awful. I then removed 4 of these rectangles and I got an increase of 10fps. Maybe it was a coincidence.

Also, I had a bunch of layered backgrounds with a gradient fill. I removed them and saw a huge performance boost.

Very odd.

Hey,

I’ve created a project that replicates the issue very well. I have 10 rectangles at 0.01 alpha. If you run this in the iOS simulator (or an older device) it will run at about 5-10 fps instead of 60. There’s only a couple of animations going on here.

Now, I’m guessing that using rectangles at 0.01 alpha is now a big mistake. I guess I need to set them to “isVisible = false” and “isHitTestable = true”. 

I’d really like to hear some input on this.

You can run the project here:

https://github.com/justTheDrummer/corona-low-fps

Does this mean that if I have particles fading out to an alpha of 0.01 it will also have a large effect on performance? What about semi transparent objects?

Thanks a lot!

Just to add, I’ve altered the repo to test for gradients also. I’ve found that there is a huge performance issue on gradients. If I added one full screen gradient to the screen, my frame rate drops from 60fps to 30fps.

If you clone this repo and run it in the iOS simulator you’ll see it switch between testing “nothing”, then 0.01 alpha rects and 10 gradient rects. You’ll see the frame rate reduces dramatically.

Thanks.

EDIT: Also, I’ve just tweaked the rects to be full opacity and the problem still persists, so it can’t be the the alpha like I first guessed.

Sorry to “bump” this, but I’m kinda stuck until I know what’s going on. Is this a bug in corona, or am I doing something wrong?

If I display 10 rectangles on the screen, I get a massive drop in performance. That can’t be right. I’m hoping I’m doing something wrong and it can be fixed easily :slight_smile:

Thanks in advance!

Hi Rob,

I cloned your repo and ran it in the Corona Simulator (Mac), Build #2189. The frame rate never drops below 58. Is there something I’m not getting in your case report?

Brent

Hey,

Thanks for checking it out.

The corona simulator is fine. Try it in xcode’s iOS simulator or an iPhone 4/android phone that’s over a year old.

Here’s a screencast of iOS simulator. I get the same results on a samsung nexus.

https://www.youtube.com/watch?v=I4JL1-jK5W4&feature=youtu.be

Hi Brent, 

Has anyone at corona been able to check this out? Please watch the above video for a demonstration of the huge drop in fps.

Hi Rob,

Is the project currently uploaded at the link you provide the most current or have you made changes? I can test it on one of the older devices I have (iPod Touch 4th-gen) and see how it performs. As for the Xcode Simulator, that is not good grounds for performance testing, and on Samsung devices, the capabilities of the the GPU can vary wildly depending on the model.

Thanks,

Brent

Thanks for looking into this. I’ve made some very small changes to the github repo, basically to show that it’s not actually the rectangle “alpha” that was the problem. I get the same problem with full alpha.

Hi Rob.  On my Google Nexus 7, I saw a frame rate drop to about 30fps.  We think engineering needs to look at this.  Can you zip up your sample project and file a bug report using the Report a Bug link at the top.  This will get it on their radar.

Thanks

Rob

Hey, I’ve already filed a bug for this. I’ve just not heard back yet.

I was hoping I was doing something wrong as it’s causing me huge issues at the moment.

Thanks for replying.

Hi @roballison182,

Vector objects don’t take up much room at all. Maybe a tiny tiny bit, but nowhere near what a screen-sized PNG would take up. You can test it by putting a bunch of vector objects on the screen and testing the amount of texture memory occupied via the standard testing method.

Best regards,

Brent

Hi, thanks for the reply.

I’m currently testing my game. I was getting REALLY low frame rates on my android phone. I took out all game loops and the frame rate was still awful. I then removed 4 of these rectangles and I got an increase of 10fps. Maybe it was a coincidence.

Also, I had a bunch of layered backgrounds with a gradient fill. I removed them and saw a huge performance boost.

Very odd.

Hey,

I’ve created a project that replicates the issue very well. I have 10 rectangles at 0.01 alpha. If you run this in the iOS simulator (or an older device) it will run at about 5-10 fps instead of 60. There’s only a couple of animations going on here.

Now, I’m guessing that using rectangles at 0.01 alpha is now a big mistake. I guess I need to set them to “isVisible = false” and “isHitTestable = true”. 

I’d really like to hear some input on this.

You can run the project here:

https://github.com/justTheDrummer/corona-low-fps

Does this mean that if I have particles fading out to an alpha of 0.01 it will also have a large effect on performance? What about semi transparent objects?

Thanks a lot!

Just to add, I’ve altered the repo to test for gradients also. I’ve found that there is a huge performance issue on gradients. If I added one full screen gradient to the screen, my frame rate drops from 60fps to 30fps.

If you clone this repo and run it in the iOS simulator you’ll see it switch between testing “nothing”, then 0.01 alpha rects and 10 gradient rects. You’ll see the frame rate reduces dramatically.

Thanks.

EDIT: Also, I’ve just tweaked the rects to be full opacity and the problem still persists, so it can’t be the the alpha like I first guessed.

Sorry to “bump” this, but I’m kinda stuck until I know what’s going on. Is this a bug in corona, or am I doing something wrong?

If I display 10 rectangles on the screen, I get a massive drop in performance. That can’t be right. I’m hoping I’m doing something wrong and it can be fixed easily :slight_smile:

Thanks in advance!

Hi Rob,

I cloned your repo and ran it in the Corona Simulator (Mac), Build #2189. The frame rate never drops below 58. Is there something I’m not getting in your case report?

Brent

Hey,

Thanks for checking it out.

The corona simulator is fine. Try it in xcode’s iOS simulator or an iPhone 4/android phone that’s over a year old.

Here’s a screencast of iOS simulator. I get the same results on a samsung nexus.

https://www.youtube.com/watch?v=I4JL1-jK5W4&feature=youtu.be