summaryrefslogtreecommitdiff
path: root/indra/newview/llappdelegate-objc.mm
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2018-08-23 12:31:54 -0400
committerNat Goodspeed <nat@lindenlab.com>2018-08-23 12:31:54 -0400
commite674f11757ab55c5ca7aab4cb1c8e059fa98f466 (patch)
tree81fcc0c7f513585c64cca6910dc87723894b21bd /indra/newview/llappdelegate-objc.mm
parentafbf243f1a049bdeec6410bcc57350b00d0da169 (diff)
DRTVWR-447: Add (some) metadata to Mac crash reports.
This required reordering certain operations during Mac viewer startup. Split llappviewermacosx.cpp's initViewer() function into constructViewer() (which instantiates LLAppViewerMacOSX) and initViewer() (which calls LLAppViewerMacOSX::init()). llappdelegate-objc.mm's applicationDidFinishLaunching override now calls [BugsplatStartupManager start] between constructViewer() and initViewer(): we want constructViewer() to have set up the logging subsystem so we can log the actions of BugsplatStartupManagerDelegate override methods, but otherwise we want BugsplatStartupManager in place as early as possible to catch any early crashes. Besides, initViewer() ends up overwriting the static_debug_info.log on which we depend for the *previous* run's crash metadata. Move the code that initializes the pathname of the static_debug_info.log file from LLAppViewerMacOSX::init() to the LLAppViewerMacOSX() constructor, since BugsplatStartupManagerDelegate override methods need to read (the previous run's) file. Add code to applicationLogForBugsplatStartupManager override to set new BugsplatMac 1.0.6 properties userName and userEmail. Don't log empty fields from static_debug_info.log if we couldn't read it.
Diffstat (limited to 'indra/newview/llappdelegate-objc.mm')
-rw-r--r--indra/newview/llappdelegate-objc.mm55
1 files changed, 42 insertions, 13 deletions
diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index 66bcf58961..f55304f30b 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -54,6 +54,25 @@
- (void) applicationDidFinishLaunching:(NSNotification *)notification
{
+ // Call constructViewer() first so our logging subsystem is in place. This
+ // risks missing crashes in the LLAppViewerMacOSX constructor, but for
+ // present purposes it's more important to get the startup sequence
+ // properly logged.
+ // Someday I would like to modify the logging system so that calls before
+ // it's initialized are cached in a std::ostringstream and then, once it's
+ // initialized, "played back" into whatever handlers have been set up.
+ constructViewer();
+
+#if defined(LL_BUGSPLAT)
+ // Engage BugsplatStartupManager *before* calling initViewer() to handle
+ // any crashes during initialization.
+ // https://www.bugsplat.com/docs/platforms/os-x#initialization
+ [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES;
+ [BugsplatStartupManager sharedManager].askUserDetails = NO;
+ [BugsplatStartupManager sharedManager].delegate = self;
+ [[BugsplatStartupManager sharedManager] start];
+#endif
+
frameTimer = nil;
[self languageUpdated];
@@ -71,14 +90,6 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil];
// [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
-
-#if defined(LL_BUGSPLAT)
- // https://www.bugsplat.com/docs/platforms/os-x#initialization
- [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES;
- [BugsplatStartupManager sharedManager].askUserDetails = NO;
- [BugsplatStartupManager sharedManager].delegate = self;
- [[BugsplatStartupManager sharedManager] start];
-#endif
}
- (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
@@ -198,11 +209,29 @@
- (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager
{
- std::string fatalMessage(CrashMetadata_instance().fatalMessage);
- infos("applicationLogForBugsplatStartupManager -> '" + fatalMessage + "'");
- // This strangely-named override method contributes the User Description
- // metadata field.
- return [NSString stringWithCString:fatalMessage.c_str()
+ CrashMetadata& meta(CrashMetadata_instance());
+ // As of BugsplatMac 1.0.6, userName and userEmail properties are now
+ // exposed by the BugsplatStartupManager. Set them here, since the
+ // defaultUserNameForBugsplatStartupManager and
+ // defaultUserEmailForBugsplatStartupManager methods are called later, for
+ // the *current* run, rather than for the previous crashed run whose crash
+ // report we are about to send.
+ infos("applicationLogForBugsplatStartupManager setting userName = '" +
+ meta.agentFullname + '"');
+ bugsplatStartupManager.userName =
+ [NSString stringWithCString:meta.agentFullname.c_str()
+ encoding:NSUTF8StringEncoding];
+ // Use the email field for OS version, just as we do on Windows, until
+ // BugSplat provides more metadata fields.
+ infos("applicationLogForBugsplatStartupManager setting userEmail = '" +
+ meta.OSInfo + '"');
+ bugsplatStartupManager.userEmail =
+ [NSString stringWithCString:meta.OSInfo.c_str()
+ encoding:NSUTF8StringEncoding];
+ // This strangely-named override method's return value contributes the
+ // User Description metadata field.
+ infos("applicationLogForBugsplatStartupManager -> '" + meta.fatalMessage + "'");
+ return [NSString stringWithCString:meta.fatalMessage.c_str()
encoding:NSUTF8StringEncoding];
}