Hang/Freeze when calling PackedScene sc = GD.Load<PackedScene>("res://scenes/tiles/TileDarkGray.tscn");

Godot Version

4.2.1

Question

Experimenting in C# class polymorphism with Godot, I get an intermittent freeze/hang when calling (example):

PackedScene sc = GD.Load(“res://scenes/tiles/TileDarkGray.tscn”);

The scene file is there, it works fine in Godot editor, and will load sometimes. There’s more around this of course, like a base scene, adding a viewport and such. However, it hangs/freeze on the GD.Load, not on adding to the tree.

Is there some extra debugging that can be enabled in Godot? If documented, just pointing me to the doc is great.

As a note, here’s the stack trace from VS when I break all:

[External Code]

GodotSharp.dll!Godot.NativeInterop.NativeFuncs.godotsharp_internal_new_csharp_script(Godot.NativeInterop.godot_ref* r_dest) Line 162 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.CreateScriptBridgeForType(System.Type scriptType, Godot.NativeInterop.godot_ref* outScript) Line 515 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForType(System.Type scriptType, Godot.NativeInterop.godot_ref* outScript) Line 466 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForPath(Godot.NativeInterop.godot_string* scriptPath, Godot.NativeInterop.godot_ref* outScript) Line 451 C#
[External Code]
GodotSharp.dll!Godot.NativeInterop.NativeFuncs.godotsharp_internal_script_load(Godot.NativeInterop.godot_string p_path, Godot.NativeInterop.godot_ref* r_dest) Line 169 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.GetOrLoadOrCreateScriptForType(System.Type scriptType, Godot.NativeInterop.godot_ref* outScript) Line 502 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.UpdateScriptClassInfo(nint scriptPtr, Godot.NativeInterop.godot_string* outClassName, Godot.NativeInterop.godot_bool* outTool, Godot.NativeInterop.godot_bool* outGlobal, Godot.NativeInterop.godot_bool* outAbstract, Godot.NativeInterop.godot_string* outIconPath, Godot.NativeInterop.godot_array* outMethodsDest, Godot.NativeInterop.godot_dictionary* outRpcFunctionsDest, Godot.NativeInterop.godot_dictionary* outEventSignalsDest, Godot.NativeInterop.godot_ref* outBaseScript) Line 793 C#
[External Code]
GodotSharp.dll!Godot.NativeInterop.NativeFuncs.godotsharp_internal_reload_registered_script(nint scriptPtr) Line 175 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.CreateScriptBridgeForType(System.Type scriptType, Godot.NativeInterop.godot_ref* outScript) Line 521 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForType(System.Type scriptType, Godot.NativeInterop.godot_ref* outScript) Line 466 C#
GodotSharp.dll!Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForPath(Godot.NativeInterop.godot_string* scriptPath, Godot.NativeInterop.godot_ref* outScript) Line 451 C#
[External Code]
GodotSharp.dll!Godot.NativeInterop.NativeFuncs.godotsharp_method_bind_ptrcall(nint p_method_bind, nint p_instance, void** p_args, void* p_ret) Line 353 C#
GodotSharp.dll!Godot.NativeCalls.godot_icall_3_981(nint method, nint ptr, string arg1, string arg2, int arg3) Line 9004 C#
GodotSharp.dll!Godot.ResourceLoader.Load(string path, string typeHint, Godot.ResourceLoader.CacheMode cacheMode) Line 100 C#
GodotSharp.dll!Godot.ResourceLoader.Load<Godot.PackedScene>(string path, string typeHint, Godot.ResourceLoader.CacheMode cacheMode) Line 27 C#
GodotSharp.dll!Godot.GD.Load<Godot.PackedScene>(string path) Line 129 C#
Grgm!grgm.tactical.GCGIF.CreateGCGI(gamebase.data.DataUnitGameItem du, int l, int c, grgm.tactical.GridMapTactical gm, gamebase.systems.MouseInputService misMap) Line 35 C#
Grgm!grgm.tactical.GridMapTactical.AddMapLocation(gamebase.data.DataUnitGameItem duResident, int l, int c) Line 160 C#
Grgm!gamebase.gridmap.GridMapContainer.AddMapLocations(gamebase.data.DatumLocation dl, gamebase.data.ActorTypes actor) Line 265 C#
Grgm!gamebase.gridmap.GridMapContainer.SetupMapResidents() Line 252 C#
Grgm!grgm.tactical.GridMapTactical.SetupMapResidents() Line 166 C#
Grgm!Game.SetupMapAbstract() Line 470 C#
Grgm!Game.ProcessMessage(gamebase.message.Message m) Line 183 C#
Grgm!gamebase.message.MessageCenter.ProcessMessages() Line 128 C#
Grgm!Game._Process(double delta) Line 66 C#
GodotSharp.dll!Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name method, Godot.NativeInterop.NativeVariantPtrArgs args, out Godot.NativeInterop.godot_variant ret) Line 2111 C#
Grgm!gamebase.baseobject.BGONode.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name method, Godot.NativeInterop.NativeVariantPtrArgs args, out Godot.NativeInterop.godot_variant ret) Line 100 C#
Grgm!Game.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name method, Godot.NativeInterop.NativeVariantPtrArgs args, out Godot.NativeInterop.godot_variant ret) Line 218 C#
GodotSharp.dll!Godot.Bridge.CSharpInstanceBridge.Call(nint godotObjectGCHandle, Godot.NativeInterop.godot_string_name* method, Godot.NativeInterop.godot_variant** args, int argCount, Godot.NativeInterop.godot_variant_call_error* refCallError, Godot.NativeInterop.godot_variant* ret) Line 24 C#
[External Code]

Thanks!

can you create a short c# example that reproduces this issue? might also help to show us the tree for TileDarkGray.tscn

There’s quite a bit of code to get to that issue. It’s a port of an engine running on MonoGame. Also, it fails/hangs of multiple different scenes, most as simple as a Node2D-Sprite2D. I’m building the tree programmatically, and adding scenes into it.

What I’m looking for is enabling more advanced/verbose debugging. If that’s not doable, I’ll probably need to figure out how to setup godot build, and get more debugging symbols to dig deeper. Any suggestion is appreciated.