aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llappviewer.cpp133
1 files changed, 106 insertions, 27 deletions
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp
index a461dcb..f39610f 100644
--- a/linden/indra/newview/llappviewer.cpp
+++ b/linden/indra/newview/llappviewer.cpp
@@ -269,6 +269,7 @@ BOOL gUseWireframe = FALSE;
269LLVFS* gStaticVFS = NULL; 269LLVFS* gStaticVFS = NULL;
270 270
271LLMemoryInfo gSysMemory; 271LLMemoryInfo gSysMemory;
272U64 gMemoryAllocated = 0; // updated in display_stats() in llviewerdisplay.cpp
272 273
273LLString gLastVersionChannel; 274LLString gLastVersionChannel;
274 275
@@ -285,6 +286,7 @@ BOOL gPeriodicSlowFrame = FALSE;
285BOOL gCrashOnStartup = FALSE; 286BOOL gCrashOnStartup = FALSE;
286BOOL gLLErrorActivated = FALSE; 287BOOL gLLErrorActivated = FALSE;
287BOOL gLogoutInProgress = FALSE; 288BOOL gLogoutInProgress = FALSE;
289
288//////////////////////////////////////////////////////////// 290////////////////////////////////////////////////////////////
289// Internal globals... that should be removed. 291// Internal globals... that should be removed.
290static LLString gArgs; 292static LLString gArgs;
@@ -320,6 +322,48 @@ void idle_afk_check()
320 } 322 }
321} 323}
322 324
325//this function checks if the system can allocate (num_chunk)MB memory successfully.
326//if this check fails, the allocated memory is NOT freed.
327void idle_mem_check(S32 num_chunk)
328{
329 //this flag signals if memory allocation check is necessary
330 static BOOL check = TRUE ;
331
332 if(!check) //if memory check fails before, do not repeat it.
333 {
334 return ;
335 }
336 check = FALSE ; //before memory check for this frame, turn off check signal for the next frame.
337
338 S32 i = 0 ;
339 char**p = new char*[num_chunk] ;
340 if(!p)
341 {
342 return ;
343 }
344 for(i = 0 ; i < num_chunk ; i++)
345 {
346 //1MB per chunk
347 //if the allocation fails, the system should catch it.
348 p[i] = new char[1024 * 1024] ;
349
350 if(!p[i]) //in case that system try-catch is turned off
351 {
352 return ;
353 }
354 }
355
356 //release memory if the allocation check does not fail.
357 for(i = 0 ; i < num_chunk ; i++)
358 {
359 delete[] p[i] ;
360 }
361 delete[] p ;
362
363 //memory check for this frame succeeds, turn on next frame check.
364 check = TRUE ;
365}
366
323// A callback set in LLAppViewer::init() 367// A callback set in LLAppViewer::init()
324static void ui_audio_callback(const LLUUID& uuid) 368static void ui_audio_callback(const LLUUID& uuid)
325{ 369{
@@ -351,6 +395,24 @@ void request_initial_instant_messages()
351 } 395 }
352} 396}
353 397
398// A settings system callback for CrashSubmitBehavior
399bool handleCrashSubmitBehaviorChanged(const LLSD& newvalue)
400{
401 S32 cb = newvalue.asInteger();
402 const S32 NEVER_SUBMIT_REPORT = 2;
403 if(cb == NEVER_SUBMIT_REPORT)
404 {
405 // LLWatchdog::getInstance()->cleanup(); // SJB: cleaning up a running watchdog is unsafe
406 LLAppViewer::instance()->destroyMainloopTimeout();
407 }
408 else if(gSavedSettings.getBOOL("WatchdogEnabled") == TRUE)
409 {
410// LLWatchdog::getInstance()->init();
411// LLAppViewer::instance()->initMainloopTimeout("Mainloop Resume");
412 }
413 return true;
414}
415
354// Use these strictly for things that are constructed at startup, 416// Use these strictly for things that are constructed at startup,
355// or for things that are performance critical. JC 417// or for things that are performance critical. JC
356static void settings_to_globals() 418static void settings_to_globals()
@@ -457,9 +519,8 @@ void LLAppViewer::initGridChoice()
457 std::string grid_choice = gSavedSettings.getString("CmdLineGridChoice"); 519 std::string grid_choice = gSavedSettings.getString("CmdLineGridChoice");
458 LLViewerLogin::getInstance()->setGridChoice(grid_choice); 520 LLViewerLogin::getInstance()->setGridChoice(grid_choice);
459 521
460#if !LL_RELEASE_FOR_DOWNLOAD 522 // Load last server choice by default
461 // Development version: load last server choice by default 523 // ignored if the command line grid choice has been set
462 // ignored is the command line grid choice has been set
463 if(grid_choice.empty()) 524 if(grid_choice.empty())
464 { 525 {
465 S32 server = gSavedSettings.getS32("ServerChoice"); 526 S32 server = gSavedSettings.getS32("ServerChoice");
@@ -474,7 +535,6 @@ void LLAppViewer::initGridChoice()
474 LLViewerLogin::getInstance()->setGridChoice((EGridInfo)server); 535 LLViewerLogin::getInstance()->setGridChoice((EGridInfo)server);
475 } 536 }
476 } 537 }
477#endif
478} 538}
479 539
480bool send_url_to_other_instance(const std::string& url) 540bool send_url_to_other_instance(const std::string& url)
@@ -521,7 +581,6 @@ LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
521 581
522LLAppViewer::LLAppViewer() : 582LLAppViewer::LLAppViewer() :
523 mMarkerFile(NULL), 583 mMarkerFile(NULL),
524 mCrashBehavior(CRASH_BEHAVIOR_ASK),
525 mReportedCrash(false), 584 mReportedCrash(false),
526 mNumSessions(0), 585 mNumSessions(0),
527 mPurgeCache(false), 586 mPurgeCache(false),
@@ -543,12 +602,7 @@ LLAppViewer::LLAppViewer() :
543 602
544LLAppViewer::~LLAppViewer() 603LLAppViewer::~LLAppViewer()
545{ 604{
546 if(mMainloopTimeout) 605 destroyMainloopTimeout();
547 {
548 // delete the mainloop timeout.
549 delete mMainloopTimeout;
550 mMainloopTimeout = NULL;
551 }
552 606
553 // If we got to this destructor somehow, the app didn't hang. 607 // If we got to this destructor somehow, the app didn't hang.
554 removeMarkerFile(); 608 removeMarkerFile();
@@ -860,6 +914,8 @@ bool LLAppViewer::mainLoop()
860 { 914 {
861 LLFastTimer t(LLFastTimer::FTM_FRAME); 915 LLFastTimer t(LLFastTimer::FTM_FRAME);
862 916
917 pingMainloopTimeout("Main:GatherInput");
918
863 { 919 {
864 LLFastTimer t2(LLFastTimer::FTM_MESSAGES); 920 LLFastTimer t2(LLFastTimer::FTM_MESSAGES);
865 #if LL_WINDOWS 921 #if LL_WINDOWS
@@ -880,8 +936,13 @@ bool LLAppViewer::mainLoop()
880 } 936 }
881#endif 937#endif
882 938
939 //at the beginning of every frame, check if the system can successfully allocate 10 * 1 MB memory.
940 idle_mem_check(10) ;
941
883 if (!LLApp::isExiting()) 942 if (!LLApp::isExiting())
884 { 943 {
944 pingMainloopTimeout("Main:JoystickKeyboard");
945
885 // Scan keyboard for movement keys. Command keys and typing 946 // Scan keyboard for movement keys. Command keys and typing
886 // are handled by windows callbacks. Don't do this until we're 947 // are handled by windows callbacks. Don't do this until we're
887 // done initializing. JC 948 // done initializing. JC
@@ -896,6 +957,8 @@ bool LLAppViewer::mainLoop()
896 gKeyboard->scanKeyboard(); 957 gKeyboard->scanKeyboard();
897 } 958 }
898 959
960 pingMainloopTimeout("Main:Messages");
961
899 // Update state based on messages, user input, object idle. 962 // Update state based on messages, user input, object idle.
900 { 963 {
901 LLFastTimer t3(LLFastTimer::FTM_IDLE); 964 LLFastTimer t3(LLFastTimer::FTM_IDLE);
@@ -912,25 +975,32 @@ bool LLAppViewer::mainLoop()
912 975
913 if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED)) 976 if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED))
914 { 977 {
978 pauseMainloopTimeout();
915 saveFinalSnapshot(); 979 saveFinalSnapshot();
916 disconnectViewer(); 980 disconnectViewer();
981 resumeMainloopTimeout();
917 } 982 }
918 983
919 // Render scene. 984 // Render scene.
920 if (!LLApp::isExiting()) 985 if (!LLApp::isExiting())
921 { 986 {
987 pingMainloopTimeout("Main:Display");
922 display(); 988 display();
923 989
990 pingMainloopTimeout("Main:Snapshot");
924 LLFloaterSnapshot::update(); // take snapshots 991 LLFloaterSnapshot::update(); // take snapshots
925 992
926#if LL_WINDOWS && LL_LCD_COMPILE 993#if LL_WINDOWS && LL_LCD_COMPILE
927 // update LCD Screen 994 // update LCD Screen
995 pingMainloopTimeout("Main:LCD");
928 gLcdScreen->UpdateDisplay(); 996 gLcdScreen->UpdateDisplay();
929#endif 997#endif
930 } 998 }
931 999
932 } 1000 }
933 1001
1002 pingMainloopTimeout("Main:Sleep");
1003
934 pauseMainloopTimeout(); 1004 pauseMainloopTimeout();
935 1005
936 // Sleep and run background threads 1006 // Sleep and run background threads
@@ -1017,7 +1087,7 @@ bool LLAppViewer::mainLoop()
1017 1087
1018 resumeMainloopTimeout(); 1088 resumeMainloopTimeout();
1019 1089
1020 pingMainloopTimeout("Mainloop"); 1090 pingMainloopTimeout("Main:End");
1021 } 1091 }
1022 1092
1023 } 1093 }
@@ -1042,11 +1112,7 @@ bool LLAppViewer::mainLoop()
1042 1112
1043 delete gServicePump; 1113 delete gServicePump;
1044 1114
1045 if(mMainloopTimeout) 1115 destroyMainloopTimeout();
1046 {
1047 delete mMainloopTimeout;
1048 mMainloopTimeout = NULL;
1049 }
1050 1116
1051 llinfos << "Exiting main_loop" << llendflush; 1117 llinfos << "Exiting main_loop" << llendflush;
1052 1118
@@ -1350,7 +1416,7 @@ bool LLAppViewer::initThreads()
1350 1416
1351 const S32 NEVER_SUBMIT_REPORT = 2; 1417 const S32 NEVER_SUBMIT_REPORT = 2;
1352 if(TRUE == gSavedSettings.getBOOL("WatchdogEnabled") 1418 if(TRUE == gSavedSettings.getBOOL("WatchdogEnabled")
1353 && (gCrashSettings.getS32("CrashSubmitBehavior") != NEVER_SUBMIT_REPORT)) 1419 && (gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING) != NEVER_SUBMIT_REPORT))
1354 { 1420 {
1355 LLWatchdog::getInstance()->init(); 1421 LLWatchdog::getInstance()->init();
1356 } 1422 }
@@ -1512,10 +1578,16 @@ bool LLAppViewer::initConfiguration()
1512 //*FIX:Mani - Set default to disabling watchdog mainloop 1578 //*FIX:Mani - Set default to disabling watchdog mainloop
1513 // timeout for mac and linux. There is no call stack info 1579 // timeout for mac and linux. There is no call stack info
1514 // on these platform to help debug. 1580 // on these platform to help debug.
1581#ifndef LL_RELEASE_FOR_DOWNLOAD
1582 gSavedSettings.setBOOL("WatchdogEnabled", FALSE);
1583#endif
1584
1515#ifndef LL_WINDOWS 1585#ifndef LL_WINDOWS
1516 gSavedSettings.setBOOL("WatchdogEnabled", FALSE); 1586 gSavedSettings.setBOOL("WatchdogEnabled", FALSE);
1517#endif 1587#endif
1518 1588
1589 gCrashSettings.getControl(CRASH_BEHAVIOR_SETTING)->getSignal()->connect(boost::bind(&handleCrashSubmitBehaviorChanged, _1));
1590
1519 // These are warnings that appear on the first experience of that condition. 1591 // These are warnings that appear on the first experience of that condition.
1520 // They are already set in the settings_default.xml file, but still need to be added to LLFirstUse 1592 // They are already set in the settings_default.xml file, but still need to be added to LLFirstUse
1521 // for disable/reset ability 1593 // for disable/reset ability
@@ -2153,9 +2225,10 @@ void LLAppViewer::writeSystemInfo()
2153 gDebugInfo["CPUInfo"]["CPUSSE"] = gSysCPU.hasSSE(); 2225 gDebugInfo["CPUInfo"]["CPUSSE"] = gSysCPU.hasSSE();
2154 gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2(); 2226 gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2();
2155 2227
2156 gDebugInfo["RAMInfo"] = llformat("%u", gSysMemory.getPhysicalMemoryKB()); 2228 gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB());
2229 gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated>>10); // MB -> KB
2157 gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple(); 2230 gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple();
2158 2231
2159 // *FIX:Mani - move this ddown in llappviewerwin32 2232 // *FIX:Mani - move this ddown in llappviewerwin32
2160#ifdef LL_WINDOWS 2233#ifdef LL_WINDOWS
2161 DWORD thread_id = GetCurrentThreadId(); 2234 DWORD thread_id = GetCurrentThreadId();
@@ -2191,7 +2264,10 @@ void LLAppViewer::handleSyncViewerCrash()
2191void LLAppViewer::handleViewerCrash() 2264void LLAppViewer::handleViewerCrash()
2192{ 2265{
2193 llinfos << "Handle viewer crash entry." << llendl; 2266 llinfos << "Handle viewer crash entry." << llendl;
2194 2267
2268 // Make sure the watchdog gets turned off...
2269// LLWatchdog::getInstance()->cleanup(); // SJB: This causes the Watchdog to hang for an extra 20-40s?!
2270
2195 LLAppViewer* pApp = LLAppViewer::instance(); 2271 LLAppViewer* pApp = LLAppViewer::instance();
2196 if (pApp->beingDebugged()) 2272 if (pApp->beingDebugged())
2197 { 2273 {
@@ -2315,12 +2391,6 @@ void LLAppViewer::handleViewerCrash()
2315 return; 2391 return;
2316} 2392}
2317 2393
2318void LLAppViewer::setCrashBehavior(S32 cb)
2319{
2320 mCrashBehavior = cb;
2321 gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, mCrashBehavior);
2322}
2323
2324bool LLAppViewer::anotherInstanceRunning() 2394bool LLAppViewer::anotherInstanceRunning()
2325{ 2395{
2326 // We create a marker file when the program starts and remove the file when it finishes. 2396 // We create a marker file when the program starts and remove the file when it finishes.
@@ -3618,6 +3688,15 @@ void LLAppViewer::initMainloopTimeout(const std::string& state, F32 secs)
3618 } 3688 }
3619} 3689}
3620 3690
3691void LLAppViewer::destroyMainloopTimeout()
3692{
3693 if(mMainloopTimeout)
3694 {
3695 delete mMainloopTimeout;
3696 mMainloopTimeout = NULL;
3697 }
3698}
3699
3621void LLAppViewer::resumeMainloopTimeout(const std::string& state, F32 secs) 3700void LLAppViewer::resumeMainloopTimeout(const std::string& state, F32 secs)
3622{ 3701{
3623 if(mMainloopTimeout) 3702 if(mMainloopTimeout)