Merge branch 'better-freeze-catcher' into 'master'
Some checks are pending
Build and test / Ubuntu (push) Waiting to run
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions

Improve Windows crash/freeze catcher UX

See merge request OpenMW/openmw!4630
This commit is contained in:
psi29a 2025-04-13 20:57:12 +00:00
commit 6dd2cac3ec
4 changed files with 12 additions and 10 deletions

View file

@ -237,7 +237,7 @@ namespace Crash
// must remain until monitor has finished
waitMonitor();
std::string message = "OpenMW has encountered a fatal error.\nCrash log saved to '"
std::string message = "OpenMW has encountered a fatal error.\nCrash dump saved to '"
+ Misc::StringUtils::u8StringToString(getCrashDumpPath(*mShm).u8string())
+ "'.\nPlease report this to https://gitlab.com/OpenMW/openmw/issues !";
SDL_ShowSimpleMessageBox(0, "Fatal Error", message.c_str(), nullptr);

View file

@ -21,6 +21,7 @@ namespace Crash
// the main openmw process in task manager.
static constexpr const int CrashCatcherTimeout = 2500;
static constexpr const int CrashCatcherThawTimeout = 250;
struct CrashSHM;

View file

@ -87,9 +87,10 @@ namespace Crash
SetEvent(mSignalAppEvent);
}
bool CrashMonitor::waitApp() const
bool CrashMonitor::waitApp(bool thawMode) const
{
return WaitForSingleObject(mSignalMonitorEvent, CrashCatcherTimeout) == WAIT_OBJECT_0;
return WaitForSingleObject(mSignalMonitorEvent, thawMode ? CrashCatcherThawTimeout : CrashCatcherTimeout)
== WAIT_OBJECT_0;
}
bool CrashMonitor::isAppAlive() const
@ -185,7 +186,7 @@ namespace Crash
frozen = false;
}
if (!mFreezeAbort && waitApp())
if (!mFreezeAbort && waitApp(frozen))
{
shmLock();
@ -215,7 +216,7 @@ namespace Crash
{
handleCrash(true);
TerminateProcess(mAppProcessHandle, 0xDEAD);
std::string message = "OpenMW appears to have frozen.\nCrash log saved to '"
std::string message = "OpenMW has frozen.\nCrash dump saved to '"
+ Misc::StringUtils::u8StringToString(getFreezeDumpPath(*mShm).u8string())
+ "'.\nPlease report this to https://gitlab.com/OpenMW/openmw/issues !";
SDL_ShowSimpleMessageBox(0, "Fatal Error", message.c_str(), nullptr);
@ -289,10 +290,10 @@ namespace Crash
{
std::thread messageBoxThread([&]() {
SDL_MessageBoxButtonData button = { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "Abort" };
SDL_MessageBoxData messageBoxData = { SDL_MESSAGEBOX_ERROR, nullptr, "OpenMW appears to have frozen",
"OpenMW appears to have frozen. Press Abort to terminate it and generate a crash dump.\nIf OpenMW "
"hasn't actually frozen, this message box will disappear a within a few seconds of it becoming "
"responsive.",
SDL_MessageBoxData messageBoxData = { SDL_MESSAGEBOX_ERROR, nullptr, "OpenMW has frozen",
"OpenMW has frozen. This should never happen. Press Abort to terminate it and generate a crash dump to "
"help diagnose the problem.\nOpenMW may unfreeze if you wait, and this message box will disappear "
"after it becomes responsive.",
1, &button, nullptr };
int buttonId;

View file

@ -41,7 +41,7 @@ namespace Crash
void signalApp() const;
bool waitApp() const;
bool waitApp(bool thawMode) const;
bool isAppAlive() const;