# Low framerate when using lots of text nodes in gui

**URL:** <https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212>\
**Category:** Questions\
**Created:** [June 7, 2019, 10:12am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212 "2019-06-07T10:12:07Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [June 7, 2019, 10:12am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/1 "2019-06-07T10:12:07Z")

</div>

I need to use lots of text nodes in gui (around 70). In such case the frame rate drops substantially. How can I improve the situation? I’m running a debug version on windows.  
Here’s what profiler shows:

 ![profiler](https://forum-defold-uploads.b-cdn.net/original/3X/8/e/8eee0639b540a4dbeb2d91e7da3bbe74b7ad2001.png)

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [June 7, 2019, 11:07am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/2 "2019-06-07T11:07:00Z")

</div>

Profiler shows 301 Draw Call, it seems like your GUI do not optimized.  
Please read this topic about the draw calls optimization, it should help you:

> [@Draw calls and Defold](https://forum.defold.com/t/draw-calls-and-defold/4674):
>
> I am by no means an expert in this field, but sometimes I think about performance. Here is some thoughts about draw calls in Defold. Draw Calls What is a draw call? In a one liner: “A command that tells the GPU to render a certain set of vertices as triangles with a certain state (shaders, blend state and so on). A command like this is often more than one object.” A batch is a term that is basically means multiple commands that share the same state. If you are curios of a more in depth explan…

---

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [June 10, 2019, 9:00am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/3 "2019-06-10T09:00:04Z")

</div>

It helped. I used templates with text nodes mixed with box nodes which broke batching. I’ve put text nodes to a separate layer and it worked out perfectly.  
Here’s what profiler shows now:

 ![profiler](https://forum-defold-uploads.b-cdn.net/original/3X/f/c/fc4bd873c7ba81c6a2235be65abadca893f30665.png)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 10, 2019, 9:10am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/4 "2019-06-10T09:10:36Z")

</div>

Still too many drawcalls, you should try to get it under 100 for mobile.

---

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [June 10, 2019, 10:22am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/5 "2019-06-10T10:22:44Z")

</div>

Ok, thanks, I will.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 10, 2019, 8:24pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/6 "2019-06-10T20:24:32Z")

</div>

> [@Pkeod](#):
>
> you should try to get it under 100 for mobile.

Yes, it should be possible to get lower than 100, probably a lot lower.

> [@snakky](#):
>
> Ok, thanks, I will.

Do you know where you draw calls originate from? How many game objects and sprites do you have? How many gui components? Share a screenshot of the table to the right (Counters).

---

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [June 13, 2019, 12:59pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/7 "2019-06-13T12:59:47Z")

</div>

Well, yes, there’s a lot of nodes and many of them are text nodes with different fonts. I’m currently using a separate font for different font sizes (I was trying to get better text look, unfortunately it didn’t help, but I left it for a time being). Here’s the table to the right:

 ![profiler](https://forum-defold-uploads.b-cdn.net/original/3X/0/1/01373418cda69fd04a25b4690e5ef683d2da17e0.png)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 13, 2019, 1:50pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/8 "2019-06-13T13:50:27Z")

</div>

Are you using df/distance field fonts? You can make a custom material with a custom fp to add extra sharpness so that when text is scaled down it doesn’t get as blurry, then it’s more useful to use one font for multiple sizes.

---

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [June 13, 2019, 2:05pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/9 "2019-06-13T14:05:15Z")

</div>

I’m using bitmap fonts because df font gets weird color tint when scaled too much. Is there such fp shader already exists? Shaders are my weak spot 😔

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 13, 2019, 2:31pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/10 "2019-06-13T14:31:14Z")

</div>

![0%20-%20JointHookshot](https://forum-defold-uploads.b-cdn.net/original/3X/c/2/c2b6055975c410ce6590fc4e1e8ff0e2936ed0b6.png)

Example modification is very simple, you only halve the smoothing, or whatever value looks best for your project.

 ![2019-06-13%2007_29_06-JointHookshot](https://forum-defold-uploads.b-cdn.net/original/3X/3/1/31cd5309287ffc43fa3e2d225020cf20e4c72300.png) ![2019-06-13%2007_28_40-JointHookshot](https://forum-defold-uploads.b-cdn.net/original/3X/3/8/38102a01336a5182c6e63d991a2fa0c95bf34d5e.png)

Top has this modification, bottom uses builtin. So you can see the builtin version turns grey when scaled down but reducing the smoothing helps to minimize that.

What do your fonts look like currently?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 13, 2019, 3:47pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/11 "2019-06-13T15:47:04Z")

</div>

> [@snakky](#):
>
> I’m currently using a separate font for different font sizes (I was trying to get better text look, unfortunately it didn’t help, but I left it for a time being)

I’m sure there’s more to be done with layers to reduce draw calls! Can you share a screenshot? In theory and sometimes in practice you can get draw calls down to the number of atlases+number of fonts+possibly one or two more if you want stuff both above and below text.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 14, 2019, 10:05am UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/12 "2019-06-14T10:05:11Z")

</div>

![2019-06-14%2003_03_18-Window](https://forum-defold-uploads.b-cdn.net/original/3X/6/2/62063707f52e339b67f9b68c7283a2bb0a36cf73.png) ![2019-06-14%2003_03_07-Window](https://forum-defold-uploads.b-cdn.net/original/3X/1/2/121be2f9881770b02c7e1b0c09733933ae0dd752.png) ![2019-06-14%2003_02_53-Window](https://forum-defold-uploads.b-cdn.net/original/3X/2/8/28c26fd99bde0d8a3e151ebb493e7eed4e975de3.png)

Here’s a slightly different modification, instead of reducing all smoothing only reduce the edge. Again in each screenshot top is modified bottom is builtin.

This stays more consistently colored when scaled and looks a bit smoother.

---

<div class="post-metadata">

**Author:** ![snakky](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/snakky/32/9154_2.png) [@snakky](https://forum.defold.com/u/snakky)\
**Post date:** [July 2, 2019, 1:54pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/13 "2019-07-02T13:54:19Z")

</div>

Thank you guys! Everything you suggested helped a lot. I managed to get it to 15 draw calls.

 ![profiler](https://forum-defold-uploads.b-cdn.net/original/3X/9/3/9303f7f0feb7cf06aade4fc348f82b40964dae9f.png)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 2, 2019, 8:07pm UTC](https://forum.defold.com/t/low-framerate-when-using-lots-of-text-nodes-in-gui/54212/14 "2019-07-02T20:07:17Z")

</div>

Cool! I’m happy that to hear that you managed to rework and optimize your GUI!
