Merge branch 'DRTVWR-515-maint' of https://bitbucket.org/lindenlab/viewer

master
Ansariel 2020-12-02 08:17:58 +01:00
commit 6c587d437d
18 changed files with 201 additions and 84 deletions

View File

@ -3394,9 +3394,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>archive</key>
<map>
<key>hash</key>
<string>dfef4288f26457f7d41bb17768cc88d4</string>
<string>2cad9f4819a814f307031df38542336b</string>
<key>url</key>
<string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/71888/695068/viewer_manager-2.0.551854-darwin64-551854.tar.bz2</string>
<string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/73146/705975/viewer_manager-2.0.552903-darwin64-552903.tar.bz2</string>
</map>
<key>name</key>
<string>darwin64</string>
@ -3430,9 +3430,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>archive</key>
<map>
<key>hash</key>
<string>d6d3081c7da304b24e9ff39452bae563</string>
<string>b19cf411bad0a34b7862e9ea624a86af</string>
<key>url</key>
<string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/71889/695075/viewer_manager-2.0.551854-windows-551854.tar.bz2</string>
<string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/73145/705981/viewer_manager-2.0.552903-windows-552903.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
@ -3443,7 +3443,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>source_type</key>
<string>hg</string>
<key>version</key>
<string>2.0.551854</string>
<string>2.0.552903</string>
</map>
<key>vlc-bin</key>
<map>

View File

@ -56,10 +56,6 @@
#include "stringize.h"
#include "llexception.h"
#if LL_WINDOWS
#include <excpt.h>
#endif
// static
LLCoros::CoroData& LLCoros::get_CoroData(const std::string& caller)
{
@ -252,29 +248,13 @@ std::string LLCoros::launch(const std::string& prefix, const callable_t& callabl
#if LL_WINDOWS
static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific
U32 exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop)
{
if (code == STATUS_MSC_EXCEPTION)
{
// C++ exception, go on
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
// handle it
return EXCEPTION_EXECUTE_HANDLER;
}
}
void LLCoros::winlevel(const callable_t& callable)
{
__try
{
callable();
}
__except (exception_filter(GetExceptionCode(), GetExceptionInformation()))
__except (msc_exception_filter(GetExceptionCode(), GetExceptionInformation()))
{
// convert to C++ styled exception
// Note: it might be better to use _se_set_translator

View File

@ -24,11 +24,14 @@
// `_GNU_SOURCE` macro or `BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED` if
// _Unwind_Backtrace is available without `_GNU_SOURCE`."
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#if LL_WINDOWS
// On Windows, header-only implementation causes macro collisions -- use
// prebuilt library
#define BOOST_STACKTRACE_LINK
#include <excpt.h>
#endif // LL_WINDOWS
#include <boost/stacktrace.hpp>
// other Linden headers
#include "llerror.h"
@ -85,3 +88,25 @@ void annotate_exception_(boost::exception& exc)
// Anyway, which of us is really going to examine more than 100 frames?
exc << errinfo_stacktrace(boost::stacktrace::stacktrace(1, 100));
}
#if LL_WINDOWS
// For windows SEH exception handling we sometimes need a filter that will
// separate C++ exceptions from C SEH exceptions
static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific
U32 msc_exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop)
{
if (code == STATUS_MSC_EXCEPTION)
{
// C++ exception, go on
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
// handle it
return EXCEPTION_EXECUTE_HANDLER;
}
}
#endif //LL_WINDOWS

View File

@ -102,4 +102,14 @@ void crash_on_unhandled_exception_(const char*, int, const char*, const std::str
log_unhandled_exception_(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, CONTEXT)
void log_unhandled_exception_(const char*, int, const char*, const std::string&);
#if LL_WINDOWS
// SEH exception filtering for use in __try __except
// Separates C++ exceptions from C SEH exceptions
// Todo: might be good idea to do some kind of seh_to_msc_wrapper(function, ARGS&&);
U32 msc_exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop);
#endif //LL_WINDOWS
#endif /* ! defined(LL_LLEXCEPTION_H) */

View File

@ -262,7 +262,7 @@ public:
virtual void logAssetStorageInfo() = 0;
void checkForTimeouts();
virtual void checkForTimeouts();
void getEstateAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id,
const LLUUID &asset_id, LLAssetType::EType atype, EstateAssetType etype,

View File

@ -47,7 +47,7 @@ static const std::map<std::string, U32> DefaultPoolSizes{
};
static const U32 DEFAULT_POOL_SIZE = 5;
static const U32 DEFAULT_QUEUE_SIZE = 4096;
const U32 LLCoprocedureManager::DEFAULT_QUEUE_SIZE = 4096;
//=========================================================================
class LLCoprocedurePool: private boost::noncopyable
@ -194,7 +194,7 @@ void LLCoprocedureManager::setPropertyMethods(SettingQuery_t queryfn, SettingUpd
mPropertyDefineFn = updatefn;
// workaround until we get mutex into initializePool
initializePool("VAssetStorage");
initializePool("AssetStorage");
initializePool("Upload");
}
@ -281,7 +281,7 @@ LLCoprocedurePool::LLCoprocedurePool(const std::string &poolName, size_t size):
mPoolSize(size),
mActiveCoprocsCount(0),
mPending(0),
mPendingCoprocs(boost::make_shared<CoprocQueue_t>(DEFAULT_QUEUE_SIZE)),
mPendingCoprocs(boost::make_shared<CoprocQueue_t>(LLCoprocedureManager::DEFAULT_QUEUE_SIZE)),
mHTTPPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mCoroMapping()
{
@ -332,7 +332,7 @@ LLCoprocedurePool::LLCoprocedurePool(const std::string &poolName, size_t size):
mCoroMapping.insert(CoroAdapterMap_t::value_type(pooledCoro, httpAdapter));
}
LL_INFOS("CoProcMgr") << "Created coprocedure pool named \"" << mPoolName << "\" with " << size << " items, queue max " << DEFAULT_QUEUE_SIZE << LL_ENDL;
LL_INFOS("CoProcMgr") << "Created coprocedure pool named \"" << mPoolName << "\" with " << size << " items, queue max " << LLCoprocedureManager::DEFAULT_QUEUE_SIZE << LL_ENDL;
}
LLCoprocedurePool::~LLCoprocedurePool()

