Skip to content

Commit b275237

Browse files
committed
Merge pull request #113267 from bruvzg/mac_headless_inst
[macOS] Do not use `openApplicationAtURL` for headless instances.
2 parents 7135bb5 + 17fa521 commit b275237

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

platform/macos/godot_main_macos.mm

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,6 @@ int main(int argc, char **argv) {
6161
bool is_embedded = false;
6262
bool is_headless = false;
6363

64-
const char *headless_args[] = {
65-
"--headless",
66-
"-h",
67-
"--help",
68-
"/?",
69-
"--version",
70-
"--dump-gdextension-interface",
71-
"--dump-extension-api",
72-
"--dump-extension-api-with-docs",
73-
"--validate-extension-api",
74-
"--convert-3to4",
75-
"--validate-conversion-3to4",
76-
"--doctool",
77-
};
78-
7964
for (int i = 0; i < argc; i++) {
8065
if (strcmp("-NSDocumentRevisionsDebugMode", argv[i]) == 0) {
8166
// remove "-NSDocumentRevisionsDebugMode" and the next argument
@@ -94,8 +79,8 @@ int main(int argc, char **argv) {
9479
if (strcmp("--embedded", argv[i]) == 0) {
9580
is_embedded = true;
9681
}
97-
for (size_t j = 0; j < std::size(headless_args); j++) {
98-
if (strcmp(headless_args[j], argv[i]) == 0) {
82+
for (size_t j = 0; j < std::size(OS_MacOS::headless_args); j++) {
83+
if (strcmp(OS_MacOS::headless_args[j], argv[i]) == 0) {
9984
is_headless = true;
10085
break;
10186
}

platform/macos/os_macos.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@ class OS_MacOS : public OS_Unix {
7979
virtual void delete_main_loop() override;
8080

8181
public:
82+
static inline const char *headless_args[] = {
83+
"--headless",
84+
"-h",
85+
"--help",
86+
"/?",
87+
"--version",
88+
"--dump-gdextension-interface",
89+
"--dump-extension-api",
90+
"--dump-gdextension-interface-json",
91+
"--dump-extension-api-with-docs",
92+
"--validate-extension-api",
93+
"--convert-3to4",
94+
"--validate-conversion-3to4",
95+
"--doctool",
96+
"--test",
97+
};
98+
8299
virtual void add_frame_delay(bool p_can_draw, bool p_wake_for_events) override;
83100

84101
virtual void set_cmdline_platform_args(const List<String> &p_args);

platform/macos/os_macos.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@
852852
}
853853

854854
Error OS_MacOS::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) {
855+
// Do not run headless instance as app bundle, since it will never send `applicationDidFinishLaunching` and register as failed start after timeout.
856+
for (size_t i = 0; i < std::size(OS_MacOS::headless_args); i++) {
857+
if (p_arguments.find(String(OS_MacOS::headless_args[i]))) {
858+
return OS_Unix::create_process(get_executable_path(), p_arguments, r_child_id, false);
859+
}
860+
}
861+
855862
// If executable is bundled, always execute editor instances as an app bundle to ensure app window is registered and activated correctly.
856863
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
857864
if (nsappname != nil) {

0 commit comments

Comments
 (0)