Update: Async calls were implemented! Questions below.
I'm working on a game template project where you can change a font's face and size. Whenever I make changes, however, the game locks up while processing the changes. I'm trying to mitigate this locking up by making this happen asynchronously. I tried creating just one thread to handle in the background, but the lag persisted. I went so far as the code below where I create a unique thread for each node type in my theme! But even that didn't improve performance. How can I adjust font size without getting this laggy lock-up issue I'm experiencing?
If you want to see the full project for context, you can take a look here: https://github.com/programnoir/GDTemplate/pull/19 But the code below gives the essential parts.
# Above this code are the basic parts of setting up an array of null values so they can have threads created on them later.
func set_font_size_threaded( type: String, new_size: int ) -> void:
theme.set_font_size( "font_size", type, new_size )
func set_font_size( new_size: int ) -> void:
var i: int = 0
for type in theme.get_type_list():
if( thread_font_size_array[ i ] != null ):
thread_font_size_array[ i ].wait_to_finish()
thread_font_size_array[ i ] = Thread.new()
thread_font_size_array[ i ].start( set_font_size_threaded.bind(
type, new_size ) )