View File

@ -91,6 +91,9 @@ private:
SettingQuery_t mPropertyQueryFn;
SettingUpdate_t mPropertyDefineFn;
public:
static const U32 DEFAULT_QUEUE_SIZE;
};
#endif

View File

@ -38,6 +38,7 @@
// Linden library includes
#include "llerror.h"
#include "llexception.h"
#include "llfasttimer.h"
#include "llgl.h"
#include "llstring.h"
@ -117,7 +118,7 @@ void show_window_creation_error(const std::string& title)
LL_WARNS("Window") << title << LL_ENDL;
}
HGLRC SafeCreateContext(HDC hdc)
HGLRC SafeCreateContext(HDC &hdc)
{
__try
{
@ -129,6 +130,22 @@ HGLRC SafeCreateContext(HDC hdc)
}
}
GLuint SafeChoosePixelFormat(HDC &hdc, const PIXELFORMATDESCRIPTOR *ppfd)
{
__try
{
return ChoosePixelFormat(hdc, ppfd);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
// convert to C++ styled exception
// C exception don't allow classes, so it's a regular char array
char integer_string[32];
sprintf(integer_string, "SEH, code: %lu\n", GetExceptionCode());
throw std::exception(integer_string);
}
}
//static
BOOL LLWindowWin32::sIsClassRegistered = FALSE;
@ -463,8 +480,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
memset(mCurrentGammaRamp, 0, sizeof(mCurrentGammaRamp));
memset(mPrevGammaRamp, 0, sizeof(mPrevGammaRamp));
mCustomGammaSet = FALSE;
mWindowHandle = NULL; // <FS:Ansariel> Initialize...
mWindowHandle = NULL;
if (!SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &mMouseVanish, 0))
{
mMouseVanish = TRUE;
@ -1175,8 +1192,6 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
<< " Height: " << (window_rect.bottom - window_rect.top)
<< " Fullscreen: " << mFullscreen
<< LL_ENDL;
// <FS:Ansariel> Only try destroying an existing window
//if (!destroy_window_handler(mWindowHandle))
if (mWindowHandle && !destroy_window_handler(mWindowHandle))
{
LL_WARNS("Window") << "Failed to properly close window before recreating it!" << LL_ENDL;
@ -1236,13 +1251,26 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
LL_INFOS("Window") << "Device context retrieved." << LL_ENDL ;
if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd)))
{
close();
OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
return FALSE;
}
try
{
// Looks like ChoosePixelFormat can crash in case of faulty driver
if (!(pixel_format = SafeChoosePixelFormat(mhDC, &pfd)))
{
LL_WARNS("Window") << "ChoosePixelFormat failed, code: " << GetLastError() << LL_ENDL;
OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
}
catch (...)
{
LOG_UNHANDLED_EXCEPTION("ChoosePixelFormat");
OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
LL_INFOS("Window") << "Pixel format chosen." << LL_ENDL ;
@ -1502,7 +1530,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
}
// Destroy The Window
if (!destroy_window_handler(mWindowHandle))
if (mWindowHandle && !destroy_window_handler(mWindowHandle))
{
LL_WARNS("Window") << "Failed to properly close window!" << LL_ENDL;
}

View File

@ -18818,7 +18818,7 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<real>1</real>
</map>
<key>PoolSizeVAssetStorage</key>
<key>PoolSizeAssetStorage</key>
<map>
<key>Comment</key>
<string>Coroutine Pool size for AssetStorage requests</string>

View File

@ -134,6 +134,7 @@
// called again. Since it returned false, do not yet cancel
// frameTimer.
handleQuit();
[[NSApplication sharedApplication] stopModal];
return NSTerminateCancel;
} else {
// pumpMainLoop() returned true: it's done. Okay, done with frameTimer.

View File

@ -1916,6 +1916,7 @@ bool LLAppViewer::doFrame()
}
delete gServicePump;
gServicePump = NULL;
destroyMainloopTimeout();

