From d3265a09bbbf509550de9b7363e9d0e15c821cf5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Tue, 2 Dec 2025 00:44:56 +0200 Subject: [PATCH] #5084 Ressurect Watchdog --- indra/newview/app_settings/settings.xml | 19 ++++++++--- indra/newview/llappviewer.cpp | 42 ++++++++++++++----------- indra/newview/llappviewer.h | 8 +++-- indra/newview/llappviewerwin32.cpp | 11 +++++-- indra/newview/llwatchdog.cpp | 12 ++++++- 5 files changed, 63 insertions(+), 29 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3dbb5dca1f4..fe31a00ba33 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4484,13 +4484,24 @@ MainloopTimeoutDefault Comment - Timeout duration for mainloop lock detection, in seconds. + Timeout duration for mainloop lock detection during teleports, login and logout, in seconds. Persist 1 Type F32 Value - 60.0 + 120.0 + + MainloopTimeoutStarted + + Comment + Timeout duration for mainloop lock detection when logged in and not teleporting, in seconds. + Persist + 1 + Type + F32 + Value + 30.0 MapScale @@ -13862,13 +13873,13 @@ WatchdogEnabled Comment - Controls whether the thread watchdog timer is activated. Value is boolean. Set to -1 to defer to built-in default. + Controls whether the thread watchdog timer is activated. Value is S32. Set to -1 to defer to built-in default. Persist 0 Type S32 Value - 0 + 1 WaterGLFogDensityScale diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 72bfdcf83c3..f6f5f1717b6 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3145,7 +3145,7 @@ bool LLAppViewer::initWindow() // Need to load feature table before cheking to start watchdog. bool use_watchdog = false; - int watchdog_enabled_setting = gSavedSettings.getS32("WatchdogEnabled"); + S32 watchdog_enabled_setting = gSavedSettings.getS32("WatchdogEnabled"); if (watchdog_enabled_setting == -1) { use_watchdog = !LLFeatureManager::getInstance()->isFeatureAvailable("WatchdogDisabled"); @@ -5820,12 +5820,12 @@ void LLAppViewer::forceExceptionThreadCrash() thread->start(); } -void LLAppViewer::initMainloopTimeout(std::string_view state, F32 secs) +void LLAppViewer::initMainloopTimeout(std::string_view state) { if (!mMainloopTimeout) { mMainloopTimeout = new LLWatchdogTimeout(); - resumeMainloopTimeout(state, secs); + resumeMainloopTimeout(state); } } @@ -5838,17 +5838,11 @@ void LLAppViewer::destroyMainloopTimeout() } } -void LLAppViewer::resumeMainloopTimeout(std::string_view state, F32 secs) +void LLAppViewer::resumeMainloopTimeout(std::string_view state) { if (mMainloopTimeout) { - if (secs < 0.0f) - { - static LLCachedControl mainloop_timeout(gSavedSettings, "MainloopTimeoutDefault", 60.f); - secs = mainloop_timeout; - } - - mMainloopTimeout->setTimeout(secs); + mMainloopTimeout->setTimeout(getMainloopTimeoutSec()); mMainloopTimeout->start(state); } } @@ -5861,23 +5855,33 @@ void LLAppViewer::pauseMainloopTimeout() } } -void LLAppViewer::pingMainloopTimeout(std::string_view state, F32 secs) +void LLAppViewer::pingMainloopTimeout(std::string_view state) { LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; if (mMainloopTimeout) { - if (secs < 0.0f) - { - static LLCachedControl mainloop_timeout(gSavedSettings, "MainloopTimeoutDefault", 60); - secs = mainloop_timeout; - } - - mMainloopTimeout->setTimeout(secs); + mMainloopTimeout->setTimeout(getMainloopTimeoutSec()); mMainloopTimeout->ping(state); } } + +F32 LLAppViewer::getMainloopTimeoutSec() const +{ + if (LLStartUp::getStartupState() == STATE_STARTED + && gAgent.getTeleportState() == LLAgent::TELEPORT_NONE) + { + static LLCachedControl mainloop_started(gSavedSettings, "MainloopTimeoutStarted", 30.f); + return mainloop_started(); + } + else + { + static LLCachedControl mainloop_default(gSavedSettings, "MainloopTimeoutDefault", 120.f); + return mainloop_default(); + } +} + void LLAppViewer::handleLoginComplete() { gLoggedInTime.start(); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index c12b2e83efb..61c206bcec5 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -204,11 +204,13 @@ class LLAppViewer : public LLApp // For thread debugging. // llstartup needs to control init. // llworld, send_agent_pause() also controls pause/resume. - void initMainloopTimeout(std::string_view state, F32 secs = -1.0f); + void initMainloopTimeout(std::string_view state); void destroyMainloopTimeout(); void pauseMainloopTimeout(); - void resumeMainloopTimeout(std::string_view state = "", F32 secs = -1.0f); - void pingMainloopTimeout(std::string_view state, F32 secs = -1.0f); + void resumeMainloopTimeout(std::string_view state = ""); + void pingMainloopTimeout(std::string_view state); + + F32 getMainloopTimeoutSec() const; // Handle the 'login completed' event. // *NOTE:Mani Fix this for login abstraction!! diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index a9513381384..0620b625d9b 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -176,10 +176,17 @@ namespace LLAppViewer* app = LLAppViewer::instance(); if (!app->isSecondInstance() && !app->errorMarkerExists()) { - // If marker doesn't exist, create a marker with 'other' code for next launch + // If marker doesn't exist, create a marker with 'other' or 'logout' code for next launch // otherwise don't override existing file // Any unmarked crashes will be considered as freezes - app->createErrorMarker(LAST_EXEC_OTHER_CRASH); + if (app->logoutRequestSent()) + { + app->createErrorMarker(LAST_EXEC_LOGOUT_CRASH); + } + else + { + app->createErrorMarker(LAST_EXEC_OTHER_CRASH); + } } } // MDSCB_EXCEPTIONCODE diff --git a/indra/newview/llwatchdog.cpp b/indra/newview/llwatchdog.cpp index bf171fe954c..614d1afc2ad 100644 --- a/indra/newview/llwatchdog.cpp +++ b/indra/newview/llwatchdog.cpp @@ -28,6 +28,7 @@ #include "llviewerprecompiledheaders.h" #include "llwatchdog.h" #include "llthread.h" +#include "llappviewer.h" constexpr U32 WATCHDOG_SLEEP_TIME_USEC = 1000000U; @@ -240,7 +241,16 @@ void LLWatchdog::run() { mTimer->stop(); } - + if (LLAppViewer::instance()->logoutRequestSent()) + { + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_LOGOUT_FROZE); + } + else + { + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_FROZE); + } + // Todo1: warn user? + // Todo2: We probably want to report even if 5 seconds passed, just not error 'yet'. LL_ERRS() << "Watchdog timer expired; assuming viewer is hung and crashing" << LL_ENDL; } }