"Random" infinite freezing without errors - a tool for tracking internal processes?

	if !tile.objects_pool.is_empty():
		for obj in tile.objects_pool:
			print_rich("[color=green]", obj, "[/color]")	
			if !is_instance_valid(obj):
				print_rich("[color=yellow]", obj, "[/color]")	
				if !obj.thing:
					continue
				print_rich("[color=orange]", obj, ", ", obj.thing, "[/color]")
				if is_instance_valid(obj.thing):
					print_rich("[color=cyan]", obj, ", ", obj.thing, "[/color]")
					var n_obj_button : Button = object_button_prefub.instantiate()
					n_obj_button.icon = ResourceGod.get_object_list_icon("thing")
					n_obj_button.text = obj.thing.t_name
					object_list_holder.add_child(n_obj_button)
					if !n_obj_button.pressed.is_connected(select_object_from_list):
						n_obj_button.pressed.connect(select_object_from_list.bind(n_obj_button,obj,{"name" : n_obj_button.text}))
		print_rich("[color=magenta]loop done[/color]") 		
	updating_list = false	

Does it print as expected. If it does, then this loop is not the problem whatsoever.

Print’s never called, but there are no more freezes either

None of them? Then your project is not doing what you think it’s doing. Possibly on the wide scale.

But what exactly is wrong? In this case, your code is specifically written so that the code is only called if the object is not valid (and such scenarios clearly occur, but print is not called). In my previous example, I showed that print outputs previous freed, but in this example, it does not. So what is the difference?

My code is your code only with prints added. Without seeing the exact printout - we cannot continue.

I recorded this two versions (sry about compression)

So I don’t know. Even if I’ve made a fundamental mistake in the code somewhere, I don’t even know where it is or what it is anymore. Maybe I should just be happy that it works

Why are you running fullscreen when debugging? No wonder you can’t catch any bugs. Run windowed with the game window set to ā€œalways on topā€ or embed the game window into editor viewport. That way you can observe the printouts in real time as they happen.

I usually switch between them if I need print debugging, but that doesn’t happen often, so I switch back for game design testing. I do everything alone, so I have to test different things, and sometimes full screen is better. I’ve already technically solved this error, so I forgot to switch back, i’m sorry

We need to see those printouts. If there are no printouts then this code is never running and thus can’t be the source of any problems.

Btw, the indentation is different than in normalized’s post. (The print below the continue and the last two lines.)

Here is a re-run of the comparison with debug, with VSCode off - I tested both situations. In the first situation, there is a freeze - in the second, there is not. However, print is not called, so it cannot be the cause of the error, which is true, but then why does changing this code segment result in the freeze never occurring again?

Godot tells me that the nesting level is incorrect

In any case, even if I made a mistake, I don’t know where I made it. If something like this happens again in the future, I’ll just do another refactoring or rewrite the whole game from scratch. It’s not like I’m new to this. At the moment, I seem to be too far away from understanding this issue

That’s because you just mindlessly copy pasted the snippet I posted. I only added print lines into your code which was indented using spaces instead of standard tabs, another strange thing.

I only illustrated what it looks when you print everything because it seems you’re not understanding how fundamental and important this is for debugging.

The point is to put print a statement every step of the way to see exactly what’s happening. You can do it on your own using your own judgement. No need to copy paste such a trivial thing. Make this a habit.

That’s why the indents are different - because I changed them manually so the code would run at all

Just type the print statements into your code.