### Godot version

7022271291a3d2a9cbd6a223d22a29fd775dfc5d

### System information

Windows 11, gl_compatibility, NVidia RTX 3070 TI

### Issue description

A deadlock can occur during application startup with the following:
* Main Thread: locks the DisplayServerWindows mutex during DisplayServerWindows::_get_screens_origin()
* Worker Thread: Surface Upgrade Tool attempts to change window title calling DisplayServerWindows::window_set_title()

The Worker Thread owns the DisplayServerWindows mutex and is trying to do a blocking SetWindowTextW call - a call which requires the Main Thread message pump to process; however the Main Thread is blocked trying to get hold of the very mutex locked by the worker thread.

Main Thread Call Stack:
```
godot.windows.editor.dev.x86_64.exe!MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock<MutexImpl<std::recursive_mutex>>(const MutexImpl<std::recursive_mutex> & p_mutex) Line 129	C++
godot.windows.editor.dev.x86_64.exe!DisplayServerWindows::_get_screens_origin() Line 663	C++
godot.windows.editor.dev.x86_64.exe!DisplayServerWindows::mouse_get_position() Line 429	C++
godot.windows.editor.dev.x86_64.exe!Viewport::get_mouse_position() Line 1391	C++
godot.windows.editor.dev.x86_64.exe!CanvasItem::get_global_mouse_position() Line 1047	C++
godot.windows.editor.dev.x86_64.exe!CanvasItem::get_local_mouse_position() Line 1054	C++
godot.windows.editor.dev.x86_64.exe!EditorToaster::_notification(int p_what) Line 51	C++
godot.windows.editor.dev.x86_64.exe!EditorToaster::_notificationv(int p_notification, bool p_reversed) Line 43	C++
godot.windows.editor.dev.x86_64.exe!Object::notification(int p_notification, bool p_reversed) Line 840	C++
godot.windows.editor.dev.x86_64.exe!SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 950	C++
godot.windows.editor.dev.x86_64.exe!SceneTree::_process(bool p_physics) Line 1031	C++
godot.windows.editor.dev.x86_64.exe!SceneTree::process(double p_time) Line 510	C++
godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 3636	C++
godot.windows.editor.dev.x86_64.exe!OS_Windows::run() Line 1474	C++
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 182	C++
godot.windows.editor.dev.x86_64.exe!_main() Line 204	C++
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 218	C++
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 232	C++
[External Code]	
```