View File

@ -384,22 +384,6 @@ F32 gpu_benchmark();
#if LL_WINDOWS
static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific
U32 exception_benchmark_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop)
{
if (code == STATUS_MSC_EXCEPTION)
{
// C++ exception, go on
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
// handle it
return EXCEPTION_EXECUTE_HANDLER;
}
}
F32 logExceptionBenchmark()
{
// Todo: make a wrapper/class for SEH exceptions
@ -408,7 +392,7 @@ F32 logExceptionBenchmark()
{
gbps = gpu_benchmark();
}
__except (exception_benchmark_filter(GetExceptionCode(), GetExceptionInformation()))
__except (msc_exception_filter(GetExceptionCode(), GetExceptionInformation()))
{
// convert to C++ styled exception
char integer_string[32];

View File

@ -104,6 +104,11 @@ LLMeshFilePicker::LLMeshFilePicker(LLModelPreview* mp, S32 lod)
void LLMeshFilePicker::notify(const std::vector<std::string>& filenames)
{
if(LLAppViewer::instance()->quitRequested())
{
return;
}
if (filenames.size() > 0)
{
mMP->loadModel(filenames[0], mLOD);

View File

@ -51,8 +51,8 @@
/// LLViewerAssetRequest
///----------------------------------------------------------------------------
// There is also PoolSizeVAssetStorage value in setting that should mirror this name
static const std::string VIEWER_ASSET_STORAGE_CORO_POOL = "VAssetStorage";
// There is also PoolSizeAssetStorage value in setting that should mirror this name
static const std::string VIEWER_ASSET_STORAGE_CORO_POOL = "AssetStorage";
/**
* @brief Local class to encapsulate asset fetch requests with a timestamp.
@ -139,6 +139,14 @@ LLViewerAssetStorage::~LLViewerAssetStorage()
// This class has dedicated coroutine pool, clean it up, otherwise coroutines will crash later.
LLCoprocedureManager::instance().close(VIEWER_ASSET_STORAGE_CORO_POOL);
}
while (mCoroWaitList.size() > 0)
{
CoroWaitList &request = mCoroWaitList.front();
// Clean up pending downloads, delete request and trigger callbacks
removeAndCallbackPendingDownloads(request.mId, request.mType, request.mId, request.mType, LL_ERR_NOERR, LLExtStat::NONE);
mCoroWaitList.pop_front();
}
}
// virtual
@ -353,6 +361,29 @@ void LLViewerAssetStorage::storeAssetData(
}
}
void LLViewerAssetStorage::checkForTimeouts()
{
LLAssetStorage::checkForTimeouts();
// Restore requests
LLCoprocedureManager* manager = LLCoprocedureManager::getInstance();
while (mCoroWaitList.size() > 0
&& manager->count(VIEWER_ASSET_STORAGE_CORO_POOL) < LLCoprocedureManager::DEFAULT_QUEUE_SIZE)
{
CoroWaitList &request = mCoroWaitList.front();
// <FS:Ansariel> [UDP Assets]
//bool with_http = true;
//bool is_temp = false;
//LLViewerAssetStatsFF::record_enqueue(request.mType, with_http, is_temp);
// </FS:Ansariel> [UDP Assets]
manager->enqueueCoprocedure(VIEWER_ASSET_STORAGE_CORO_POOL, "LLViewerAssetStorage::assetRequestCoro",
boost::bind(&LLViewerAssetStorage::assetRequestCoro, this, request.mRequest, request.mId, request.mType, request.mCallback, request.mUserData));
mCoroWaitList.pop_front();
}
}
/**
* @brief Allocate and queue an asset fetch request for the viewer
@ -410,14 +441,22 @@ void LLViewerAssetStorage::queueRequestHttp(
// This is the same as the current UDP logic - don't re-request a duplicate.
if (!duplicate)
{
// <FS:Ansariel> [UDP Assets]
//bool with_http = true;
//bool is_temp = false;
//LLViewerAssetStatsFF::record_enqueue(atype, with_http, is_temp);
// <FS:Ansariel> [UDP Assets]
// Coroutine buffer has fixed size (synchronization buffer, so we have no alternatives), so buffer any request above limit
if (LLCoprocedureManager::instance().count(VIEWER_ASSET_STORAGE_CORO_POOL) < LLCoprocedureManager::DEFAULT_QUEUE_SIZE)
{
// <FS:Ansariel> [UDP Assets]
//bool with_http = true;
//bool is_temp = false;
//LLViewerAssetStatsFF::record_enqueue(atype, with_http, is_temp);
// </FS:Ansariel> [UDP Assets]
LLCoprocedureManager::instance().enqueueCoprocedure(VIEWER_ASSET_STORAGE_CORO_POOL,"LLViewerAssetStorage::assetRequestCoro",
boost::bind(&LLViewerAssetStorage::assetRequestCoro, this, req, uuid, atype, callback, user_data));
LLCoprocedureManager::instance().enqueueCoprocedure(VIEWER_ASSET_STORAGE_CORO_POOL, "LLViewerAssetStorage::assetRequestCoro",
boost::bind(&LLViewerAssetStorage::assetRequestCoro, this, req, uuid, atype, callback, user_data));
}
else
{
mCoroWaitList.emplace_back(req, uuid, atype, callback, user_data);
}
}
}

View File

@ -45,7 +45,7 @@ public:
~LLViewerAssetStorage();
virtual void storeAssetData(
void storeAssetData(
const LLTransactionID& tid,
LLAssetType::EType atype,
LLStoreAssetCallback callback,
@ -54,9 +54,9 @@ public:
bool is_priority = false,
bool store_local = false,
bool user_waiting=FALSE,
F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT);
virtual void storeAssetData(
F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT) override;
void storeAssetData(
const std::string& filename,
const LLTransactionID& tid,
LLAssetType::EType type,
@ -65,16 +65,17 @@ public:
bool temp_file = false,
bool is_priority = false,
bool user_waiting=FALSE,
F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT);
F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT) override;
void checkForTimeouts() override;
protected:
// virtual
void _queueDataRequest(const LLUUID& uuid,
LLAssetType::EType type,
LLGetAssetCallback callback,
void *user_data,
BOOL duplicate,
BOOL is_priority);
BOOL is_priority) override;
void queueRequestHttp(const LLUUID& uuid,
LLAssetType::EType type,
@ -93,8 +94,35 @@ protected:
std::string getAssetURL(const std::string& cap_url, const LLUUID& uuid, LLAssetType::EType atype);
void logAssetStorageInfo();
void logAssetStorageInfo() override;
// Asset storage works through coroutines and coroutines have limited queue capacity
// This class is meant to temporary store requests when fiber's queue is full
class CoroWaitList
{
public:
CoroWaitList(LLViewerAssetRequest *req,
const LLUUID& uuid,
LLAssetType::EType atype,
LLGetAssetCallback &callback,
void *user_data)
: mRequest(req),
mId(uuid),
mType(atype),
mCallback(callback),
mUserData(user_data)
{
}
LLViewerAssetRequest* mRequest;
LLUUID mId;
LLAssetType::EType mType;
LLGetAssetCallback mCallback;
void *mUserData;
};
typedef std::list<CoroWaitList> wait_list_t;
wait_list_t mCoroWaitList;
std::string mViewerAssetUrl;
S32 mAssetCoroCount;
S32 mCountRequests;

View File

@ -2602,7 +2602,6 @@ void LLViewerWindow::shutdownGL()
LLViewerWindow::~LLViewerWindow()
{
LL_INFOS() << "Destroying Window" << LL_ENDL;
gDebugWindowProc = TRUE; // event catching, disable once we figure out cause for exit crashes
destroyWindow();
delete mDebugText;

View File

@ -190,6 +190,7 @@ void LLVoiceClient::terminate()
{
if (mVoiceModule) mVoiceModule->terminate();
mVoiceModule = NULL;
m_servicePump = NULL;
// <FS:Ansariel> Shutdown speaker volume storage before CRT does it
if (LLSpeakerVolumeStorage::instanceExists())

View File

@ -392,7 +392,7 @@ LLVivoxVoiceClient::~LLVivoxVoiceClient()
void LLVivoxVoiceClient::init(LLPumpIO *pump)
{
// constructor will set up LLVoiceClient::getInstance()
LLVivoxVoiceClient::getInstance()->mPump = pump;
mPump = pump;
// LLCoros::instance().launch("LLVivoxVoiceClient::voiceControlCoro",
// boost::bind(&LLVivoxVoiceClient::voiceControlCoro, LLVivoxVoiceClient::getInstance()));
@ -420,6 +420,7 @@ void LLVivoxVoiceClient::terminate()
}
sShuttingDown = true;
mPump = NULL;
// <FS:Ansariel> Delete useless Vivox logs on logout
if (gSavedSettings.getString("VivoxDebugLevel") == "0")
@ -1052,10 +1053,15 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
llcoro::suspendUntilTimeout(UPDATE_THROTTLE_SECONDS);
while (!mPump)
{ // Can't do this until we have the pump available.
while (!mPump && !sShuttingDown)
{ // Can't use the pump until we have it available.
llcoro::suspend();
}
if (sShuttingDown)
{
return false;
}
// MBW -- Note to self: pumps and pipes examples in
// indra/test/io.cpp
@ -1068,8 +1074,10 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
readChain.push_back(LLIOPipe::ptr_t(new LLIOSocketReader(mSocket)));
readChain.push_back(LLIOPipe::ptr_t(new LLVivoxProtocolParser()));
mPump->addChain(readChain, NEVER_CHAIN_EXPIRY_SECS);
//---------------------------------------------------------------------
llcoro::suspendUntilTimeout(UPDATE_THROTTLE_SECONDS);
@ -1092,6 +1100,11 @@ bool LLVivoxVoiceClient::provisionVoiceAccount()
// *TODO* Pump a message for wake up.
llcoro::suspend();
}
if (sShuttingDown)
{
return false;
}
std::string url = gAgent.getRegionCapability("ProvisionVoiceAccountRequest");