godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.61k stars 21.28k forks source link

Command line export doesn't exit if there is a build error #91527

Open miv391 opened 7 months ago

miv391 commented 7 months ago

Tested versions

Reproducible in

System information

Godot v4.3.dev6.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.5212) - Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 Threads)

Issue description

If I try to export the project from command line but there is build error, either GDScript error or C# error, Godot executable doesn't exit. I need to press Ctrl-C to exit.

A build error seems to cause this problem every time. But I also noticed that sometimes even working build doesn't exit cleanly if I ran the export command from Window's bat-file. However, I don't know to reprocude that.

I also wonder, if it would be better to instantly quit the exporting process, if the build fails. Now the process continues with the savepack.

This is a somewhat shortened and anonymized output:

λ "C:\godot\Godot_v4.3-dev6_mono_win64\Godot_v4.3-dev6_mono_win64_console.exe" --verbose --headless --no-window --export-release "Windows Desktop"
Godot Engine v4.3.dev6.mono.official.89850d553 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Using "default" pen tablet driver...

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
.NET: Initializing module...
Found hostfxr: C:\Program Files\dotnet\host/fxr/8.0.4/hostfxr.dll
.NET: hostfxr initialized
.NET: GodotPlugins initialized
CORE API HASH: 3400182566
EDITOR API HASH: 130872444
EditorSettings: Load OK!
EditorTheme: Generating new theme for the config '66886095'.
EditorTheme: Generating new icons.
EditorTheme: Generating new fonts.
EditorTheme: Generating new styles.
Found .NET Sdk version '8.0.204': C:\Program Files\dotnet\sdk\8.0.204
Loaded system CA certificates
Failed to bind socket. Error: 3
Failed to bind socket. Error: 3
EditorSettings: Save OK!
update_scene_groups: begin: Update Scene Groups steps: 16
        update_scene_groups: step 0: Updating Scene Groups...
        update_scene_groups: step 1: Updating Scene Groups...
        update_scene_groups: step 2: Updating Scene Groups...
        update_scene_groups: step 3: Updating Scene Groups...
        update_scene_groups: step 4: Updating Scene Groups...
        update_scene_groups: step 5: Updating Scene Groups...
        update_scene_groups: step 6: Updating Scene Groups...
        update_scene_groups: step 7: Updating Scene Groups...
        update_scene_groups: step 8: Updating Scene Groups...
        update_scene_groups: step 9: Updating Scene Groups...
        update_scene_groups: step 10: Updating Scene Groups...
        update_scene_groups: step 11: Updating Scene Groups...
        update_scene_groups: step 12: Updating Scene Groups...
        update_scene_groups: step 13: Updating Scene Groups...
        update_scene_groups: step 14: Updating Scene Groups...
        update_scene_groups: step 15: Updating Scene Groups...
update_scene_groups: end
dotnet_publish_project: begin: Publishing .NET project... steps: 1
        dotnet_publish_project: step 0: Running dotnet publish
Running:  "C:\Program Files\dotnet\dotnet.EXE" publish C:/godot/foo/bar.csproj -c ExportRelease -r win-x64 --self-contained true -v normal -l:GodotTools.BuildLogger.GodotBuildLogger,... ...
dotnet publish exited with code: 1. Log file: ...
dotnet_publish_project: end
ERROR: Failed to export project: Failed to build project.
   at: void GodotTools.Export.ExportPlugin._ExportBegin(System.String[], bool, string, uint) (/root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:123)
System.InvalidOperationException: Failed to build project.
   at GodotTools.Export.ExportPlugin._ExportBeginImpl(String[] features, Boolean isDebug, String path, Int64 flags) in /root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:line 255
   at GodotTools.Export.ExportPlugin._ExportBegin(String[] features, Boolean isDebug, String path, UInt32 flags) in /root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:line 123
savepack: begin: Packing steps: 102
...
savepack: end
ERROR: Attempting to parent and popup a dialog that already has a parent.
   at: (scene/main/window.cpp:1838)                          <--- !!! 4.3 beta1 hangs after this line !!!
EditorSettings: Save OK!
Unloading: Disposing tracked instances...
Unloading: Finished disposing tracked instances.
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2314)
Leaked instance: Image:9223373671391885761 - Resource path:
Leaked instance: Image:9223373672683731395 - Resource path:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: _setup_local_to_scene (static: 0, total: 2)
Orphan StringName: EditorFileDialog (static: 1, total: 7)
Orphan StringName: AudioStream (static: 0, total: 1)
Orphan StringName: ItemList (static: 1, total: 9)
Orphan StringName: TabBar (static: 1, total: 9)
Orphan StringName: FileDialog (static: 6, total: 12)
Orphan StringName: AudioStreamRandomizer (static: 1, total: 5)
Orphan StringName: export_presets_runnable_updated (static: 0, total: 1)
Orphan StringName: OptionButton (static: 2, total: 12)
Orphan StringName: Node (static: 12, total: 13)
Orphan StringName: export_presets_updated (static: 0, total: 1)
Orphan StringName: Texture2D (static: 0, total: 5)
Orphan StringName: PopupMenu (static: 1, total: 15)
StringName: 13 unclaimed string names at exit.
^C                                                   <--- !!! pressing Ctrl-C here !!!

