Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] Texts created with CreateText() VERY slow?

Author
Message
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 26th Jul 2019 23:46 Edited at: 26th Jul 2019 23:47
Hey,

I just encountered unusual frame drops in a game I'm currently developing.
I thought I messed up with the particles, but it turned out it were the texts I created.
There are 35 levels in the game, and each level contains a pretty long text ( between 500 and 3000 characters ).
All texts are hidden @ -999, -999.
The FPS dropped sometimes from 60 to 30 on a Galaxy S4. Both with Studio and Classic.
First thing I did was change the text visibility to 0, which boosted the FPS back to around 60.

So I wrote a little code to check the impact of texts, which really surprised me: ( Tested on Win10 64bit GTX 970 )


This code creates 500 texts with 200 characters each, and puts them @-999, -999
I get around 125 FPS with visibility 1, and around 290 FPS with visibility 0
I get around 240 FPS with visibility 1, and around 410 FPS with visibility 0 when I use 100 "A"s instead of 200.

Isn't that pretty slow for texts? I mean, they are not even on the screen.
I can display 2000 space ships ON the screen, flying from bottom to top at different speeds, and still have 410FPS.
With just 500 texts, which are pretty small because of their tiny text size, and which are not EVEN on the screen, AND hidden with visibility set to 0, I get only 290?

Sure, I can do a workaround by just loading the texts on demand, but I still find it pretty strange that texts are so slow. Anyone have an explanation for this?


Thanks,
PSY


PSY LABS Games
Coders don't die, they just gosub without return

The author of this post has marked a post as an answer.

Go to answer

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 26th Jul 2019 23:55
This post has been marked by the post author as the answer.
That sounds about right for the level of complexity rendering text is via the methods used by AGKV2/Studio. Each character is effectively its own sprite and as a collective unit provides varied options for scaling, rotation, placement, and color.

Being on/off screen probably wouldn't help performance very much (limitations with clipping bounds perhaps?), but setting their visibility state should as you noted. I would highly recommend only creating text indexes when needed, then remove them entirely when not needed to minimize overall consumed indexes. Creating text indexes is very fast, so it doesn't take long to go through that process on demand during runtime.
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Jul 2019 01:33
Quote: "Each character is effectively its own sprite and as a collective unit provides varied options for scaling, rotation, placement, and color."


What the hell

I didn't know that. Well, that explains it, then.
Thanks alot, man.

I rewrote some parts. Now, the compound description is only loaded into a text on demand ( when the player actually starts a level ).
Any existing compound description is cleared beforehand.
By this, I was able to boost FPS on my Windows machine from 310 FPS to 3000 FPS

I guess a lot of people dont know about this huge impact on the FPS. I really think this should be mentioned in the help...


PSY LABS Games
Coders don't die, they just gosub without return

Login to post a reply

Server time is: 2024-04-18 23:41:51
Your offset time is: 2024-04-18 23:41:51