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 56959c8262..2017cf9530 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3539,7 +3539,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/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 6a629b5405..8329041a5c 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,13 @@ 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 + // 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 93e791e7a7..63e60b3bd8 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1008,9 +1008,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 @@ -1029,6 +1032,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(); } @@ -5072,8 +5079,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; } @@ -5088,7 +5101,10 @@ void LLWindowWin32::LLWindowWin32Thread::run() { sWindowThreadId = std::this_thread::get_id(); LogChange logger("Window"); - + // [FIRE-32453][BUG-232971] Improve shutdown behaviour. + try + { + // initDX(); //as good a place as any to up the MM timer resolution (see ms_sleep) @@ -5169,7 +5185,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."); + // //clean up DXGI/D3D resources if (mDXGIAdapter) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 217dc36d35..9e103a5a96 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2700,7 +2700,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}"