0 votes

I tried to find the source of the stutters and narrowed down it to this.

Basically when I update the text on a Label the game stutters.

extends Label

func update_score():

I call this function every time the score Label needs to be updated

even when i do this it stutters:

extends Label

func update_score():

It happens for about the first 5 seconds or so when the score is updated.
After those 5 seconds it updates without stuttering.
It only happens when I export it to android. If i run it on my pc it doesn't stutter

I'm using godot 3.2.2 stable

in Engine by (21 points)

1 Answer

+1 vote
Best answer

I ran a profiler on my project and figured out that the Idle Time was spiking.
I think that it was spiking because the font data on my label wasn't preloaded or cached. So everytime I had a new symbol be displayed the font data had to be fetched.

Basically every new symbol that I used had to be loaded seperately.

I solved it by creating another label and just printing every numeral "0123456789" and the stutters stopped except after the first score update.

There should be a better way of solving this.

by (21 points)

There's a pull request that aims to make DynamicFont caching easier: https://github.com/godotengine/godot/pull/40491

PS: You should be able to set the label's Modulate property to Color(0, 0, 0, 0) so it's invisible while still rendering its characters.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.