From f359a39195553832229e454a4079aaec57ffc0f0 Mon Sep 17 00:00:00 2001 From: PanteraPolnocy Date: Mon, 2 Jan 2023 19:19:28 +0100 Subject: [PATCH 1/3] Flip dates to 2023 --- FIRESTORM-SOURCE_LICENSE_HEADER.txt | 2 +- autobuild.xml | 2 +- indra/newview/CMakeLists.txt | 2 +- indra/newview/English.lproj/InfoPlist.strings | 2 +- indra/newview/res/viewerRes.rc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/FIRESTORM-SOURCE_LICENSE_HEADER.txt b/FIRESTORM-SOURCE_LICENSE_HEADER.txt index 77797473c5..19eedbfa2e 100644 --- a/FIRESTORM-SOURCE_LICENSE_HEADER.txt +++ b/FIRESTORM-SOURCE_LICENSE_HEADER.txt @@ -2,7 +2,7 @@ * @file * @brief * - * $LicenseInfo:firstyear=2022&license=fsviewerlgpl$ + * $LicenseInfo:firstyear=2023&license=fsviewerlgpl$ * Phoenix Firestorm Viewer Source Code * Copyright (C) 2020, The Phoenix Firestorm Project, Inc. * diff --git a/autobuild.xml b/autobuild.xml index 2a787fc617..86c7be0f17 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3427,7 +3427,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors canonical_repo https://github.com/secondlife/viewer copyright - Copyright (c) 2022, The Phoenix Firestorm Project, Inc. + Copyright (c) 2023, The Phoenix Firestorm Project, Inc. description Firestorm Viewer license diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 24ee0b0b11..15aa203e28 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2681,7 +2681,7 @@ if (DARWIN) set(MACOSX_BUNDLE_BUNDLE_NAME "Firestorm") set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION}") set(MACOSX_BUNDLE_BUNDLE_VERSION "${VIEWER_SHORT_VERSION}${VIEWER_MACOSX_PHASE}${VIEWER_REVISION}") - set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010-2022 The Phoenix Firestorm Project, Inc.") + set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010-2023 The Phoenix Firestorm Project, Inc.") set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Firestorm.nib") set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "LLApplication") diff --git a/indra/newview/English.lproj/InfoPlist.strings b/indra/newview/English.lproj/InfoPlist.strings index 4948632494..1afe5749be 100644 --- a/indra/newview/English.lproj/InfoPlist.strings +++ b/indra/newview/English.lproj/InfoPlist.strings @@ -3,4 +3,4 @@ CFBundleName = "Firestorm"; CFBundleShortVersionString = "Firestorm version %%VERSION%%"; -CFBundleGetInfoString = "Firestorm version %%VERSION%%, Copyright 2010-2022 The Phoenix Firestorm Project, Inc."; +CFBundleGetInfoString = "Firestorm version %%VERSION%%, Copyright 2010-2023 The Phoenix Firestorm Project, Inc."; diff --git a/indra/newview/res/viewerRes.rc b/indra/newview/res/viewerRes.rc index 1f7a2b71e8..dd0da75631 100755 --- a/indra/newview/res/viewerRes.rc +++ b/indra/newview/res/viewerRes.rc @@ -161,7 +161,7 @@ BEGIN VALUE "FileDescription", "Firestorm" VALUE "FileVersion", "${VIEWER_VERSION_MAJOR}.${VIEWER_VERSION_MINOR}.${VIEWER_VERSION_PATCH}.${VIEWER_VERSION_REVISION}" VALUE "InternalName", "Firestorm" - VALUE "LegalCopyright", "Copyright \251 2010-2022, The Phoenix Firestorm Project, Inc." + VALUE "LegalCopyright", "Copyright \251 2010-2023, The Phoenix Firestorm Project, Inc." VALUE "OriginalFilename", "Firestorm.exe" VALUE "ProductName", "Firestorm" VALUE "ProductVersion", "${VIEWER_VERSION_MAJOR}.${VIEWER_VERSION_MINOR}.${VIEWER_VERSION_PATCH}.${VIEWER_VERSION_REVISION}" From 6c4ba94b256a5a57f6f11724ef069e02466afaf8 Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 3 Jan 2023 10:02:01 +0000 Subject: [PATCH 2/3] [FIRE-32453][BUG-232971] Further edge cases for thread hangs on exit --- indra/llcommon/llthreadsafequeue.h | 8 +++++-- indra/llwindow/llwindowwin32.cpp | 37 ++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 6a629b5405..f7cd940a06 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -180,7 +180,7 @@ protected: typedef QueueT queue_type; QueueT mStorage; U32 mCapacity; - bool mClosed; + std::atomic mClosed; // Try harder to stop the compiler optimising the mClosed state inside the loops boost::fibers::timed_mutex mLock; typedef std::unique_lock lock_t; @@ -342,7 +342,11 @@ bool LLThreadSafeQueue::pushIfOpen(T&& element) return true; // Storage Full. Wait for signal. - mCapacityCond.wait(lock1); + // [FIRE-32453][BUG-232971] Improve shutdown behaviour. Time bound the sleep + // When the queue is full and the consuming thread has exited we will never wake up. + const auto timeout = std::chrono::milliseconds(50); + mCapacityCond.wait_for(lock1, timeout); + // } } diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 4fab03ebee..1b9b65b346 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -901,9 +901,12 @@ void LLWindowWin32::close() // This causes WM_DESTROY to be sent *immediately* if (!destroy_window_handler(mWindowHandle)) { - OSMessageBox(mCallbacks->translateString("MBDestroyWinFailed"), - mCallbacks->translateString("MBShutdownErr"), - OSMB_OK); + // Can't use a message box here because we're about to stop servicing the events. + // OSMessageBox(mCallbacks->translateString("MBDestroyWinFailed"), + // mCallbacks->translateString("MBShutdownErr"), + // OSMB_OK); + LL_INFOS("Window") << "Destroying Window failed" << LL_ENDL; + // } } else @@ -4751,8 +4754,14 @@ void LLWindowWin32::LLWindowWin32Thread::close() for (auto& pair: mThreads) { LL_DEBUGS("ThreadPool") << mName << " waiting on thread " << pair.first << LL_ENDL; - // if mName does not contain the word Window - pair.second.join(); + // As we cannot seem to rely on the clean and timely exit of the windows thread in ALL situations we apply a timeout. + std::future f = std::async(std::launch::async, [&] { pair.second.join(); }); + if (f.wait_until(std::chrono::steady_clock::now() + std::chrono::seconds(5)) == std::future_status::ready) { + LL_DEBUGS("ThreadPool") << mName << " joined normally." << LL_ENDL; + } else { + LL_WARNS("ThreadPool") << mName << " join timed out." << LL_ENDL; + // the specified time point was reached before the thread finished execution and could be joined + } } LL_DEBUGS("ThreadPool") << mName << " shutdown complete" << LL_ENDL; } @@ -4767,7 +4776,10 @@ void LLWindowWin32::LLWindowWin32Thread::run() { sWindowThreadId = std::this_thread::get_id(); LogChange logger("Window"); - + // [FIRE-32453][BUG-232971] Improve shutdown behaviour. + try + { + // while (! getQueue().done()) { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; @@ -4827,7 +4839,18 @@ void LLWindowWin32::LLWindowWin32Thread::run() } #endif } - logger.always("done - queue closed on windows thread.");// extra debug for threaded window handler + // [FIRE-32453][BUG-232971] Improve shutdown behaviour. + } + catch (const std::exception& e) + { + logger.always("Windows thread exiting - Exception: ", e.what()); + } + catch (...) + { + logger.always("Windows thread exiting - Exception: Unknown"); + } + logger.always("done - queue closed on windows thread."); + // } void LLWindowWin32::post(const std::function& func) From 0c9d4db072ab220b02b801595db5fc9ce3dfe6e0 Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 3 Jan 2023 18:50:24 +0000 Subject: [PATCH 3/3] [FIRE-32453][BUG-232971] Orderly shutdown of event queues Terminate related queues before the windows thread to avoid loops. Also increase timeout on queue full wait as we don't expect to see this so often now. --- indra/llcommon/llthreadsafequeue.h | 6 ++++-- indra/llwindow/llwindowwin32.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index f7cd940a06..8329041a5c 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -343,8 +343,10 @@ bool LLThreadSafeQueue::pushIfOpen(T&& element) // Storage Full. Wait for signal. // [FIRE-32453][BUG-232971] Improve shutdown behaviour. Time bound the sleep - // When the queue is full and the consuming thread has exited we will never wake up. - const auto timeout = std::chrono::milliseconds(50); + // mCapacityCond.wait(lock1); + // When the queue is full and the consuming thread has exited we would never wake up. + // For safety, we now wait max half a second then recheck close. + const auto timeout = std::chrono::milliseconds(500); mCapacityCond.wait_for(lock1, timeout); // } diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 1b9b65b346..f146b71b6e 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -925,6 +925,10 @@ void LLWindowWin32::close() // operations we're asking. That's the last time WE should touch it. mhDC = NULL; mWindowHandle = NULL; + // [FIRE-32453][BUG-232971] close the related queues first to prevent spinning. + mFunctionQueue.close(); + mMouseQueue.close(); + // mWindowThread->close(); }