Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions indra/llwindow/llwindowcallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ void LLWindowCallbacks::handlePreCloseRequest()
{
}

void LLWindowCallbacks::handleCloseRequestCanceled()
{
}

void LLWindowCallbacks::handleSuspendRequest()
{
}

bool LLWindowCallbacks::handleCloseRequest(LLWindow *window, bool from_user)
{
//allow the window to close
Expand Down
2 changes: 2 additions & 0 deletions indra/llwindow/llwindowcallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class LLWindowCallbacks
virtual void handleMouseLeave(LLWindow *window);
// Called before close request is processed (ex: to create marker file in case OS is about to kill app).
virtual void handlePreCloseRequest();
virtual void handleCloseRequestCanceled();
virtual void handleSuspendRequest();
// return true to allow window to close, which will then cause handleQuit to be called
virtual bool handleCloseRequest(LLWindow *window, bool from_user);
virtual bool handleSessionExit(LLWindow* window);
Expand Down
15 changes: 8 additions & 7 deletions indra/llwindow/llwindowwin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2657,21 +2657,22 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
// Viewer can't function in hibernation, try to shut down.
// The system allows approximately two seconds for an
// application to handle this notification.

// Mark app as potentially closing, to minimize issues if OS does not recover.
window_imp->mCallbacks->handlePreCloseRequest();
window_imp->post([=]()
{
LL_INFOS("Window") << "Shutting down due to system suspending (sleep/hibernate)" << LL_ENDL;
if (window_imp->mCallbacks->handleSessionExit(window_imp))
{
// Get the app to initiate cleanup.
window_imp->mCallbacks->handleQuit(window_imp);
}
window_imp->mCallbacks->handleSuspendRequest();
});
// Window thread normally doesn't block main thread, but OS can suspend
// immediately if we don't wait.
// Keep OS from suspending to give a chance to send stats.
ms_sleep(1000);
return TRUE;
Comment thread
akleshchev marked this conversation as resolved.

case PBT_APMRESUMESUSPEND:
LL_INFOS("Window") << "System is resuming from suspend" << LL_ENDL;
// Shouldn't be up, but log just in case.
window_imp->mCallbacks->handleCloseRequestCanceled();
return TRUE;

case PBT_APMPOWERSTATUSCHANGE:
Expand Down
29 changes: 18 additions & 11 deletions indra/newview/llappviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4055,8 +4055,10 @@ void LLAppViewer::processMarkerFiles()
// - Other Crash (SecondLife.error_marker present)
// - Watchdog freeze (SecondLife.watchdog_marker present)
// - Failed to initialize (SecondLife.inited_marker not present)
// - Potentially killed by task manager (SecondLife.close_marker present)
// These checks should also remove these files for the last 2 cases if they currently exist
// - Potentially killed by task manager or computer
// didn't recover from hibernation (SecondLife.close_marker present)
// These checks should also remove these files for the last 2 cases
// if they currently exist

std::ostringstream marker_log_stream;
bool marker_is_same_version = true;
Expand Down Expand Up @@ -4227,21 +4229,21 @@ void LLAppViewer::processMarkerFiles()
}
}
// If 'close' marker is found, viewer either started shutdown but
// failed, or viewer got killed by task manager.
// failed, OS did not recover from hibernation or viewer got
// killed by task manager.
// Marker does not indicate that viewer was closed or is closing,
// just that 'close' was requested before viewer died.
else if (LLAPRFile::isExist(close_marker_file, NULL, LL_APR_RB))
{
// For now treat as 'other' cause.
// Unfortunately we can't for certain distinguish task
// manager's case from other shutdown problems, so we
// have to report both.
// Todo: if this bears noticeable fruits, make a new state later.
// New categories need server/web side support.
// Unfortunately we can't reliably distinguish
// task manager's case from genuine shutdown, so we
// have to report all of them as the same thing.
// Todo: but we can distinguish hibernation, might want
// to simply not report it as an issue.
if (markerIsSameVersion(close_marker_file))
{
gLastExecEvent = LAST_EXEC_UNKNOWN == gLastExecEvent ? LAST_EXEC_OTHER_CRASH : LAST_EXEC_LOGOUT_CRASH;
LL_INFOS("MarkerFile") << "'Close' marker '" << close_marker_file << "' found, setting LastExecEvent to CRASH"
gLastExecEvent = LAST_EXEC_OS_EVENT;
LL_INFOS("MarkerFile") << "'Close' marker '" << close_marker_file << "' found, setting LastExecEvent to OS_EVENT"
<< LL_ENDL;
}
}
Expand Down Expand Up @@ -4472,6 +4474,11 @@ void LLAppViewer::abortQuit()
mClosingFloaters = false;
}

void LLAppViewer::sendViewerStatistics()
{
send_viewer_stats(false);
}

void LLAppViewer::migrateCacheDirectory()
{
#if LL_WINDOWS || LL_DARWIN
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llappviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef enum
LAST_EXEC_INIT,
LAST_EXEC_UNKNOWN,
LAST_EXEC_LOGOUT_UNKNOWN,
LAST_EXEC_OS_EVENT,
LAST_EXEC_COUNT
} eLastExecEvent;

Expand Down Expand Up @@ -113,6 +114,7 @@ class LLAppViewer : public LLApp
const LLSD& substitutions = LLSD()); // Display an error dialog and forcibly quit.
void earlyExitNoNotify(); // Do not display error dialog then forcibly quit.
void abortQuit(); // Called to abort a quit request.
void sendViewerStatistics();

bool quitRequested() { return mQuitRequested; }
bool logoutRequestSent() { return mLogoutRequestSent; }
Expand Down
18 changes: 18 additions & 0 deletions indra/newview/llviewerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,25 @@ void LLViewerWindow::handlePreCloseRequest()
{
LLAppViewer::instance()->createCloseRequestMarker();
}
}

void LLViewerWindow::handleCloseRequestCanceled()
{
// WINDOW THREAD! since we need this to act fast.
if (!LLApp::isExiting() && !LLApp::isStopped())
{
LLAppViewer::instance()->removeCloseRequestMarker();
}
}

void LLViewerWindow::handleSuspendRequest()
{
LLAppViewer::instance()->sendViewerStatistics();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure, but simple logging inside handleSuspendRequest() and handleCloseRequestCanceled() may be useful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are already doing logging in window code, but wouldn't hurt, thank you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done it in the next commit.

// Todo: this should send a disconnect request as viewer
// can't keep heartbeat up while suspended and will get
// disconnected within a minute.
// Add a disconnect here once 'prevent OS from sleeping'
// feature is ready.
}

bool LLViewerWindow::handleCloseRequest(LLWindow *window, bool from_user)
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llviewerwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class LLViewerWindow : public LLWindowCallbacks
/*virtual*/ bool handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ bool handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ void handlePreCloseRequest();
/*virtual*/ void handleCloseRequestCanceled();
/*virtual*/ void handleSuspendRequest();
/*virtual*/ bool handleCloseRequest(LLWindow *window, bool from_user);
/*virtual*/ bool handleSessionExit(LLWindow* window);
/*virtual*/ void handleQuit(LLWindow *window);
Expand Down
Loading