Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(react-native): Update bugsnag-cocoa to v6.8.1 #1345

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## TBD

### Changed

- (react-native): Update bugsnag-cocoa to v6.8.1
- Fix unreliable ordering of breadcrumbs. [bugsnag-cocoa#1049](https://github.com/bugsnag/bugsnag-cocoa/pull/1049)

## v7.9.1 (2021-03-25)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ios/.bugsnag-cocoa-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3196f905d5933b4a90678ca9fd755616ea89dc84
c6f2433cffe2bfaf70cffa106f624d88953700b8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.8.0",
"version": "6.8.1",
"summary": "The Bugsnag crash reporting framework for Apple platforms.",
"homepage": "https://bugsnag.com",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.8.0"
"tag": "v6.8.1"
},
"frameworks": [
"Foundation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@
010FF28825ED2A8D00E4F2B0 /* BSGAppHangDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = 010FF28325ED2A8D00E4F2B0 /* BSGAppHangDetector.m */; };
010FF28925ED2A8D00E4F2B0 /* BSGAppHangDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = 010FF28325ED2A8D00E4F2B0 /* BSGAppHangDetector.m */; };
010FF28A25ED2A8D00E4F2B0 /* BSGAppHangDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = 010FF28325ED2A8D00E4F2B0 /* BSGAppHangDetector.m */; };
011ADCE326049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 011ADCE126049A3600B20D72 /* BugsnagClient+OutOfMemory.h */; };
011ADCE426049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 011ADCE126049A3600B20D72 /* BugsnagClient+OutOfMemory.h */; };
011ADCE526049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 011ADCE126049A3600B20D72 /* BugsnagClient+OutOfMemory.h */; };
011ADCE626049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */ = {isa = PBXBuildFile; fileRef = 011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */; };
011ADCE726049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */ = {isa = PBXBuildFile; fileRef = 011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */; };
011ADCE826049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */ = {isa = PBXBuildFile; fileRef = 011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */; };
011ADCE926049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */ = {isa = PBXBuildFile; fileRef = 011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */; };
01210B8825CD665000D683BB /* BugsnagThread+Recording.m in Sources */ = {isa = PBXBuildFile; fileRef = 01210B8725CD665000D683BB /* BugsnagThread+Recording.m */; };
01210B8925CD665000D683BB /* BugsnagThread+Recording.m in Sources */ = {isa = PBXBuildFile; fileRef = 01210B8725CD665000D683BB /* BugsnagThread+Recording.m */; };
01210B8A25CD665000D683BB /* BugsnagThread+Recording.m in Sources */ = {isa = PBXBuildFile; fileRef = 01210B8725CD665000D683BB /* BugsnagThread+Recording.m */; };
Expand Down Expand Up @@ -1291,6 +1298,8 @@
00E636C324878FFC006CBF1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
010FF28225ED2A8D00E4F2B0 /* BSGAppHangDetector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGAppHangDetector.h; sourceTree = "<group>"; };
010FF28325ED2A8D00E4F2B0 /* BSGAppHangDetector.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGAppHangDetector.m; sourceTree = "<group>"; };
011ADCE126049A3600B20D72 /* BugsnagClient+OutOfMemory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagClient+OutOfMemory.h"; sourceTree = "<group>"; };
011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "BugsnagClient+OutOfMemory.m"; sourceTree = "<group>"; };
01210B7C25CD661800D683BB /* BugsnagThread+Recording.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagThread+Recording.h"; sourceTree = "<group>"; };
01210B8725CD665000D683BB /* BugsnagThread+Recording.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "BugsnagThread+Recording.m"; sourceTree = "<group>"; };
012482A225627B51003F7243 /* UIKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIKitTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1786,6 +1795,8 @@
008967BB2486DA1900DC48C2 /* BugsnagClient.m */,
0127149025F6171000D3500A /* BugsnagClient+AppHangs.h */,
0127149125F6171000D3500A /* BugsnagClient+AppHangs.m */,
011ADCE126049A3600B20D72 /* BugsnagClient+OutOfMemory.h */,
011ADCE226049A3600B20D72 /* BugsnagClient+OutOfMemory.m */,
008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */,
);
path = Client;
Expand Down Expand Up @@ -2042,6 +2053,7 @@
0126F7BB25DD512B008483C2 /* BSGEventUploadKSCrashReportOperation.h in Headers */,
008968DE2486DAA700DC48C2 /* BugsnagPluginClient.h in Headers */,
008969EA2486DAD100DC48C2 /* BSG_KSCrashReport.h in Headers */,
011ADCE326049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */,
008969F02486DAD100DC48C2 /* BSG_KSCrashReportFields.h in Headers */,
00896A2F2486DAD100DC48C2 /* BSG_KSCrashIdentifier.h in Headers */,
008969FC2486DAD100DC48C2 /* BSG_KSCrashAdvanced.h in Headers */,
Expand Down Expand Up @@ -2145,6 +2157,7 @@
0126F7BC25DD512B008483C2 /* BSGEventUploadKSCrashReportOperation.h in Headers */,
008968DF2486DAA700DC48C2 /* BugsnagPluginClient.h in Headers */,
008969EB2486DAD100DC48C2 /* BSG_KSCrashReport.h in Headers */,
011ADCE426049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */,
008969F12486DAD100DC48C2 /* BSG_KSCrashReportFields.h in Headers */,
00896A302486DAD100DC48C2 /* BSG_KSCrashIdentifier.h in Headers */,
008969FD2486DAD100DC48C2 /* BSG_KSCrashAdvanced.h in Headers */,
Expand Down Expand Up @@ -2248,6 +2261,7 @@
0126F7BD25DD512B008483C2 /* BSGEventUploadKSCrashReportOperation.h in Headers */,
008968E02486DAA700DC48C2 /* BugsnagPluginClient.h in Headers */,
008969EC2486DAD100DC48C2 /* BSG_KSCrashReport.h in Headers */,
011ADCE526049A3600B20D72 /* BugsnagClient+OutOfMemory.h in Headers */,
008969F22486DAD100DC48C2 /* BSG_KSCrashReportFields.h in Headers */,
00896A312486DAD100DC48C2 /* BSG_KSCrashIdentifier.h in Headers */,
008969FE2486DAD100DC48C2 /* BSG_KSCrashAdvanced.h in Headers */,
Expand Down Expand Up @@ -2620,6 +2634,7 @@
008969C02486DAD100DC48C2 /* BSG_KSString.c in Sources */,
0126F79E25DD510E008483C2 /* BSGEventUploadObjectOperation.m in Sources */,
0089682B2486DA5600DC48C2 /* BSGSerialization.m in Sources */,
011ADCE626049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */,
008968E92486DAB800DC48C2 /* BugsnagSessionFileStore.m in Sources */,
00896A172486DAD100DC48C2 /* BSG_KSCrashSentry_CPPException.mm in Sources */,
008969CF2486DAD100DC48C2 /* BSG_KSCrashState.m in Sources */,
Expand Down Expand Up @@ -2790,6 +2805,7 @@
008969C12486DAD100DC48C2 /* BSG_KSString.c in Sources */,
0126F79F25DD510E008483C2 /* BSGEventUploadObjectOperation.m in Sources */,
0089682C2486DA5600DC48C2 /* BSGSerialization.m in Sources */,
011ADCE726049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */,
008968EA2486DAB800DC48C2 /* BugsnagSessionFileStore.m in Sources */,
00896A182486DAD100DC48C2 /* BSG_KSCrashSentry_CPPException.mm in Sources */,
008969D02486DAD100DC48C2 /* BSG_KSCrashState.m in Sources */,
Expand Down Expand Up @@ -2958,6 +2974,7 @@
008969C22486DAD100DC48C2 /* BSG_KSString.c in Sources */,
0126F7A025DD510E008483C2 /* BSGEventUploadObjectOperation.m in Sources */,
0089682D2486DA5600DC48C2 /* BSGSerialization.m in Sources */,
011ADCE826049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */,
008968EB2486DAB800DC48C2 /* BugsnagSessionFileStore.m in Sources */,
00896A192486DAD100DC48C2 /* BSG_KSCrashSentry_CPPException.mm in Sources */,
008969D12486DAD100DC48C2 /* BSG_KSCrashState.m in Sources */,
Expand Down Expand Up @@ -3085,6 +3102,7 @@
E7462911248907E500F92D67 /* BSG_KSSysCtl.c in Sources */,
E7462912248907E500F92D67 /* BSG_KSMach_x86_64.c in Sources */,
CBCF77A925010648004AF22A /* BSGJSONSerialization.m in Sources */,
011ADCE926049A3600B20D72 /* BugsnagClient+OutOfMemory.m in Sources */,
E7462913248907E500F92D67 /* BSG_KSSignalInfo.c in Sources */,
E7462914248907E500F92D67 /* BSG_KSString.c in Sources */,
E7462915248907E500F92D67 /* BSG_KSObjC.c in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,29 @@ - (nullable NSArray *)loadBreadcrumbsAsDictionaries:(BOOL)asDictionaries {
return nil;
}

// We cannot use NSString's -localizedStandardCompare: because its sorting may vary by locale.
filenames = [filenames sortedArrayUsingComparator:^NSComparisonResult(NSString *name1, NSString *name2) {
long long value1 = [[name1 stringByDeletingPathExtension] longLongValue];
long long value2 = [[name2 stringByDeletingPathExtension] longLongValue];
if (value1 < value2) { return NSOrderedAscending; }
if (value1 > value2) { return NSOrderedDescending; }
return NSOrderedSame;
}];

NSMutableArray<NSDictionary *> *breadcrumbs = [NSMutableArray array];

for (NSString *file in [filenames sortedArrayUsingSelector:@selector(compare:)]) {
for (NSString *file in filenames) {
if ([file hasPrefix:@"."] || ![file.pathExtension isEqual:@"json"]) {
// Ignore partially written files, which have names like ".dat.nosync43c9.RZFc3z"
continue;
}
NSString *path = [self.breadcrumbsPath stringByAppendingPathComponent:file];
NSData *data = [NSData dataWithContentsOfFile:path];
NSData *data = [NSData dataWithContentsOfFile:path options:0 error:&error];
if (!data) {
bsg_log_err(@"Unable to read breadcrumb from %@", path);
// If a high volume of breadcrumbs is being logged, it is normal for older files to be deleted before this thread can read them.
if (!(error.domain == NSCocoaErrorDomain && error.code == NSFileReadNoSuchFileError)) {
bsg_log_err(@"Unable to read breadcrumb: %@", error);
}
continue;
}
id JSONObject = [BSGJSONSerialization JSONObjectWithData:data options:0 error:&error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface BugsnagClient (AppHangs) <BSGAppHangDetectorDelegate>

- (BOOL)lastRunEndedWithAppHang;
/// @Returns A `BugsnagEvent` if the last run ended with a fatal app hang, `nil` otherwise.
- (nullable BugsnagEvent *)loadFatalAppHangEvent;

- (void)startAppHangDetector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ - (void)appHangEnded {
self.appHangEvent = nil;
}

- (BOOL)lastRunEndedWithAppHang {
- (nullable BugsnagEvent *)loadFatalAppHangEvent {
NSError *error = nil;
NSDictionary *json = [BSGJSONSerialization JSONObjectWithContentsOfFile:BSGFileLocations.current.appHangEvent options:0 error:&error];
if (!json) {
if (!(error.domain == NSCocoaErrorDomain && error.code == NSFileReadNoSuchFileError)) {
bsg_log_err(@"Could not read app_hang.json: %@", error);
}
return NO;
return nil;
}

BugsnagEvent *event = [[BugsnagEvent alloc] initWithJson:json];
if (!event) {
bsg_log_err(@"Could not parse app_hang.json");
return NO;
return nil;
}

// Update event to reflect that the app hang was fatal.
Expand All @@ -106,8 +106,7 @@ - (BOOL)lastRunEndedWithAppHang {
attrValue:nil];
event.session.unhandledCount++;

self.appHangEvent = event;
return YES;
return event;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// BugsnagClient+OutOfMemory.h
// Bugsnag
//
// Created by Nick Dowell on 19/03/2021.
// Copyright © 2021 Bugsnag Inc. All rights reserved.
//

#import <Bugsnag/Bugsnag.h>

@class BugsnagEvent;

NS_ASSUME_NONNULL_BEGIN

@interface BugsnagClient (OutOfMemory)

- (BugsnagEvent *)generateOutOfMemoryEvent;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// BugsnagClient+OutOfMemory.m
// Bugsnag
//
// Created by Nick Dowell on 19/03/2021.
// Copyright © 2021 Bugsnag Inc. All rights reserved.
//

#import "BugsnagClient+OutOfMemory.h"

#import "BugsnagAppWithState+Private.h"
#import "BugsnagBreadcrumbs.h"
#import "BugsnagClient+Private.h"
#import "BugsnagDeviceWithState+Private.h"
#import "BugsnagError+Private.h"
#import "BugsnagEvent+Private.h"
#import "BugsnagHandledState.h"
#import "BugsnagKeys.h"
#import "BugsnagSession+Private.h"
#import "BugsnagSystemState.h"

@implementation BugsnagClient (OutOfMemory)

- (BugsnagEvent *)generateOutOfMemoryEvent {
NSDictionary *appDict = self.systemState.lastLaunchState[SYSTEMSTATE_KEY_APP];
BugsnagAppWithState *app = [BugsnagAppWithState appFromJson:appDict];
app.dsymUuid = appDict[BSGKeyMachoUUID];
app.isLaunching = [self.stateMetadataFromLastLaunch[BSGKeyApp][BSGKeyIsLaunching] boolValue];

NSDictionary *deviceDict = self.systemState.lastLaunchState[SYSTEMSTATE_KEY_DEVICE];
BugsnagDeviceWithState *device = [BugsnagDeviceWithState deviceFromJson:deviceDict];
device.manufacturer = @"Apple";
device.orientation = self.stateMetadataFromLastLaunch[BSGKeyDeviceState][BSGKeyOrientation];

BugsnagMetadata *metadata = [[BugsnagMetadata alloc] initWithDictionary:self.metadataFromLastLaunch ?: @{}];
[metadata addMetadata:self.stateMetadataFromLastLaunch[BSGKeyDeviceState] toSection:BSGKeyDevice];

NSDictionary *sessionDict = self.systemState.lastLaunchState[BSGKeySession];
BugsnagSession *session = sessionDict ? [[BugsnagSession alloc] initWithDictionary:sessionDict] : nil;
session.unhandledCount += 1;

BugsnagError *error =
[[BugsnagError alloc] initWithErrorClass:@"Out Of Memory"
errorMessage:@"The app was likely terminated by the operating system while in the foreground"
errorType:BSGErrorTypeCocoa
stacktrace:nil];

BugsnagEvent *event =
[[BugsnagEvent alloc] initWithApp:app
device:device
handledState:[BugsnagHandledState handledStateWithSeverityReason:LikelyOutOfMemory]
user:session.user
metadata:metadata
breadcrumbs:self.breadcrumbs.breadcrumbs
errors:@[error]
threads:nil
session:session];

return event;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN

@property (strong, nonatomic) BugsnagCrashSentry *crashSentry;

/// The App hang or OOM event that caused the last launch to crash.
@property (nullable, nonatomic) BugsnagEvent *eventFromLastLaunch;

@property (strong, nonatomic) BSGEventUploader *eventUploader;

@property NSMutableDictionary *extraRuntimeInfo;
Expand Down
Loading