Skip to content

#5719 Partial detection of shutdown from task manager#5729

Merged
akleshchev merged 3 commits intodevelopfrom
andreyk/viewer_5719
Apr 30, 2026
Merged

#5719 Partial detection of shutdown from task manager#5729
akleshchev merged 3 commits intodevelopfrom
andreyk/viewer_5719

Conversation

@akleshchev
Copy link
Copy Markdown
Contributor

@akleshchev akleshchev commented Apr 28, 2026

Attempt to detect task manager issued shutdowns. We can't be absolutely certain about the source in this case, but at least try to distinguish termination caused by task manager from 'unknown' crashes.

This change depends onto previous watchdog improvements, so I had to cherry pick it from 26.2 early.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “close request” marker mechanism to better classify viewer terminations (especially Windows Task Manager / external close scenarios) instead of lumping them into generic “unknown” outcomes.

Changes:

  • Introduces a new handlePreCloseRequest() callback to allow fast “about to close” handling (marker creation) before shutdown processing.
  • Adds a new close marker file (SecondLife.close_marker) and integrates it into startup marker processing to refine last-execution classification.
  • Updates Win32 message handling to track SC_CLOSE → WM_CLOSE sequencing and trigger fast-quit behavior for suspected external closes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
indra/newview/llviewerwindow.h Adds handlePreCloseRequest() override to viewer window callbacks.
indra/newview/llviewerwindow.cpp Creates close marker on pre-close; schedules marker cleanup for user-driven close flow.
indra/newview/llappviewer.h Adds APIs to create/remove the new close marker.
indra/newview/llappviewer.cpp Adds close marker constant, processes it in processMarkerFiles(), and implements create/remove helpers.
indra/llwindow/llwindowwin32.h Adds Win32 state flag to track whether SC_CLOSE was received.
indra/llwindow/llwindowwin32.cpp Implements SC_CLOSE tracking and new WM_CLOSE behavior; adds extra logging and adjusts WM_DISPLAYCHANGE handling.
indra/llwindow/llwindowcallbacks.h Adds handlePreCloseRequest() to the window callback interface.
indra/llwindow/llwindowcallbacks.cpp Provides default no-op implementation for handlePreCloseRequest().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread indra/newview/llappviewer.cpp Outdated
Comment thread indra/newview/llappviewer.cpp Outdated
Comment thread indra/newview/llviewerwindow.cpp Outdated
Comment thread indra/llwindow/llwindowwin32.cpp
Comment thread indra/llwindow/llwindowwin32.cpp Outdated
Comment thread indra/llwindow/llwindowwin32.cpp Outdated
Comment thread indra/llwindow/llwindowwin32.cpp Outdated
Comment thread indra/newview/llappviewer.cpp Outdated
Comment thread indra/llwindow/llwindowwin32.cpp Outdated
@akleshchev akleshchev changed the title #5719 Partiald detection of shutdown from task manager #5719 Partial detection of shutdown from task manager Apr 29, 2026
@akleshchev akleshchev force-pushed the andreyk/viewer_5719 branch 2 times, most recently from c417909 to f437f1e Compare April 29, 2026 21:32
@akleshchev akleshchev changed the base branch from release/2026.02 to develop April 29, 2026 21:34
@secondlife secondlife deleted a comment from github-actions Bot Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread indra/llcommon/llwatchdog.cpp
Comment thread indra/llcommon/llwatchdog.cpp Outdated
Comment thread indra/newview/llappviewerwin32.cpp Outdated
Comment thread indra/llcommon/llapp.h Outdated
Comment thread indra/newview/llappviewerwin32.h Outdated
@akleshchev akleshchev requested review from Copilot and marchcat April 30, 2026 12:37
@akleshchev akleshchev marked this pull request as ready for review April 30, 2026 12:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 212 to +220
// mTimer->start() kicks off the thread, any code after
// start needs to use the mSuspectsAccessMutex
mTimer->start();
}
mCreateMarkerFnc = set_error_state_callback;
mCreateMarkerFnc = error_state_callback;
mClearMarkerFnc = clear_marker_callback;
mCrashReportFnc = report_callback;
mNotifyFnc = notify_callback;
mCrashOnFreeze = crash_on_freeze;
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLWatchdog::init() starts the watchdog thread before assigning the callback std::function members. If the timer thread runs before these are set (or sees partially updated state), calling an empty std::function will throw std::bad_function_call and terminate. Assign the callbacks (and mCrashOnFreeze) before starting the timer thread, or initialize them to safe no-op defaults before thread start.

Copilot uses AI. Check for mistakes.
Comment on lines +3286 to +3291
{
LLAppViewer* app = LLAppViewer::instance();
app->sendLogoutRequest();
// Might be better to ask user if user wants to terminate the app or wait.
OSMessageBox(LLTrans::getString("MBFreezeDetected"), LLTrans::getString("MBFatalError"), OSMB_OK);
},
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This notify callback is invoked from the watchdog timer thread. Calling sendLogoutRequest() (touches gMessageSystem/gAgent) and showing OSMessageBox() from that thread can be unsafe and may deadlock or corrupt state. Consider making this callback only schedule work onto the main thread (e.g., via the mainloop work queue) or call an existing explicitly thread-safe quit path.

Copilot uses AI. Check for mistakes.
Comment thread indra/newview/llviewerwindow.cpp
Comment thread indra/newview/llappviewerwin32.cpp Outdated
Comment thread indra/newview/llappviewerwin32.cpp Outdated
Comment thread indra/llwindow/llwindowwin32.cpp
We can't be absolutely certain about the source in this case, but at least try to distinguish termination caused by task manager from 'unknowns'.
@akleshchev akleshchev force-pushed the andreyk/viewer_5719 branch from 07ecf11 to c4b4f16 Compare April 30, 2026 17:15
@akleshchev akleshchev merged commit 6fb576a into develop Apr 30, 2026
15 checks passed
@akleshchev akleshchev deleted the andreyk/viewer_5719 branch April 30, 2026 21:36
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants