Looks like your performing IO on the main thread and freezing all the processing till it is complete.
You should try multithreading to make sure you aren't freezing the main thread.
var thread
# The thread will start here.
func _ready():
thread = Thread.new()
func save_data_to_database_async(data, database):
if thread != null:
thread.wait_to_finish()
thread.start(self, "save_data_to_database", {"data": data, "database": database})
func save_data_to_database(data2):
var database = data2["database"]
var data = data2["data"]
database.save(data)
# Thread must be disposed (or "joined"), for portability.
func _exit_tree():
thread.wait_to_finish()
As long as you are not saving very often, you shouldn't get many ui hangups.