Fix #142314: Crash popup blocks automation in background mode
Crash popups were being displayed even when Blender was running in background mode, causing the process to hang and blocking automated workflows (e.g., render farms). Therefore, disable the crash popup when running in background mode. Pull Request: https://projects.blender.org/blender/blender/pulls/142518
This commit is contained in:
committed by
Thomas Dinges
parent
c7ac5240d8
commit
66ef7f5621
@@ -43,12 +43,16 @@ int BLI_system_memory_max_in_megabytes_int(void);
|
||||
# define BLI_SYSTEM_PID_H <process.h>
|
||||
|
||||
/**
|
||||
* \note Use `void *` for `exception` since we really do not want to drag Windows.h
|
||||
* \note Use `void *` for `os_info` since we really do not want to drag Windows.h
|
||||
* in to get the proper `typedef`.
|
||||
*/
|
||||
void BLI_windows_exception_capture(void *exception);
|
||||
void BLI_windows_exception_show_dialog(const void *exception,
|
||||
const char *filepath_crashlog,
|
||||
void BLI_windows_exception_print_message(const void *os_info);
|
||||
|
||||
/**
|
||||
* Displays a crash report dialog with options to open the crash log, restart the application, and
|
||||
* report a bug. This is based on the `showMessageBox` function in `GHOST_SystemWin32.cc`.
|
||||
*/
|
||||
void BLI_windows_exception_show_dialog(const char *filepath_crashlog,
|
||||
const char *filepath_relaunch,
|
||||
const char *gpu_name,
|
||||
const char *build_version);
|
||||
|
||||
@@ -425,14 +425,13 @@ void BLI_system_backtrace_with_os_info(FILE *fp, const void *os_info)
|
||||
bli_windows_system_backtrace_modules(fp);
|
||||
}
|
||||
|
||||
static void bli_windows_exception_message_get(const EXCEPTION_POINTERS *exception,
|
||||
char r_message[512])
|
||||
void BLI_windows_exception_print_message(const void *os_info)
|
||||
{
|
||||
if (!exception) {
|
||||
r_message[0] = '\0';
|
||||
if (!os_info) {
|
||||
return;
|
||||
}
|
||||
|
||||
const EXCEPTION_POINTERS *exception = static_cast<const EXCEPTION_POINTERS *>(os_info);
|
||||
const char *exception_name = bli_windows_get_exception_description(
|
||||
exception->ExceptionRecord->ExceptionCode);
|
||||
LPVOID address = exception->ExceptionRecord->ExceptionAddress;
|
||||
@@ -440,7 +439,8 @@ static void bli_windows_exception_message_get(const EXCEPTION_POINTERS *exceptio
|
||||
bli_windows_get_module_name(address, modulename, sizeof(modulename));
|
||||
DWORD threadId = GetCurrentThreadId();
|
||||
|
||||
BLI_snprintf(r_message,
|
||||
char message[512];
|
||||
BLI_snprintf(message,
|
||||
512,
|
||||
"Error : %s\n"
|
||||
"Address : 0x%p\n"
|
||||
@@ -450,6 +450,9 @@ static void bli_windows_exception_message_get(const EXCEPTION_POINTERS *exceptio
|
||||
address,
|
||||
modulename,
|
||||
threadId);
|
||||
|
||||
fprintf(stderr, message);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -571,14 +574,10 @@ static std::wstring url_encode_wstring(const std::string &str)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a crash report dialog with options to open the crash log, restart the application, and
|
||||
* report a bug. This is based on the `showMessageBox` function in `GHOST_SystemWin32.cc`.
|
||||
*/
|
||||
static void bli_show_crash_report_dialog(const char *filepath_crashlog,
|
||||
const char *filepath_relaunch,
|
||||
const char *gpu_name,
|
||||
const char *build_version)
|
||||
void BLI_windows_exception_show_dialog(const char *filepath_crashlog,
|
||||
const char *filepath_relaunch,
|
||||
const char *gpu_name,
|
||||
const char *build_version)
|
||||
{
|
||||
/* Redundant: #InitCommonControls is already called during GHOST System initialization. */
|
||||
// InitCommonControls();
|
||||
@@ -683,18 +682,4 @@ static void bli_show_crash_report_dialog(const char *filepath_crashlog,
|
||||
free((void *)filepath_relaunch_utf16);
|
||||
}
|
||||
|
||||
void BLI_windows_exception_show_dialog(const void *exception,
|
||||
const char *filepath_crashlog,
|
||||
const char *filepath_relaunch,
|
||||
const char *gpu_name,
|
||||
const char *build_version)
|
||||
{
|
||||
char message[512];
|
||||
bli_windows_exception_message_get(static_cast<const EXCEPTION_POINTERS *>(exception), message);
|
||||
fprintf(stderr, message);
|
||||
fflush(stderr);
|
||||
|
||||
bli_show_crash_report_dialog(filepath_crashlog, filepath_relaunch, gpu_name, build_version);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -171,23 +171,26 @@ extern LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string version;
|
||||
# ifndef BUILD_DATE
|
||||
const char *build_hash = G_MAIN ? G_MAIN->build_hash : "unknown";
|
||||
version = std::string(BKE_blender_version_string()) + ", hash: `" + build_hash + "`";
|
||||
# else
|
||||
version = std::string(BKE_blender_version_string()) + ", Commit date: " + build_commit_date +
|
||||
" " + build_commit_time + ", hash: `" + build_hash + "`";
|
||||
# endif
|
||||
|
||||
char filepath_crashlog[FILE_MAX];
|
||||
BLI_windows_exception_print_message(ExceptionInfo);
|
||||
BKE_blender_globals_crash_path_get(filepath_crashlog);
|
||||
crashlog_file_generate(filepath_crashlog, ExceptionInfo);
|
||||
BLI_windows_exception_show_dialog(ExceptionInfo,
|
||||
filepath_crashlog,
|
||||
G.filepath_last_blend,
|
||||
GPU_platform_gpu_name(),
|
||||
version.c_str());
|
||||
|
||||
/* Disable popup in background mode to avoid blocking automation.
|
||||
* (e.g., when used by a render farm; see #142314). */
|
||||
if (!G.background) {
|
||||
std::string version;
|
||||
# ifndef BUILD_DATE
|
||||
const char *build_hash = G_MAIN ? G_MAIN->build_hash : "unknown";
|
||||
version = std::string(BKE_blender_version_string()) + ", hash: `" + build_hash + "`";
|
||||
# else
|
||||
version = std::string(BKE_blender_version_string()) + ", Commit date: " + build_commit_date +
|
||||
" " + build_commit_time + ", hash: `" + build_hash + "`";
|
||||
# endif
|
||||
|
||||
BLI_windows_exception_show_dialog(
|
||||
filepath_crashlog, G.filepath_last_blend, GPU_platform_gpu_name(), version.c_str());
|
||||
}
|
||||
sig_cleanup_and_terminate(SIGSEGV);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user