Worker Thread Call Stack:
```
godot.windows.editor.dev.x86_64.exe!DisplayServerWindows::window_set_title(const String & p_title, int p_window) Line 1228	C++
godot.windows.editor.dev.x86_64.exe!EditorNode::_update_title() Line 303	C++
godot.windows.editor.dev.x86_64.exe!EditorNode::_update_from_settings() Line 349	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_helper<EditorNode>(EditorNode * p_instance, void(EditorNode::*)() p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<> __formal) Line 308	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args<EditorNode>(EditorNode * p_instance, void(EditorNode::*)() p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 418	C++
godot.windows.editor.dev.x86_64.exe!CallableCustomMethodPointer<EditorNode>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 105	C++
godot.windows.editor.dev.x86_64.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 58	C++
godot.windows.editor.dev.x86_64.exe!Object::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 1128	C++
godot.windows.editor.dev.x86_64.exe!Object::emit_signal<>(const StringName & p_name) Line 922	C++
godot.windows.editor.dev.x86_64.exe!ProjectSettings::_emit_changed() Line 458	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_helper<ProjectSettings>(ProjectSettings * p_instance, void(ProjectSettings::*)() p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<> __formal) Line 308	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args<ProjectSettings>(ProjectSettings * p_instance, void(ProjectSettings::*)() p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 418	C++
godot.windows.editor.dev.x86_64.exe!CallableCustomMethodPointer<ProjectSettings>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 105	C++
godot.windows.editor.dev.x86_64.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 58	C++
godot.windows.editor.dev.x86_64.exe!CallQueue::_call_function(const Callable & p_callable, const Variant * p_args, int p_argcount, bool p_show_error) Line 220	C++
godot.windows.editor.dev.x86_64.exe!CallQueue::flush() Line 326	C++
godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 3615	C++
godot.windows.editor.dev.x86_64.exe!EditorNode::immediate_confirmation_dialog(const String & p_text, const String & p_ok_text, const String & p_cancel_text, unsigned int p_wrap_width) Line 5579	C++
godot.windows.editor.dev.x86_64.exe!SurfaceUpgradeTool::_show_popup() Line 89	C++
godot.windows.editor.dev.x86_64.exe!SurfaceUpgradeTool::_try_show_popup() Line 75	C++
godot.windows.editor.dev.x86_64.exe!RenderingServer::fix_surface_compatibility(RenderingServer::SurfaceData & p_surface, const String & p_path) Line 2138	C++
godot.windows.editor.dev.x86_64.exe!ArrayMesh::_set_surfaces(const Array & p_surfaces) Line 1643	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_helper<ArrayMesh,Array const &,0>(ArrayMesh * p_instance, void(ArrayMesh::*)(const Array &) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0> __formal) Line 303	C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_dv<ArrayMesh,Array const &>(ArrayMesh * p_instance, void(ArrayMesh::*)(const Array &) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error, const Vector<Variant> & default_values) Line 451	C++
godot.windows.editor.dev.x86_64.exe!MethodBindT<ArrayMesh,Array const &>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 337	C++
godot.windows.editor.dev.x86_64.exe!ClassDB::set_property(Object * p_object, const StringName & p_property, const Variant & p_value, bool * r_valid) Line 1235	C++
godot.windows.editor.dev.x86_64.exe!Object::set(const StringName & p_name, const Variant & p_value, bool * r_valid) Line 257	C++
godot.windows.editor.dev.x86_64.exe!ResourceLoaderBinary::load() Line 836	C++
godot.windows.editor.dev.x86_64.exe!ResourceFormatLoaderBinary::load(const String & p_path, const String & p_original_path, Error * r_error, bool p_use_sub_threads, float * r_progress, ResourceFormatLoader::CacheMode p_cache_mode) Line 1198	C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error, bool p_use_sub_threads, float * r_progress) Line 261	C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_thread_load_function(void * p_userdata) Line 319	C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_load_start(const String & p_path, const String & p_type_hint, ResourceLoader::LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode) Line 501	C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error) Line 418	C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreviewGenerator::generate_from_path(const String & p_path, const Vector2 & p_size, Dictionary & p_metadata) Line 68	C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_generate_preview(Ref<ImageTexture> & r_texture, Ref<ImageTexture> & r_small_texture, const EditorResourcePreview::QueueItem & p_item, const String & cache_base, Dictionary & p_metadata) Line 159	C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_iterate() Line 251	C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_thread() Line 338	C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_thread_func(void * ud) Line 103	C++
godot.windows.editor.dev.x86_64.exe!Thread::callback(unsigned __int64 p_caller_id, const Thread::Settings & p_settings, void(*)(void *) p_callback, void * p_userdata) Line 63	C++
[External Code]	
godot.windows.editor.dev.x86_64.exe!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97	C++
```

### Steps to reproduce

Happens when opening a project that has many meshes. This occurred opening https://github.com/Malcolmnixon/TiltFiveMapTest

### Minimal reproduction project

It seems to be a russian-roulette with large projects - the project in the reproduce steps causes it.
if (!inspector_only && !skip_main_plugin) {
				skip_main_plugin = stay_in_script_editor_on_node_selected && !ScriptEditor::get_singleton()->is_editor_floating() && ScriptEditor::get_singleton()->is_visible_in_tree();
			}
		} else {
			NodeDock::get_singleton()->set_node(nullptr);
			SceneTreeDock::get_singleton()->set_selected(nullptr);
			InspectorDock::get_singleton()->update(nullptr);
		}
		if (get_edited_scene() && !get_edited_scene()->get_scene_file_path().is_empty()) {
			String source_scene = get_edited_scene()->get_scene_file_path();
			if (FileAccess::exists(source_scene + ".import")) {
				editable_info = TTR("This scene was imported, so changes to it won't be kept.\nInstantiating or inheriting it will allow you to make changes to it.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
				info_is_warning = true;
			}
		}
	} else {
		Node *selected_node = nullptr;
		if (current_obj->is_class("MultiNodeEdit")) {
			Node *scene = get_edited_scene();
			if (scene) {
				MultiNodeEdit *multi_node_edit = Object::cast_to<MultiNodeEdit>(current_obj);
				int node_count = multi_node_edit->get_node_count();
				if (node_count > 0) {
					List<Node *> multi_nodes;
					for (int node_index = 0; node_index < node_count; ++node_index) {
						Node *node = scene->get_node(multi_node_edit->get_node(node_index));
						if (node) {
							multi_nodes.push_back(node);
						}
					}