Identify debugger instance at runtime?

Godot Version

4.2.1

Question

When running more than one instance of my game, I’d like to be able to identify each instance/session open and auto position them. I’m not currently seeing a way to do this, and I’m trying to avoid modifying my Godot build as I’m not too comfortable building the app from source.

I did find custom solutions that would both be awesome to have, but it appears that they were never merged into the main branch!?!?

Solution for identification of debugger session at runtime:
https://github.com/godotengine/godot/pull/64913

Solution for auto-positioning of debugger windows in Editor settings:
https://github.com/godotengine/godot/pull/67587

I was attempting to persist the OS.get_process_id() of each window to a file and then position, which works to an extent, but i’m now having issues with file access and this just feels wrong!! Does anyone know of a way to accomplish my goal?

Thanks!

I still haven’t found a solution that works 100% of the time, but this works 70%:

if (OS.is_debug_build()):
	var config = ConfigFile.new()
	var mutex = Mutex.new()
	
	while mutex.try_lock():
		break
		
	var load_status = config.load("user://debug_window_positioning.cfg")
	
	while load_status != OK:
		load_status = config.load("user://debug_window_positioning.cfg")
	
	if config.has_section("Players") && config.has_section_key("Players","4"):
		config.clear()
	
	var save_status
	
	if !config.has_section("Players"):
		config.set_value("Players", "1", OS.get_process_id())
		save_status = config.save("user://debug_window_positioning.cfg")
	else:
		var next_player = str(config.get_section_keys("Players").size() + 1)
		
		while !config.has_section_key("Players",next_player):
			config.set_value("Players", next_player, OS.get_process_id())
			save_status = config.save("user://debug_window_positioning.cfg")
		
	while save_status != OK:
		save_status = config.save("user://debug_window_positioning.cfg")
				
	var screen_size = DisplayServer.screen_get_size()
	DisplayServer.window_set_size(Vector2(screen_size.x / 2, screen_size.y / 2 - 30))
	
	for section in config.get_sections():
		if config.get_value(section, "1") == OS.get_process_id():
			DisplayServer.window_set_position(Vector2(0,30))
		elif config.get_value(section, "2") == OS.get_process_id():
			DisplayServer.window_set_position(Vector2(screen_size.x / 2,30))
		elif config.get_value(section, "3") == OS.get_process_id():
			DisplayServer.window_set_position(Vector2(0,screen_size.y / 2 + 30))
		elif config.get_value(section, "4") == OS.get_process_id():
			DisplayServer.window_set_position(Vector2(screen_size.x / 2,screen_size.y / 2 + 30))
	
	DisplayServer.window_set_current_screen(1)
	mutex.unlock()

For some reason, sometimes a window or two will be moved to a corner that already has a window!?

If anyone has a better solution than this, please share! This feels like a very broken way to achieve the goal…

I ended up scrapping the configfile idea and left just the window re-sizing in the ready function of the scene. I then bit the bullet and learned to compile the source. I cloned 4.2.1-stable, modified the code per these changes:
Support to customize launching position for every debug instance by kdada · Pull Request #67587 · godotengine/godot · GitHub

Then built my custom Godot. It is working great, but I now have a warning that I’m not sure how to resolve. Sure I can ignore it, but I’m hopeful someone can give me quick instruction on how to resolve?

The warning is:
RenderingDeviceVulkan::_load_pipeline_cache: Invalid pipelines cache header.
<C++ Source> drivers\vulkan\rendering_device_vulkan.cpp:9200 @ RenderingDeviceVulkan::_load_pipeline_cache()