diff options
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 664 |
1 files changed, 385 insertions, 279 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 584ab5e50f..de4f7ab091 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -30,9 +30,10 @@ * $/LicenseInfo$ */ - #include "llviewerprecompiledheaders.h" + #include "llappviewer.h" + #include "llprimitive.h" #include "llversionviewer.h" @@ -41,37 +42,46 @@ #include "lltexteditor.h" #include "llalertdialog.h" #include "llerrorcontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llgroupmgr.h" #include "llagent.h" +#include "llagentwearables.h" #include "llwindow.h" #include "llviewerstats.h" #include "llmd5.h" #include "llpumpio.h" #include "llimpanel.h" #include "llmimetypes.h" +#include "llslurl.h" #include "llstartup.h" #include "llfocusmgr.h" #include "llviewerjoystick.h" -#include "llfloaterjoystick.h" +#include "llallocator.h" #include "llares.h" #include "llcurl.h" -#include "llfloatersnapshot.h" #include "llviewerwindow.h" #include "llviewerdisplay.h" #include "llviewermedia.h" +#include "llviewerparcelmedia.h" +#include "llviewermediafocus.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" #include "llworldmap.h" #include "llmutelist.h" +#include "lluicolortable.h" #include "llurldispatcher.h" #include "llurlhistory.h" #include "llfirstuse.h" #include "llrender.h" - +#include "lllocationhistory.h" +#include "llfasttimerview.h" #include "llweb.h" #include "llsecondlifeurls.h" +// Linden library includes +#include "llmemory.h" + +// Third party library includes #include <boost/bind.hpp> #if LL_WINDOWS @@ -101,11 +111,12 @@ #include "llassetstorage.h" #include "llpolymesh.h" #include "llcachename.h" -#include "audioengine.h" +#include "llaudioengine.h" +#include "llstreamingaudio.h" #include "llviewermenu.h" #include "llselectmgr.h" #include "lltrans.h" -#include "lluitrans.h" +#include "lltransutil.h" #include "lltracker.h" #include "llviewerparcelmgr.h" #include "llworldmapview.h" @@ -116,9 +127,7 @@ #include "lldebugview.h" #include "llconsole.h" #include "llcontainerview.h" -#include "llfloaterstats.h" #include "llhoverview.h" -#include "llfloatermemleak.h" #include "llsdserialize.h" @@ -139,12 +148,17 @@ #include "llvoavatar.h" #include "llfolderview.h" #include "lltoolbar.h" -#include "llframestats.h" #include "llagentpilot.h" #include "llsrv.h" #include "llvovolume.h" #include "llflexibleobject.h" #include "llvosurfacepatch.h" +#include "llviewerfloaterreg.h" +#include "llcommandlineparser.h" +#include "llfloatermemleak.h" +#include "llfloaterreg.h" +#include "llfloatersnapshot.h" +#include "llfloaterinventory.h" // includes for idle() idleShutdown() #include "llviewercontrol.h" @@ -161,11 +175,6 @@ #include "llviewerthrottle.h" #include "llparcel.h" - -#include "llinventoryview.h" - -#include "llcommandlineparser.h" - // *FIX: These extern globals should be cleaned up. // The globals either represent state/config/resource-storage of either // this app, or another 'component' of the viewer. App globals should be @@ -181,10 +190,6 @@ ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor // -#if LL_WINDOWS && LL_LCD_COMPILE - #include "lllcd.h" -#endif - //---------------------------------------------------------------------------- // viewer.cpp - these are only used in viewer, should be easily moved. @@ -235,9 +240,6 @@ LLTimer gLogoutTimer; static const F32 LOGOUT_REQUEST_TIME = 6.f; // this will be cut short by the LogoutReply msg. F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME; -LLUUID gInventoryLibraryOwner; -LLUUID gInventoryLibraryRoot; - BOOL gDisconnected = FALSE; // Map scale in pixels per region @@ -285,11 +287,22 @@ static std::string gLaunchFileOnQuit; const char* const VIEWER_WINDOW_CLASSNAME = "Second Life"; //---------------------------------------------------------------------------- + +// List of entries from strings.xml to always replace +static std::set<std::string> default_trans_args; +void init_default_trans_args() +{ + default_trans_args.insert("SECOND_LIFE"); // World + default_trans_args.insert("APP_NAME"); + default_trans_args.insert("SECOND_LIFE_GRID"); + default_trans_args.insert("SUPPORT_SITE"); +} + +//---------------------------------------------------------------------------- // File scope definitons const char *VFS_DATA_FILE_BASE = "data.db2.x."; const char *VFS_INDEX_FILE_BASE = "index.db2.x."; -static std::string gSecondLife; static std::string gWindowTitle; std::string gLoginPage; @@ -366,7 +379,6 @@ static void settings_to_globals() MENU_BAR_HEIGHT = gSavedSettings.getS32("MenuBarHeight"); MENU_BAR_WIDTH = gSavedSettings.getS32("MenuBarWidth"); - STATUS_BAR_HEIGHT = gSavedSettings.getS32("StatusBarHeight"); LLCOMBOBOX_HEIGHT = BTN_HEIGHT - 2; LLCOMBOBOX_WIDTH = 128; @@ -388,10 +400,9 @@ static void settings_to_globals() LLSelectMgr::sRenderHiddenSelections = gSavedSettings.getBOOL("RenderHiddenSelections"); LLSelectMgr::sRenderLightRadius = gSavedSettings.getBOOL("RenderLightRadius"); - gFrameStats.setTrackStats(gSavedSettings.getBOOL("StatsSessionTrackFrameStats")); gAgentPilot.mNumRuns = gSavedSettings.getS32("StatsNumRuns"); gAgentPilot.mQuitAfterRuns = gSavedSettings.getBOOL("StatsQuitAfterRuns"); - gAgent.mHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle"); + gAgent.setHideGroupTitle(gSavedSettings.getBOOL("RenderHideGroupTitle")); gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc"); gAllowTapTapHoldRun = gSavedSettings.getBOOL("AllowTapTapHoldRun"); @@ -408,7 +419,7 @@ static void settings_modify() LLVOAvatar::sUseImpostors = gSavedSettings.getBOOL("RenderUseImpostors"); LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor"); LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] - gDebugGL = gSavedSettings.getBOOL("RenderDebugGL"); + gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession; gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline"); #if LL_VECTORIZE @@ -446,6 +457,38 @@ static void settings_modify() #endif } +class LLFastTimerLogThread : public LLThread +{ +public: + std::string mFile; + + LLFastTimerLogThread() : LLThread("fast timer log") + { + if(LLFastTimer::sLog) + { + mFile = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "performance.slp"); + } + if(LLFastTimer::sMetricLog) + { + mFile = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "metric.slp"); + } + } + + void run() + { + std::ofstream os(mFile.c_str()); + + while (!LLAppViewer::instance()->isQuitting()) + { + LLFastTimer::writeLog(os); + os.flush(); + ms_sleep(32); + } + + os.close(); + } +}; + void LLAppViewer::initGridChoice() { // Load up the initial grid choice from: @@ -497,8 +540,6 @@ bool LLAppViewer::sendURLToOtherInstance(const std::string& url) LLAppViewer* LLAppViewer::sInstance = NULL; const std::string LLAppViewer::sGlobalSettingsName = "Global"; -const std::string LLAppViewer::sPerAccountSettingsName = "PerAccount"; -const std::string LLAppViewer::sCrashSettingsName = "CrashSettings"; LLTextureCache* LLAppViewer::sTextureCache = NULL; LLWorkerThread* LLAppViewer::sImageDecodeThread = NULL; @@ -513,11 +554,15 @@ LLAppViewer::LLAppViewer() : mPurgeOnExit(false), mSecondInstance(false), mSavedFinalSnapshot(false), + mForceGraphicsDetail(false), mQuitRequested(false), mLogoutRequestSent(false), mYieldTime(-1), mMainloopTimeout(NULL), - mAgentRegionLastAlive(false) + mAgentRegionLastAlive(false), + mFastTimerLogThread(NULL), + mRandomizeFramerate(LLCachedControl<bool>(gSavedSettings,"Randomize Framerate", FALSE)), + mPeriodicSlowFrame(LLCachedControl<bool>(gSavedSettings,"Periodic Slow Frame", FALSE)) { if(NULL != sInstance) { @@ -558,8 +603,13 @@ bool LLAppViewer::init() // // OK to write stuff to logs now, we've now crash reported if necessary // - if (!initConfiguration()) + + init_default_trans_args(); + + if (!initConfiguration()) return false; + + mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling")); // *NOTE:Mani - LLCurl::initClass is not thread safe. // Called before threads are created. @@ -593,6 +643,11 @@ bool LLAppViewer::init() // Get the single value from the crash settings file, if it exists std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); gCrashSettings.loadFromFile(crash_settings_filename); + if(gSavedSettings.getBOOL("IgnoreAllNotifications")) + { + gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ALWAYS_SEND); + gCrashSettings.saveToFile(crash_settings_filename, FALSE); + } ///////////////////////////////////////////////// // OS-specific login dialogs @@ -612,34 +667,37 @@ bool LLAppViewer::init() LLError::setPrintLocation(true); } - // Load art UUID information, don't require these strings to be declared in code. - std::string colors_base_filename = gDirUtilp->findSkinnedFilename("colors_base.xml"); - LL_DEBUGS("InitInfo") << "Loading base colors from " << colors_base_filename << LL_ENDL; - gColors.loadFromFileLegacy(colors_base_filename, FALSE, TYPE_COL4U); - - // Load overrides from user colors file - std::string user_colors_filename = gDirUtilp->findSkinnedFilename("colors.xml"); - LL_DEBUGS("InitInfo") << "Loading user colors from " << user_colors_filename << LL_ENDL; - if (gColors.loadFromFileLegacy(user_colors_filename, FALSE, TYPE_COL4U) == 0) - { - LL_DEBUGS("InitInfo") << "Cannot load user colors from " << user_colors_filename << LL_ENDL; - } - // Widget construction depends on LLUI being initialized - LLUI::initClass(&gSavedSettings, - &gSavedSettings, - &gColors, + LLUI::settings_map_t settings_map; + settings_map["config"] = &gSavedSettings; + settings_map["ignores"] = &gWarningSettings; + settings_map["floater"] = &gSavedSettings; // *TODO: New settings file + settings_map["account"] = &gSavedPerAccountSettings; + + LLUI::initClass(settings_map, LLUIImageList::getInstance(), ui_audio_callback, &LLUI::sGLScaleFactor); + + // Setup paths and LLTrans after LLUI::initClass has been called + LLUI::setupPaths(); + LLTransUtil::parseStrings("strings.xml", default_trans_args); + LLTransUtil::parseLanguageStrings("language_settings.xml"); LLWeb::initClass(); // do this after LLUI LLTextEditor::setURLCallbacks(&LLWeb::loadURL, &LLURLDispatcher::dispatchFromTextEditor, &LLURLDispatcher::dispatchFromTextEditor); - - LLUICtrlFactory::getInstance()->setupPaths(); // update paths with correct language set + // Load translations for tooltips + LLFloater::initClass(); + + ///////////////////////////////////////////////// + + LLToolMgr::getInstance(); // Initialize tool manager if not already instantiated + + LLViewerFloaterReg::registerFloaters(); + ///////////////////////////////////////////////// // // Load settings files @@ -692,18 +750,8 @@ bool LLAppViewer::init() if (!initCache()) { std::ostringstream msg; - msg << - gSecondLife << " is unable to access a file that it needs.\n" - "\n" - "This can be because you somehow have multiple copies running, " - "or your system incorrectly thinks a file is open. " - "If this message persists, restart your computer and try again. " - "If it continues to persist, you may need to completely uninstall " << - gSecondLife << " and reinstall it."; - OSMessageBox( - msg.str(), - LLStringUtil::null, - OSMB_OK); + msg << LLTrans::getString("MBUnableToAccessFile"); + OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK); return 1; } @@ -818,8 +866,14 @@ bool LLAppViewer::init() return true; } +static LLFastTimer::DeclareTimer FTM_MESSAGES("System Messages"); +static LLFastTimer::DeclareTimer FTM_SLEEP("Sleep"); +static LLFastTimer::DeclareTimer FTM_IDLE("Idle"); +static LLFastTimer::DeclareTimer FTM_PUMP("Pump"); + bool LLAppViewer::mainLoop() { + LLMemType mt1(LLMemType::MTYPE_MAIN); mMainloopTimeout = new LLWatchdogTimeout(); // *FIX:Mani - Make this a setting, once new settings exist in this branch. @@ -837,7 +891,6 @@ bool LLAppViewer::mainLoop() LLVoiceChannel::initClass(); LLVoiceClient::init(gServicePump); - LLMemType mt1(LLMemType::MTYPE_MAIN); LLTimer frameTimer,idleTimer; LLTimer debugTime; LLViewerJoystick* joystick(LLViewerJoystick::getInstance()); @@ -853,21 +906,22 @@ bool LLAppViewer::mainLoop() // Handle messages while (!LLApp::isExiting()) { - LLFastTimer::reset(); // Should be outside of any timer instances + LLFastTimer::nextFrame(); // Should be outside of any timer instances try { - LLFastTimer t(LLFastTimer::FTM_FRAME); pingMainloopTimeout("Main:MiscNativeWindowEvents"); - + + if (gViewerWindow) { - LLFastTimer t2(LLFastTimer::FTM_MESSAGES); + LLFastTimer t2(FTM_MESSAGES); gViewerWindow->mWindow->processMiscNativeEvents(); } pingMainloopTimeout("Main:GatherInput"); + if (gViewerWindow) { - LLFastTimer t2(LLFastTimer::FTM_MESSAGES); + LLFastTimer t2(FTM_MESSAGES); if (!restoreErrorTrap()) { llwarns << " Someone took over my signal/exception handler (post messagehandling)!" << llendl; @@ -885,9 +939,10 @@ bool LLAppViewer::mainLoop() #endif //memory leaking simulation - if(LLFloaterMemLeak::getInstance()) + LLFloaterMemLeak* mem_leak_instance = LLFloaterReg::getTypedInstance<LLFloaterMemLeak>("mem_leaking"); + if(mem_leak_instance) { - LLFloaterMemLeak::getInstance()->idle() ; + mem_leak_instance->idle() ; } // canonical per-frame event @@ -907,6 +962,7 @@ bool LLAppViewer::mainLoop() && !gViewerWindow->getShowProgress() && !gFocusMgr.focusLocked()) { + LLMemType mjk(LLMemType::MTYPE_JOY_KEY); joystick->scanJoystick(); gKeyboard->scanKeyboard(); } @@ -915,13 +971,14 @@ bool LLAppViewer::mainLoop() { pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds! - LLFastTimer t3(LLFastTimer::FTM_IDLE); + LLFastTimer t3(FTM_IDLE); idle(); if (gAres != NULL && gAres->isInitialized()) { + LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP); pingMainloopTimeout("Main:ServicePump"); - LLFastTimer t4(LLFastTimer::FTM_PUMP); + LLFastTimer t4(FTM_PUMP); gAres->process(); // this pump is necessary to make the login screen show up gServicePump->pump(); @@ -947,12 +1004,6 @@ bool LLAppViewer::mainLoop() pingMainloopTimeout("Main:Snapshot"); LLFloaterSnapshot::update(); // take snapshots - -#if LL_LCD_COMPILE - // update LCD Screen - pingMainloopTimeout("Main:LCD"); - gLcdScreen->UpdateDisplay(); -#endif } } @@ -963,7 +1014,8 @@ bool LLAppViewer::mainLoop() // Sleep and run background threads { - LLFastTimer t2(LLFastTimer::FTM_SLEEP); + LLMemType mt_sleep(LLMemType::MTYPE_SLEEP); + LLFastTimer t2(FTM_SLEEP); bool run_multiple_threads = gSavedSettings.getBOOL("RunMultipleThreads"); // yield some time to the os based on command line option @@ -974,7 +1026,7 @@ bool LLAppViewer::mainLoop() // yield cooperatively when not running as foreground window if ( gNoRender - || !gViewerWindow->mWindow->getVisible() + || (gViewerWindow && !gViewerWindow->mWindow->getVisible()) || !gFocusMgr.getAppHasFocus()) { // Sleep if we're not rendering, or the window is minimized. @@ -990,12 +1042,12 @@ bool LLAppViewer::mainLoop() } } - if (gRandomizeFramerate) + if (mRandomizeFramerate) { ms_sleep(rand() % 200); } - if (gPeriodicSlowFrame + if (mPeriodicSlowFrame && (gFrameCount % 10 == 0)) { llinfos << "Periodic slow frame - sleeping 500 ms" << llendl; @@ -1057,9 +1109,10 @@ bool LLAppViewer::mainLoop() catch(std::bad_alloc) { //stop memory leaking simulation - if(LLFloaterMemLeak::getInstance()) + LLFloaterMemLeak* mem_leak_instance = LLFloaterReg::getTypedInstance<LLFloaterMemLeak>("mem_leaking"); + if(mem_leak_instance) { - LLFloaterMemLeak::getInstance()->stop() ; + mem_leak_instance->stop() ; llwarns << "Bad memory allocation in LLAppViewer::mainLoop()!" << llendl ; } else @@ -1084,9 +1137,10 @@ bool LLAppViewer::mainLoop() llwarns << "Bad memory allocation when saveFinalSnapshot() is called!" << llendl ; //stop memory leaking simulation - if(LLFloaterMemLeak::getInstance()) + LLFloaterMemLeak* mem_leak_instance = LLFloaterReg::getTypedInstance<LLFloaterMemLeak>("mem_leaking"); + if(mem_leak_instance) { - LLFloaterMemLeak::getInstance()->stop() ; + mem_leak_instance->stop() ; } } } @@ -1166,6 +1220,14 @@ bool LLAppViewer::cleanup() if (gAudiop) { + // shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem. + + LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl(); + delete sai; + gAudiop->setStreamingAudioImpl(NULL); + + // shut down the audio subsystem + bool want_longname = false; if (gAudiop->getDriverName(want_longname) == "FMOD") { @@ -1221,22 +1283,26 @@ bool LLAppViewer::cleanup() llinfos << "Shutting down." << llendflush; // Destroy the UI - gViewerWindow->shutdownViews(); + if( gViewerWindow) + gViewerWindow->shutdownViews(); // Clean up selection managers after UI is destroyed, as UI may be observing them. // Clean up before GL is shut down because we might be holding on to objects with texture references LLSelectMgr::cleanupGlobals(); // Shut down OpenGL - gViewerWindow->shutdownGL(); + if( gViewerWindow) + { + gViewerWindow->shutdownGL(); + + // Destroy window, and make sure we're not fullscreen + // This may generate window reshape and activation events. + // Therefore must do this before destroying the message system. + delete gViewerWindow; + gViewerWindow = NULL; + llinfos << "ViewerWindow deleted" << llendflush; + } - // Destroy window, and make sure we're not fullscreen - // This may generate window reshape and activation events. - // Therefore must do this before destroying the message system. - delete gViewerWindow; - gViewerWindow = NULL; - llinfos << "ViewerWindow deleted" << llendflush; - // viewer UI relies on keyboard so keep it aound until viewer UI isa gone delete gKeyboard; gKeyboard = NULL; @@ -1256,12 +1322,6 @@ bool LLAppViewer::cleanup() // gDXHardware.cleanup(); //#endif // LL_WINDOWS -#if LL_LCD_COMPILE - // shut down the LCD window on a logitech keyboard, if there is one - delete gLcdScreen; - gLcdScreen = NULL; -#endif - LLVolumeMgr* volume_manager = LLPrimitive::getVolumeManager(); if (!volume_manager->cleanup()) { @@ -1303,7 +1363,9 @@ bool LLAppViewer::cleanup() // Must do this after all panels have been deleted because panels that have persistent rects // save their rects on delete. - gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + + LLUIColorTable::instance().saveUserSettings(); // PerAccountSettingsFile should be empty if no use has been logged on. // *FIX:Mani This should get really saved in a "logoff" mode. @@ -1314,9 +1376,8 @@ bool LLAppViewer::cleanup() // save all settings, even if equals defaults gCrashSettings.saveToFile(crash_settings_filename, FALSE); - gSavedSettings.cleanup(); - gColors.cleanup(); - gCrashSettings.cleanup(); + std::string warnings_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Warnings")); + gWarningSettings.saveToFile(warnings_settings_filename, TRUE); // Save URL history file LLURLHistory::saveFile("url_history.xml"); @@ -1360,6 +1421,7 @@ bool LLAppViewer::cleanup() sTextureCache->shutdown(); sTextureFetch->shutdown(); sImageDecodeThread->shutdown(); + delete sTextureCache; sTextureCache = NULL; delete sTextureFetch; @@ -1367,11 +1429,38 @@ bool LLAppViewer::cleanup() delete sImageDecodeThread; sImageDecodeThread = NULL; + LLLocationHistory::getInstance()->save(); + delete mFastTimerLogThread; + mFastTimerLogThread = NULL; + + if (LLFastTimerView::sAnalyzePerformance) + { + llinfos << "Analyzing performance" << llendl; + + if(LLFastTimer::sLog) + { + LLFastTimerView::doAnalysis( + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "performance_baseline.slp"), + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "performance.slp"), + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "performance_report.csv")); + } + if(LLFastTimer::sMetricLog) + { + LLFastTimerView::doAnalysis( + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "metric_baseline.slp"), + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "metric.slp"), + gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "metric_report.csv")); + } + } + LLMetricPerformanceTester::cleanClass() ; + //Note: - //LLViewerMedia::cleanupClass() has to be put before gImageList.shutdown() + //LLViewerMedia::cleanupClass() has to be put before gTextureList.shutdown() //because some new image might be generated during cleaning up media. --bao + LLViewerMediaFocus::cleanupClass(); LLViewerMedia::cleanupClass(); - gImageList.shutdown(); // shutdown again in case a callback added something + LLViewerParcelMedia::cleanupClass(); + gTextureList.shutdown(); // shutdown again in case a callback added something LLUIImageList::getInstance()->cleanUp(); // This should eventually be done in LLAppViewer @@ -1392,6 +1481,10 @@ bool LLAppViewer::cleanup() gStaticVFS = NULL; delete gVFS; gVFS = NULL; + + gSavedSettings.cleanup(); + LLUIColorTable::instance().clear(); + gCrashSettings.cleanup(); LLWatchdog::getInstance()->cleanup(); @@ -1419,6 +1512,8 @@ bool LLAppViewer::cleanup() llinfos << "File launched." << llendflush; } + ll_close_fail_log(); + llinfos << "Goodbye" << llendflush; // return 0; @@ -1469,6 +1564,13 @@ bool LLAppViewer::initThreads() LLAppViewer::sTextureFetch = new LLTextureFetch(LLAppViewer::getTextureCache(), enable_threads && false); LLImage::initClass(LLAppViewer::getImageDecodeThread()); + if (LLFastTimer::sLog || LLFastTimer::sMetricLog) + { + LLFastTimer::sLogLock = new LLMutex(NULL); + mFastTimerLogThread = new LLFastTimerLogThread(); + mFastTimerLogThread->start(); + } + // *FIX: no error handling here! return true; } @@ -1476,7 +1578,7 @@ bool LLAppViewer::initThreads() void errorCallback(const std::string &error_string) { #ifndef LL_RELEASE_FOR_DOWNLOAD - OSMessageBox(error_string, "Fatal Error", OSMB_OK); + OSMessageBox(error_string, LLTrans::getString("MBFatalError"), OSMB_OK); #endif //Set the ErrorActivated global so we know to create a marker file @@ -1544,7 +1646,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, llinfos << "Attempting to load settings for the group " << settings_group << " - from location " << location_key << llendl; - if(gSettings.find(settings_group) == gSettings.end()) + if(!LLControlGroup::getInstance(settings_group)) { llwarns << "No matching settings group for name " << settings_group << llendl; continue; @@ -1558,10 +1660,10 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string custom_name_setting = file.get("NameFromSetting"); // *NOTE: Regardless of the group currently being lodaed, // this setting is always read from the Global settings. - if(gSettings[sGlobalSettingsName]->controlExists(custom_name_setting)) + if(LLControlGroup::getInstance(sGlobalSettingsName)->controlExists(custom_name_setting)) { std::string file_name = - gSettings[sGlobalSettingsName]->getString(custom_name_setting); + LLControlGroup::getInstance(sGlobalSettingsName)->getString(custom_name_setting); full_settings_path = file_name; } } @@ -1578,7 +1680,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, requirement = file.get("Requirement").asInteger(); } - if(!gSettings[settings_group]->loadFromFile(full_settings_path, set_defaults)) + if(!LLControlGroup::getInstance(settings_group)->loadFromFile(full_settings_path, set_defaults)) { if(requirement == 1) { @@ -1618,17 +1720,17 @@ std::string LLAppViewer::getSettingsFilename(const std::string& location_key, return std::string(); } +void LLAppViewer::loadColorSettings() +{ + LLUIColorTable::instance().loadFromSettings(); +} + bool LLAppViewer::initConfiguration() { - //Set up internal pointers - gSettings[sGlobalSettingsName] = &gSavedSettings; - gSettings[sPerAccountSettingsName] = &gSavedPerAccountSettings; - gSettings[sCrashSettingsName] = &gCrashSettings; - //Load settings files list std::string settings_file_list = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_files.xml"); - LLControlGroup settings_control; - llinfos << "Loading settings file list" << settings_file_list << llendl; + LLControlGroup settings_control("SettingsFiles"); + llinfos << "Loading settings file list " << settings_file_list << llendl; if (0 == settings_control.loadFromFile(settings_file_list)) { llerrs << "Cannot load default configuration file " << settings_file_list << llendl; @@ -1651,18 +1753,16 @@ bool LLAppViewer::initConfiguration() if(!loadSettingsFromDirectory("Default", set_defaults)) { std::ostringstream msg; - msg << "Second Life could not load its default settings file. \n" - << "The installation may be corrupted. \n"; - - OSMessageBox( - msg.str(), - LLStringUtil::null, - OSMB_OK); - + msg << "Unable to load default settings file. The installation may be corrupted."; + OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK); return false; } - - // - set procedural settings + + LLUI::setupPaths(); // setup paths for LLTrans based on settings files only + LLTransUtil::parseStrings("strings.xml", default_trans_args); + LLTransUtil::parseLanguageStrings("language_settings.xml"); + // - set procedural settings + // Note: can't use LL_PATH_PER_SL_ACCOUNT for any of these since we haven't logged in yet gSavedSettings.setString("ClientSettingsFile", gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Global"))); @@ -1685,7 +1785,7 @@ bool LLAppViewer::initConfiguration() gSavedSettings.setBOOL("WatchdogEnabled", FALSE); #endif - gCrashSettings.getControl(CRASH_BEHAVIOR_SETTING)->getSignal()->connect(boost::bind(&handleCrashSubmitBehaviorChanged, _1)); + gCrashSettings.getControl(CRASH_BEHAVIOR_SETTING)->getSignal()->connect(boost::bind(&handleCrashSubmitBehaviorChanged, _2)); // These are warnings that appear on the first experience of that condition. // They are already set in the settings_default.xml file, but still need to be added to LLFirstUse @@ -1696,7 +1796,7 @@ bool LLAppViewer::initConfiguration() LLFirstUse::addConfigVariable("FirstMap"); LLFirstUse::addConfigVariable("FirstGoTo"); LLFirstUse::addConfigVariable("FirstBuild"); - LLFirstUse::addConfigVariable("FirstLeftClickNoHit"); +// LLFirstUse::addConfigVariable("FirstLeftClickNoHit"); LLFirstUse::addConfigVariable("FirstTeleport"); LLFirstUse::addConfigVariable("FirstOverrideKeys"); LLFirstUse::addConfigVariable("FirstAttach"); @@ -1715,26 +1815,18 @@ bool LLAppViewer::initConfiguration() LLControlGroupCLP clp; std::string cmd_line_config = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "cmd_line.xml"); + clp.configure(cmd_line_config, &gSavedSettings); if(!initParseCommandLine(clp)) { - llwarns - << "Error parsing command line options. Command Line options ignored." - << llendl; - + llwarns << "Error parsing command line options. Command Line options ignored." << llendl; + llinfos << "Command line usage:\n" << clp << llendl; std::ostringstream msg; - msg << "Second Life found an error parsing the command line. \n" - << "Please see: http://wiki.secondlife.com/wiki/Client_parameters \n" - << "Error: " << clp.getErrorMessage(); - - OSMessageBox( - msg.str(), - LLStringUtil::null, - OSMB_OK); - + msg << LLTrans::getString("MBCmdLineError") << clp.getErrorMessage(); + OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK); return false; } @@ -1754,7 +1846,6 @@ bool LLAppViewer::initConfiguration() // - load overrides from user_settings loadSettingsFromDirectory("User"); - // - apply command line settings clp.notify(); @@ -1768,7 +1859,7 @@ bool LLAppViewer::initConfiguration() if(clp.hasOption("help")) { std::ostringstream msg; - msg << "Command line usage:\n" << clp; + msg << LLTrans::getString("MBCmdLineUsg") << "\n" << clp; llinfos << msg.str() << llendl; OSMessageBox( @@ -1779,36 +1870,6 @@ bool LLAppViewer::initConfiguration() return false; } - ////////////////////////// - // Apply settings... - if(clp.hasOption("setdefault")) - { - //const LLCommandLineParser::token_vector_t& setdefault = clp.getOption("setdefault"); - //if(0x1 & setdefault.size()) - //{ - // llwarns << "Invalid '--setdefault' parameter count." << llendl; - //} - //else - //{ - // LLCommandLineParser::token_vector_t::const_iterator itr = setdefault.begin(); - // for(; itr != setdefault.end(); ++itr) - // { - // const std::string& name = *itr; - // const std::string& value = *(++itr); - // LLControlVariable* c = gSettings[sGlobalSettingsName]->getControl(name); - // if(c) - // { - // c->setDefault(value); - // } - // else - // { - // llwarns << "'--setdefault' specified with unknown setting: '" - // << name << "'." << llendl; - // } - // } - //} - } - if(clp.hasOption("set")) { const LLCommandLineParser::token_vector_t& set_values = clp.getOption("set"); @@ -1823,7 +1884,7 @@ bool LLAppViewer::initConfiguration() { const std::string& name = *itr; const std::string& value = *(++itr); - LLControlVariable* c = gSettings[sGlobalSettingsName]->getControl(name); + LLControlVariable* c = LLControlGroup::getInstance(sGlobalSettingsName)->getControl(name); if(c) { c->setValue(value, false); @@ -1845,6 +1906,73 @@ bool LLAppViewer::initConfiguration() gCrashOnStartup = TRUE; } + if (clp.hasOption("logperformance")) + { + LLFastTimer::sLog = TRUE; + } + + if(clp.hasOption("logmetrics")) + { + LLFastTimer::sMetricLog = TRUE ; + } + + if (clp.hasOption("graphicslevel")) + { + const LLCommandLineParser::token_vector_t& value = clp.getOption("graphicslevel"); + if(value.size() != 1) + { + llwarns << "Usage: -graphicslevel <0-3>" << llendl; + } + else + { + std::string detail = value.front(); + mForceGraphicsDetail = TRUE; + + switch (detail.c_str()[0]) + { + case '0': + gSavedSettings.setU32("RenderQualityPerformance", 0); + break; + case '1': + gSavedSettings.setU32("RenderQualityPerformance", 1); + break; + case '2': + gSavedSettings.setU32("RenderQualityPerformance", 2); + break; + case '3': + gSavedSettings.setU32("RenderQualityPerformance", 3); + break; + default: + mForceGraphicsDetail = FALSE; + llwarns << "Usage: -graphicslevel <0-3>" << llendl; + break; + } + } + } + + if (clp.hasOption("analyzeperformance")) + { + LLFastTimerView::sAnalyzePerformance = TRUE; + } + + if (clp.hasOption("replaysession")) + { + LLAgentPilot::sReplaySession = TRUE; + } + + if (clp.hasOption("nonotifications")) + { + gSavedSettings.setBOOL("IgnoreAllNotifications", TRUE); + } + + if (clp.hasOption("debugsession")) + { + gDebugSession = TRUE; + gDebugGL = TRUE; + + ll_init_fail_log(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "test_failures.log")); + } + // Handle slurl use. NOTE: Don't let SL-55321 reappear. // *FIX: This init code should be made more robust to prevent @@ -1865,7 +1993,7 @@ bool LLAppViewer::initConfiguration() if(clp.hasOption("url")) { std::string slurl = clp.getOption("url")[0]; - if (LLURLDispatcher::isSLURLCommand(slurl)) + if (LLSLURL::isSLURLCommand(slurl)) { LLStartUp::sSLURLCommand = slurl; } @@ -1877,9 +2005,9 @@ bool LLAppViewer::initConfiguration() else if(clp.hasOption("slurl")) { std::string slurl = clp.getOption("slurl")[0]; - if(LLURLDispatcher::isSLURL(slurl)) + if(LLSLURL::isSLURL(slurl)) { - if (LLURLDispatcher::isSLURLCommand(slurl)) + if (LLSLURL::isSLURLCommand(slurl)) { LLStartUp::sSLURLCommand = slurl; } @@ -1893,13 +2021,12 @@ bool LLAppViewer::initConfiguration() const LLControlVariable* skinfolder = gSavedSettings.getControl("SkinCurrent"); if(skinfolder && LLStringUtil::null != skinfolder->getValue().asString()) { - gDirUtilp->setSkinFolder(skinfolder->getValue().asString()); + // hack to force the skin to default. + //gDirUtilp->setSkinFolder(skinfolder->getValue().asString()); + gDirUtilp->setSkinFolder("default"); } mYieldTime = gSavedSettings.getS32("YieldTime"); - - // XUI:translate - gSecondLife = "Second Life"; // Read skin/branding settings if specified. //if (! gDirUtilp->getSkinDir().empty() ) @@ -1916,7 +2043,7 @@ bool LLAppViewer::initConfiguration() #if LL_DARWIN // Initialize apple menubar and various callbacks - init_apple_menu(gSecondLife.c_str()); + init_apple_menu(LLTrans::getString("APP_NAME").c_str()); #if __ppc__ // If the CPU doesn't have Altivec (i.e. it's not at least a G4), don't go any further. @@ -1924,7 +2051,7 @@ bool LLAppViewer::initConfiguration() if(!gSysCPU.hasAltivec()) { std::ostringstream msg; - msg << gSecondLife << " requires a processor with AltiVec (G4 or later)."; + msg << LLTrans::getString("MBRequiresAltiVec"); OSMessageBox( msg.str(), LLStringUtil::null, @@ -1939,7 +2066,7 @@ bool LLAppViewer::initConfiguration() // Display splash screen. Must be after above check for previous // crash as this dialog is always frontmost. std::ostringstream splash_msg; - splash_msg << "Loading " << gSecondLife << "..."; + splash_msg << "Loading " << LLTrans::getString("SECOND_LIFE") << "..."; LLSplashScreen::show(); LLSplashScreen::update(splash_msg.str()); @@ -1955,12 +2082,11 @@ bool LLAppViewer::initConfiguration() // // Set the name of the window // -#if LL_RELEASE_FOR_DOWNLOAD - gWindowTitle = gSecondLife; -#elif LL_DEBUG - gWindowTitle = gSecondLife + std::string(" [DEBUG] ") + gArgs; + gWindowTitle = LLTrans::getString("APP_NAME"); +#if LL_DEBUG + gWindowTitle += std::string(" [DEBUG] ") + gArgs; #else - gWindowTitle = gSecondLife + std::string(" ") + gArgs; + gWindowTitle += std::string(" ") + gArgs; #endif LLStringUtil::truncate(gWindowTitle, 255); @@ -1997,11 +2123,7 @@ bool LLAppViewer::initConfiguration() if (mSecondInstance) { std::ostringstream msg; - msg << - gSecondLife << " is already running.\n" - "\n" - "Check your task bar for a minimized copy of the program.\n" - "If this message persists, restart your computer.", + msg << LLTrans::getString("MBAlreadyRunning"); OSMessageBox( msg.str(), LLStringUtil::null, @@ -2046,6 +2168,8 @@ bool LLAppViewer::initConfiguration() gLastRunVersion = gSavedSettings.getString("LastRunVersion"); + loadColorSettings(); + return true; // Config was successful. } @@ -2074,12 +2198,8 @@ void LLAppViewer::checkForCrash(void) if(gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING) == CRASH_BEHAVIOR_ASK) { std::ostringstream msg; - msg << gSecondLife - << " appears to have frozen or crashed on the previous run.\n" - << "Would you like to send a crash report?"; - std::string alert; - alert = gSecondLife; - alert += " Alert"; + msg << LLTrans::getString("MBFrozenCrashed"); + std::string alert = LLTrans::getString("APP_NAME") + " " + LLTrans::getString("MBAlert"); choice = OSMessageBox(msg.str(), alert, OSMB_YESNO); @@ -2127,10 +2247,10 @@ bool LLAppViewer::initWindow() gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight"), FALSE, ignorePixelDepth); - if (gSavedSettings.getBOOL("FullScreen")) + if (gSavedSettings.getBOOL("WindowFullScreen")) { + // request to go full screen... which will be delayed until login gViewerWindow->toggleFullscreen(FALSE); - // request to go full screen... which will be delayed until login } if (gSavedSettings.getBOOL("WindowMaximized")) @@ -2145,6 +2265,11 @@ bool LLAppViewer::initWindow() // Initialize GL stuff // + if (mForceGraphicsDetail) + { + LLFeatureManager::getInstance()->setGraphicsLevel(gSavedSettings.getU32("RenderQualityPerformance"), false); + } + // Set this flag in case we crash while initializing GL gSavedSettings.setBOOL("RenderInitError", TRUE); gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); @@ -2165,9 +2290,6 @@ bool LLAppViewer::initWindow() LLUI::sWindow = gViewerWindow->getWindow(); - LLTrans::parseStrings("strings.xml"); - LLUITrans::parseStrings("ui_strings.xml"); - // Show watch cursor gViewerWindow->setCursor(UI_CURSOR_WAIT); @@ -2287,7 +2409,7 @@ void LLAppViewer::writeSystemInfo() gDebugInfo["CrashNotHandled"] = (LLSD::Boolean)true; // Dump some debugging info - LL_INFOS("SystemInfo") << gSecondLife + LL_INFOS("SystemInfo") << LLTrans::getString("APP_NAME") << " version " << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "." << LL_VERSION_PATCH << LL_ENDL; @@ -2365,7 +2487,7 @@ void LLAppViewer::handleViewerCrash() gDebugInfo["CurrentPath"] = gDirUtilp->getCurPath(); gDebugInfo["SessionLength"] = F32(LLFrameTimer::getElapsedSeconds()); gDebugInfo["StartupState"] = LLStartUp::getStartupStateString(); - gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer) getCurrentRSS() >> 10; + gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer) LLMemory::getCurrentRSS() >> 10; gDebugInfo["FirstLogin"] = (LLSD::Boolean) gAgent.isFirstLogin(); gDebugInfo["FirstRunThisInstall"] = gSavedSettings.getBOOL("FirstRunThisInstall"); @@ -2776,12 +2898,14 @@ bool LLAppViewer::initCache() gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")); purgeCache(); // purge old cache gSavedSettings.setString("CacheLocation", new_cache_location); + gSavedSettings.setString("CacheLocationTopFolder", gDirUtilp->getBaseFileName(new_cache_location)); } if (!gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation"))) { LL_WARNS("AppCache") << "Unable to set cache location" << LL_ENDL; gSavedSettings.setString("CacheLocation", ""); + gSavedSettings.setString("CacheLocationTopFolder", ""); } if (mPurgeCache) @@ -2961,12 +3085,12 @@ void LLAppViewer::purgeCache() gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); } -const std::string& LLAppViewer::getSecondLifeTitle() const +std::string LLAppViewer::getSecondLifeTitle() const { - return gSecondLife; + return LLTrans::getString("APP_NAME"); } -const std::string& LLAppViewer::getWindowTitle() const +std::string LLAppViewer::getWindowTitle() const { return gWindowTitle; } @@ -3000,7 +3124,7 @@ void LLAppViewer::forceDisconnect(const std::string& mesg) return; } - // Translate the message if possible + // *TODO: Translate the message if possible std::string big_reason = LLAgent::sTeleportErrorMessages[mesg]; if ( big_reason.size() == 0 ) { @@ -3128,6 +3252,15 @@ public: } }; +static LLFastTimer::DeclareTimer FTM_AUDIO_UPDATE("Update Audio"); +static LLFastTimer::DeclareTimer FTM_CLEANUP("Cleanup"); +static LLFastTimer::DeclareTimer FTM_IDLE_CB("Idle Callbacks"); +static LLFastTimer::DeclareTimer FTM_LOD_UPDATE("Update LOD"); +static LLFastTimer::DeclareTimer FTM_OBJECTLIST_UPDATE("Update Objectlist"); +static LLFastTimer::DeclareTimer FTM_REGION_UPDATE("Update Region"); +static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World"); +static LLFastTimer::DeclareTimer FTM_NETWORK("Network"); + /////////////////////////////////////////////////////// // idle() // @@ -3136,6 +3269,7 @@ public: /////////////////////////////////////////////////////// void LLAppViewer::idle() { + LLMemType mt_idle(LLMemType::MTYPE_IDLE); pingMainloopTimeout("Main:Idle"); // Update frame timers @@ -3179,7 +3313,6 @@ void LLAppViewer::idle() // // Special case idle if still starting up // - if (LLStartUp::getStartupState() < STATE_STARTED) { // Skip rest if idle startup returns false (essentially, no world yet) @@ -3194,7 +3327,7 @@ void LLAppViewer::idle() if (!gDisconnected) { - LLFastTimer t(LLFastTimer::FTM_NETWORK); + LLFastTimer t(FTM_NETWORK); // Update spaceserver timeinfo LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + (U32)(dt_raw * SEC_TO_MICROSEC)); @@ -3219,7 +3352,7 @@ void LLAppViewer::idle() // When appropriate, update agent location to the simulator. F32 agent_update_time = agent_update_timer.getElapsedTimeF32(); BOOL flags_changed = gAgent.controlFlagsDirty() || (last_control_flags != gAgent.getControlFlags()); - + if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND))) { // Send avatar and camera info @@ -3234,7 +3367,6 @@ void LLAppViewer::idle() // Manage statistics // // - { // Initialize the viewer_stats_timer with an already elapsed time // of SEND_STATS_PERIOD so that the initial stats report will @@ -3272,12 +3404,11 @@ void LLAppViewer::idle() gObjectList.mNumUnknownUpdates = 0; } } - gFrameStats.addFrameData(); } - + if (!gDisconnected) { - LLFastTimer t(LLFastTimer::FTM_NETWORK); + LLFastTimer t(FTM_NETWORK); //////////////////////////////////////////////// // @@ -3287,12 +3418,10 @@ void LLAppViewer::idle() // floating throughout the various object lists. // - gFrameStats.start(LLFrameStats::IDLE_NETWORK); stop_glerror(); idleNetwork(); stop_glerror(); - gFrameStats.start(LLFrameStats::AGENT_MISC); // Check for away from keyboard, kick idle agents. idle_afk_check(); @@ -3308,7 +3437,7 @@ void LLAppViewer::idle() // { -// LLFastTimer t(LLFastTimer::FTM_IDLE_CB); +// LLFastTimer t(FTM_IDLE_CB); // Do event notifications if necessary. Yes, we may want to move this elsewhere. gEventNotifier.update(); @@ -3321,7 +3450,7 @@ void LLAppViewer::idle() return; } - gViewerWindow->handlePerFrameHover(); + gViewerWindow->updateUI(); /////////////////////////////////////// // Agent and camera movement @@ -3337,14 +3466,13 @@ void LLAppViewer::idle() { // Handle pending gesture processing - gGestureManager.update(); + LLGestureManager::instance().update(); gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY); } { - LLFastTimer t(LLFastTimer::FTM_OBJECTLIST_UPDATE); // Actually "object update" - gFrameStats.start(LLFrameStats::OBJECT_UPDATE); + LLFastTimer t(FTM_OBJECTLIST_UPDATE); // Actually "object update" if (!(logoutRequestSent() && hasSavedFinalSnapshot())) { @@ -3359,8 +3487,7 @@ void LLAppViewer::idle() // { - LLFastTimer t(LLFastTimer::FTM_CLEANUP); - gFrameStats.start(LLFrameStats::CLEAN_DEAD); + LLFastTimer t(FTM_CLEANUP); gObjectList.cleanDeadObjects(); LLDrawable::cleanupDeadDrawables(); } @@ -3379,7 +3506,6 @@ void LLAppViewer::idle() // { - gFrameStats.start(LLFrameStats::UPDATE_EFFECTS); LLSelectMgr::getInstance()->updateEffects(); LLHUDManager::getInstance()->cleanupEffects(); LLHUDManager::getInstance()->sendEffects(); @@ -3393,7 +3519,7 @@ void LLAppViewer::idle() // { - LLFastTimer t(LLFastTimer::FTM_NETWORK); + LLFastTimer t(FTM_NETWORK); gVLManager.unpackData(); } @@ -3405,7 +3531,7 @@ void LLAppViewer::idle() LLWorld::getInstance()->updateVisibilities(); { const F32 max_region_update_time = .001f; // 1ms - LLFastTimer t(LLFastTimer::FTM_REGION_UPDATE); + LLFastTimer t(FTM_REGION_UPDATE); LLWorld::getInstance()->updateRegions(max_region_update_time); } @@ -3452,11 +3578,9 @@ void LLAppViewer::idle() if (!gNoRender) { - LLFastTimer t(LLFastTimer::FTM_WORLD_UPDATE); - gFrameStats.start(LLFrameStats::UPDATE_MOVE); + LLFastTimer t(FTM_WORLD_UPDATE); gPipeline.updateMove(); - gFrameStats.start(LLFrameStats::UPDATE_PARTICLES); LLWorld::getInstance()->updateParticles(); } stop_glerror(); @@ -3475,15 +3599,17 @@ void LLAppViewer::idle() gAgent.updateCamera(); } + // update media focus + LLViewerMediaFocus::getInstance()->update(); + // objects and camera should be in sync, do LOD calculations now { - LLFastTimer t(LLFastTimer::FTM_LOD_UPDATE); + LLFastTimer t(FTM_LOD_UPDATE); gObjectList.updateApparentAngles(gAgent); } { - gFrameStats.start(LLFrameStats::AUDIO); - LLFastTimer t(LLFastTimer::FTM_AUDIO_UPDATE); + LLFastTimer t(FTM_AUDIO_UPDATE); if (gAudiop) { @@ -3623,8 +3749,11 @@ void LLAppViewer::sendLogoutRequest() static F32 CheckMessagesMaxTime = CHECK_MESSAGES_DEFAULT_MAX_TIME; #endif +static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Network"); + void LLAppViewer::idleNetwork() { + LLMemType mt_in(LLMemType::MTYPE_IDLE_NETWORK); pingMainloopTimeout("idleNetwork"); LLError::LLCallStacks::clear() ; llpushcallstacks ; @@ -3634,7 +3763,7 @@ void LLAppViewer::idleNetwork() if (!gSavedSettings.getBOOL("SpeedTest")) { - LLFastTimer t(LLFastTimer::FTM_IDLE_NETWORK); // decode + LLFastTimer t(FTM_IDLE_NETWORK); // decode // deal with any queued name requests and replies. gCacheName->processPending(); @@ -3644,7 +3773,8 @@ void LLAppViewer::idleNetwork() stop_glerror(); const S64 frame_count = gFrameCount; // U32->S64 F32 total_time = 0.0f; - while (gMessageSystem->checkAllMessages(frame_count, gServicePump)) + + while (gMessageSystem->checkAllMessages(frame_count, gServicePump)) { if (gDoDisconnect) { @@ -3673,6 +3803,7 @@ void LLAppViewer::idleNetwork() break; #endif } + // Handle per-frame message system processing. gMessageSystem->processAcks(); @@ -3711,7 +3842,7 @@ void LLAppViewer::idleNetwork() } } llpushcallstacks ; - gObjectList.mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); + LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); // Retransmit unacknowledged packets. gXferManager->retransmitUnackedPackets(); @@ -3752,7 +3883,6 @@ void LLAppViewer::disconnectViewer() llinfos << "Disconnecting viewer!" << llendl; // Dump our frame statistics - gFrameStats.dump(); // Remember if we were flying gSavedSettings.setBOOL("FlyingAtExit", gAgent.getFlying() ); @@ -3764,35 +3894,6 @@ void LLAppViewer::disconnectViewer() { gFloaterView->restoreAll(); } - - - std::list<LLFloater*> floaters_to_close; - for(LLView::child_list_const_iter_t it = gFloaterView->getChildList()->begin(); - it != gFloaterView->getChildList()->end(); - ++it) - { - // The following names are defined in the - // floater_image_preview.xml - // floater_sound_preview.xml - // floater_animation_preview.xml - // files. - LLFloater* fl = static_cast<LLFloater*>(*it); - if(fl - && (fl->getName() == "Image Preview" - || fl->getName() == "Sound Preview" - || fl->getName() == "Animation Preview" - )) - { - floaters_to_close.push_back(fl); - } - } - - while(!floaters_to_close.empty()) - { - LLFloater* fl = floaters_to_close.front(); - floaters_to_close.pop_front(); - fl->close(); - } } if (LLSelectMgr::getInstance()) @@ -3800,20 +3901,22 @@ void LLAppViewer::disconnectViewer() LLSelectMgr::getInstance()->deselectAll(); } - if (!gNoRender) + // save inventory if appropriate + gInventory.cache(gInventory.getRootFolderID(), gAgent.getID()); + if (gInventory.getLibraryRootFolderID().notNull() + && gInventory.getLibraryOwnerID().notNull()) { - // save inventory if appropriate - gInventory.cache(gAgent.getInventoryRootID(), gAgent.getID()); - if(gInventoryLibraryRoot.notNull() && gInventoryLibraryOwner.notNull()) - { - gInventory.cache(gInventoryLibraryRoot, gInventoryLibraryOwner); - } + gInventory.cache( + gInventory.getLibraryRootFolderID(), + gInventory.getLibraryOwnerID()); } saveNameCache(); // close inventory interface, close all windows - LLInventoryView::cleanup(); + LLFloaterInventory::cleanup(); + + gAgentWearables.cleanup(); // Also writes cached agent settings to gSavedSettings gAgent.cleanup(); @@ -3965,5 +4068,8 @@ void LLAppViewer::handleLoginComplete() { gDebugInfo["MainloopTimeoutState"] = LLAppViewer::instance()->mMainloopTimeout->getState(); } + + mOnLoginCompleted(); + writeDebugInfo(); } |