This is what Windows task manager displays while building: kuva and finally after the error message: kuva After pressing Ctrl-C .NET Host and Godot Engine (Console) disappear from Task manager.

Steps to reproduce

  1. Add some build breaking error to the project code.
  2. Run "Godot_v4.3-beta1_mono_win64\Godot_v4.3-beta1_mono_win64_console.exe" --verbose --headless --no-window --export-release "Windows Desktop"

Minimal reproduction project (MRP)

N/A

robert-wallis commented 6 months ago

image

I've noticed something similar, however when I look at Task Manager the process actually did quit. And when I simply press RETURN a few times on the keyboard, an empty prompt appears in the text (see the top few lines of the following screenshot) image

Is this the same in your case?

Steps to reproduce:

  1. use godot 4.3.dev on Windows in Powershell
  2. cd to a folder where a godot project does not exist, like ~/Desktop
  3. run the command godot --headless -v --export-release "anything" anything.exe
  4. appears to not exit, but does exit

Also this causes a crash and that crash should be fixed too.

image

robert-wallis commented 6 months ago

Here's the backtrace with a dev version of where it's crashing (separate issue likely)

PS C:\Users\Robert\Desktop> godot-dev --headless -v --export-release "anything" anything.exe
PS C:\Users\Robert\Desktop> Godot Engine v4.3.beta.custom_build.0f8ac836d (2024-05-30 14:46:59 UTC) - https://godotengig
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Using "default" pen tablet driver...

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CORE API HASH: 1850817670
EDITOR API HASH: 112790890
ERROR: Class 'EditorSettings' can only be instantiated by editor.
   at: ClassDB::_instantiate_internal (core\object\class_db.cpp:509)

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.beta.custom_build (0f8ac836d5dbf063d82efa5964f9e0d75f70f4cd)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] EditorSettings::create (C:\Users\Robert\Dev\Godot\godot\editor\editor_settings.cpp:1060)
[1] EditorSettings::create (C:\Users\Robert\Dev\Godot\godot\editor\editor_settings.cpp:1060)
[2] EditorNode::EditorNode (C:\Users\Robert\Dev\Godot\godot\editor\editor_node.cpp:6426)
[3] Main::start (C:\Users\Robert\Dev\Godot\godot\main\main.cpp:3689)
[4] widechar_main (C:\Users\Robert\Dev\Godot\godot\platform\windows\godot_windows.cpp:179)
[5] _main (C:\Users\Robert\Dev\Godot\godot\platform\windows\godot_windows.cpp:206)
[6] main (C:\Users\Robert\Dev\Godot\godot\platform\windows\godot_windows.cpp:220)
[7] WinMain (C:\Users\Robert\Dev\Godot\godot\platform\windows\godot_windows.cpp:234)
[8] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[9] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================
akien-mga commented 6 months ago

Does this crash only happen in 4.3 versions, or also 4.2?

robert-wallis commented 6 months ago

This particular terminal issue doesn't even need a crash for me and is reproducible with 4.2.2 stable

Repro Steps:

  1. godot --version
  2. terminal appears to hang
  3. type echo $?
  4. the value echo command prints True because godot --version exited successfully

https://github.com/godotengine/godot/assets/145938/1c27935b-7e90-4324-b2c1-3df1f4564203

robert-wallis commented 6 months ago

It's not limited to Terminal, Command Prompt (cmd.exe) also shows this issue.

  1. open cmd.exe
  2. godot --version
  3. looks like it's hung
  4. echo %errorlevel%
  5. echo executes and returns 0 (success)
bruvzg commented 6 months ago

Are you running *.console.exe executable? If not, this is expected, it's GUI executable and it doesn't own the console, so shell have no idea it should redraw the prompt.

robert-wallis commented 6 months ago

Using the .console.exe executable solves this issue for me, thanks @bruvzg !

miv391 commented 6 months ago

Still hangs with v4.3.beta1.mono.official [a4f2ea91a], but now it hangs immediately after "ERROR: Attempting to parent and popup a dialog that already has a parent.". I made some updates to the issues description.

lokimckay commented 6 months ago

I also have this issue using Godot 4.2.2 stable and executing the *.console.exe binary like so

Godot_v4.2.2-stable_win64_console.exe --headless --path <path> --export-release <preset> output.exe