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

Release v6.1.1 #754

Merged
merged 49 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9e26165
perf: improve performance of thread capture
fractalwrench Jun 26, 2020
db287b0
Refactored static thead data
tomlongridge Jun 28, 2020
708fa01
Merge branch 'improve-thread-perf' into tom/remove-static-json-thread…
tomlongridge Jun 28, 2020
03d0e8e
refactor(mach headers): improve encapsulation
tomlongridge Jun 28, 2020
52944fc
refactor(mach headers) Refactored mach images into linked list
tomlongridge Jun 28, 2020
5f43ffe
Made depth an update param in captureThreads
tomlongridge Jun 28, 2020
22c6b07
Merge branch 'master' into improve-thread-perf
tomlongridge Jun 29, 2020
8ee7b05
Merge branch 'improve-thread-perf' into tom/remove-static-json-thread…
tomlongridge Jun 29, 2020
a5dff3b
Changes following review
tomlongridge Jun 29, 2020
6ae9b00
Addressed review comments
tomlongridge Jun 29, 2020
0426674
Merge branch 'master' into tom/improve-mach-headers-encapsulation
tomlongridge Jun 29, 2020
34705b0
Reverted BugsnagThread refactor for another PR
tomlongridge Jun 29, 2020
96c780f
Merge pull request #727 from bugsnag/tom/remove-static-json-thread-data
tomlongridge Jun 30, 2020
8d40f95
Merge branch 'next' into tom/improve-mach-headers-encapsulation
tomlongridge Jun 30, 2020
a72ea48
perf: avoid suspending threads for handled error thread capture
fractalwrench Jun 30, 2020
551da1b
Merge pull request #728 from bugsnag/tom/improve-mach-headers-encapsu…
tomlongridge Jun 30, 2020
ec806b0
Merge branch 'next' into improve-thread-perf
tomlongridge Jun 30, 2020
d951100
Merge pull request #723 from bugsnag/improve-thread-perf
fractalwrench Jun 30, 2020
d88f70b
Reinstated suspend threads at point of tracing
tomlongridge Jun 30, 2020
2d14797
Removed redundant ManyConcurrentNotifyNoBackgroundThreads test
tomlongridge Jul 3, 2020
9fe09b5
fix(kscrash): prevent stack overflow escaping strings to JSON
tomlongridge Jul 3, 2020
0ee179f
Merge pull request #732 from bugsnag/tom/suspend-threads-on-trace-only
tomlongridge Jul 3, 2020
7de6b52
fix(kscrash): disable introspection for handled thread traces
tomlongridge Jul 3, 2020
60aaac1
Merge branch 'next' into tom/fix-escaping-long-json-strings
tomlongridge Jul 3, 2020
d1028d4
Merge pull request #741 from bugsnag/tom/disable-introspection-for-ha…
tomlongridge Jul 3, 2020
094abff
Merge branch 'next' into tom/fix-escaping-long-json-strings
tomlongridge Jul 3, 2020
5da41ac
fix(breadcrumbs): guard read access to breadcrumbs count
tomlongridge Jul 3, 2020
bca55c1
Merge pull request #739 from bugsnag/tom/fix-escaping-long-json-strings
tomlongridge Jul 3, 2020
5446215
Merge branch 'next' into tom/fix-breadcrumb-count-thread-safety
tomlongridge Jul 4, 2020
1700196
Merge branch 'master' into next
tomlongridge Jul 4, 2020
e3d1b72
Merge branch 'next' into tom/fix-breadcrumb-count-thread-safety
tomlongridge Jul 4, 2020
ec747ef
Update changelog
tomlongridge Jul 6, 2020
2408d48
Merge branch 'tom/fix-breadcrumb-count-thread-safety' of github.com:b…
tomlongridge Jul 6, 2020
3302853
test(mach): fix macOS tests
tomlongridge Jul 6, 2020
d0dba98
move config.breadcrumbs to client
tomlongridge Jul 6, 2020
f69d200
Merge pull request #745 from bugsnag/tom/fix-mach-header-mac-test
tomlongridge Jul 7, 2020
cb51758
Amended breadcrumb trimming per feedback
tomlongridge Jul 7, 2020
e6c7822
Merge branch 'next' into tom/fix-breadcrumb-count-thread-safety
tomlongridge Jul 7, 2020
9044a26
Merge pull request #743 from bugsnag/tom/fix-breadcrumb-count-thread-…
tomlongridge Jul 7, 2020
373b915
Updated changelog
tomlongridge Jul 7, 2020
2166228
docs(breadcrumbs): updated outdated docs for BugsnagBreadcrumb.arrayV…
tomlongridge Jul 8, 2020
636e985
Merge pull request #748 from bugsnag/tom/update-bugsnagbreadcrumbs-ar…
tomlongridge Jul 9, 2020
4491154
Correction to changelog (#725->727)
tomlongridge Jul 10, 2020
808b8bc
fix(breadcrumbs): reinstate dispatch barrier guard
tomlongridge Jul 10, 2020
2e52665
Merge pull request #752 from bugsnag/tom/reinstate-guard-breadcrumbs-…
fractalwrench Jul 13, 2020
3a4d5bb
fix(breadcrumbs): further refactor of count into barrier guard
tomlongridge Jul 14, 2020
b85e5ef
Merge pull request #753 from bugsnag/tom/reinstate-guard-breadcrumbs-…
tomlongridge Jul 14, 2020
e11f163
Merge branch 'master' into next
tomlongridge Jul 15, 2020
43d33eb
Release v6.1.1
tomlongridge Jul 15, 2020
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
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.1.0",
"version": "6.1.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.1.0"
"tag": "v6.1.1"
},
"frameworks": [
"Foundation",
Expand Down
19 changes: 2 additions & 17 deletions Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);

- (instancetype _Nonnull)initWithConfiguration:(BugsnagConfiguration *_Nonnull)config;

/**
* The maximum number of breadcrumbs. Resizable.
*/
@property(assign, readwrite) NSUInteger capacity;

/** Number of breadcrumbs accumulated */
@property(assign, readonly) NSUInteger count;

/**
* Path where breadcrumbs are persisted on disk
*/
Expand All @@ -43,17 +35,10 @@ typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);
- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;

/** Breadcrumb object for a particular index or nil */
- (BugsnagBreadcrumb *_Nullable)objectAtIndexedSubscript:(NSUInteger)index;

/**
* Serializable array representation of breadcrumbs, represented as nested
* strings in the format:
* [[timestamp,message]...]
*
* returns nil if empty
* Generates an array of dictionaries representing the current buffer of breadcrumbs.
*/
- (NSArray *_Nullable)arrayValue;
- (NSArray *_Nonnull)arrayValue;

/**
* The types of breadcrumbs which will be automatically captured.
Expand Down
90 changes: 21 additions & 69 deletions Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ @interface BugsnagBreadcrumbs ()

@implementation BugsnagBreadcrumbs

NSUInteger BreadcrumbsDefaultCapacity = 25;

- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config {
static NSString *const BSGBreadcrumbCacheFileName = @"bugsnag_breadcrumbs.json";
if (self = [super init]) {
_config = config;
_breadcrumbs = [NSMutableArray new];
_capacity = BreadcrumbsDefaultCapacity;
_enabledBreadcrumbTypes = BSGEnabledBreadcrumbTypeAll;
_breadcrumbs = [NSMutableArray arrayWithCapacity:config.maxBreadcrumbs];
_readWriteQueue = dispatch_queue_create("com.bugsnag.BreadcrumbRead",
DISPATCH_QUEUE_SERIAL);
NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(
Expand All @@ -59,14 +55,17 @@ - (void)addBreadcrumb:(NSString *)breadcrumbMessage {

- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block {
if (self.capacity == 0) {
if (self.config.maxBreadcrumbs == 0) {
return;
}
BugsnagBreadcrumb *crumb = [BugsnagBreadcrumb breadcrumbWithBlock:block];

if (crumb != nil && [self shouldSendBreadcrumb:crumb]) {
[self resizeToFitCapacity:self.capacity - 1];
dispatch_barrier_sync(self.readWriteQueue, ^{
if ((self.breadcrumbs.count > 0) &&
(self.breadcrumbs.count == self.config.maxBreadcrumbs)) {
[self.breadcrumbs removeObjectAtIndex:0];
}
[self.breadcrumbs addObject:crumb];
// Serialize crumbs to disk inside barrier to avoid simultaneous
// access to the file
Expand Down Expand Up @@ -116,73 +115,26 @@ - (NSArray *)cachedBreadcrumbs {
return [cache isKindOfClass:[NSArray class]] ? cache : nil;
}

@synthesize capacity = _capacity;

- (NSUInteger)capacity {
@synchronized (self) {
return _capacity;
}
}

- (void)setCapacity:(NSUInteger)capacity {
@synchronized (self) {
if (capacity == _capacity) {
return;
}
[self resizeToFitCapacity:capacity];
[self willChangeValueForKey:NSStringFromSelector(@selector(capacity))];
_capacity = MIN(100, capacity);
[self didChangeValueForKey:NSStringFromSelector(@selector(capacity))];
}
}

- (NSUInteger)count {
return self.breadcrumbs.count;
}

- (BugsnagBreadcrumb *)objectAtIndexedSubscript:(NSUInteger)index {
if (index < [self count]) {
__block BugsnagBreadcrumb *crumb = nil;
dispatch_barrier_sync(self.readWriteQueue, ^{
crumb = self.breadcrumbs[index];
});
return crumb;
}
return nil;
}

- (NSArray *)arrayValue {
if ([self count] == 0) {
return nil;
}
__block NSMutableArray *contents =
[[NSMutableArray alloc] initWithCapacity:[self count]];
__block NSMutableArray *contents;
dispatch_barrier_sync(self.readWriteQueue, ^{
for (BugsnagBreadcrumb *crumb in self.breadcrumbs) {
NSDictionary *objectValue = [crumb objectValue];
NSError *error = nil;
@try {
if (![NSJSONSerialization isValidJSONObject:objectValue]) {
bsg_log_err(@"Unable to serialize breadcrumb: Not a valid "
@"JSON object");
continue;
}
[contents addObject:objectValue];
} @catch (NSException *exception) {
contents = [[NSMutableArray alloc] initWithCapacity:self.breadcrumbs.count];
for (BugsnagBreadcrumb *crumb in self.breadcrumbs) {
NSDictionary *objectValue = [crumb objectValue];
NSError *error = nil;
@try {
if (![NSJSONSerialization isValidJSONObject:objectValue]) {
bsg_log_err(@"Unable to serialize breadcrumb: Not a valid "
@"JSON object");
continue;
}
[contents addObject:objectValue];
} @catch (NSException *exception) {
bsg_log_err(@"Unable to serialize breadcrumb: %@", error);
}
}
}
}
});
return contents;
}

- (void)resizeToFitCapacity:(NSUInteger)capacity {
if ([self count] > capacity) {
dispatch_barrier_sync(self.readWriteQueue, ^{
[self.breadcrumbs
removeObjectsInRange:NSMakeRange(0, self.count - capacity)];
});
}
}

@end
3 changes: 1 addition & 2 deletions Bugsnag/BugsnagCrashSentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ - (void)reportUserException:(NSString *)reportName
callbackOverrides:overrides
eventOverrides:eventOverrides
metadata:metadata
config:config
terminateProgram:NO];
config:config];
}

@end
16 changes: 8 additions & 8 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ @interface BugsnagClient ()
@property (nonatomic, strong) BugsnagPluginClient *pluginClient;
@property (nonatomic) BOOL appDidCrashLastLaunch;
@property (nonatomic, strong) BugsnagMetadata *metadata;
@property(nonatomic, strong) BugsnagBreadcrumbs *breadcrumbs;
@property (nonatomic) NSString *codeBundleId;
@property(nonatomic, readwrite, strong) NSMutableArray *stateEventBlocks;
#if BSG_PLATFORM_IOS
Expand All @@ -312,7 +313,6 @@ @interface BugsnagConfiguration ()
@property(readonly, retain, nullable) NSURL *notifyURL;
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
@property(readwrite, retain, nullable) BugsnagMetadata *config;
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
- (BOOL)shouldRecordBreadcrumbType:(BSGBreadcrumbType)type;
@end

Expand Down Expand Up @@ -413,6 +413,8 @@ - (id)initWithConfiguration:(BugsnagConfiguration *)initConfiguration {
BSGWriteSessionCrashData(session);
}];

self.breadcrumbs = [[BugsnagBreadcrumbs alloc] initWithConfiguration:self.configuration];

// Start with a copy of the configuration metadata
self.metadata = [[configuration metadata] deepCopy];
// sync initial state
Expand Down Expand Up @@ -919,7 +921,7 @@ - (void)notifyOutOfMemoryEvent {
static NSString *const BSGOutOfMemoryErrorClass = @"Out Of Memory";
static NSString *const BSGOutOfMemoryMessageFormat = @"The app was likely terminated by the operating system while in the %@";
NSMutableDictionary *lastLaunchInfo = [[self.oomWatchdog lastBootCachedFileInfo] mutableCopy];
NSArray *crumbs = [self.configuration.breadcrumbs cachedBreadcrumbs];
NSArray *crumbs = [self.breadcrumbs cachedBreadcrumbs];
if (crumbs.count > 0) {
lastLaunchInfo[@"breadcrumbs"] = crumbs;
}
Expand Down Expand Up @@ -990,7 +992,7 @@ - (void)notify:(NSException *)exception
handledState:handledState
user:self.user
metadata:metadata
breadcrumbs:[NSArray arrayWithArray:self.configuration.breadcrumbs.breadcrumbs]
breadcrumbs:[NSArray arrayWithArray:self.breadcrumbs.breadcrumbs]
errors:errors
threads:threads
session:self.sessionTracker.runningSession];
Expand Down Expand Up @@ -1086,14 +1088,12 @@ - (BugsnagError *)generateError:(NSException *)exception

- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block {
[self.configuration.breadcrumbs addBreadcrumbWithBlock:block];
[self.breadcrumbs addBreadcrumbWithBlock:block];
[self serializeBreadcrumbs];
}

- (void)serializeBreadcrumbs {
BugsnagBreadcrumbs *crumbs = self.configuration.breadcrumbs;
NSArray *arrayValue = crumbs.count == 0 ? nil : [crumbs arrayValue];
[self.state addMetadata:arrayValue
[self.state addMetadata:[self.breadcrumbs arrayValue]
withKey:BSGKeyBreadcrumbs
toSection:BSTabCrash];
}
Expand Down Expand Up @@ -1548,7 +1548,7 @@ - (NSDictionary *)collectDeviceWithState {
}

- (NSArray *)collectBreadcrumbs {
NSMutableArray *crumbs = self.configuration.breadcrumbs.breadcrumbs;
NSMutableArray *crumbs = self.breadcrumbs.breadcrumbs;
NSMutableArray *data = [NSMutableArray new];

for (BugsnagBreadcrumb *crumb in crumbs) {
Expand Down
40 changes: 24 additions & 16 deletions Bugsnag/Configuration/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ @interface BugsnagConfiguration ()
* Meta-information about the state of Bugsnag
*/
@property(readwrite, retain, nullable) BugsnagMetadata *config;

/**
* Rolling snapshots of user actions leading up to a crash report
*/
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
@end

// =============================================================================
Expand Down Expand Up @@ -122,7 +117,6 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone {
[copy setAutoDetectErrors:self.autoDetectErrors];
[copy setAutoTrackSessions:self.autoTrackSessions];
[copy setBundleVersion:self.bundleVersion];
// Skip breadcrumbs - none should have been set
[copy setConfig:[[BugsnagMetadata alloc] initWithDictionary:[[self.config toDictionary] mutableCopy]]];
[copy setContext:self.context];
[copy setEnabledBreadcrumbTypes:self.enabledBreadcrumbTypes];
Expand Down Expand Up @@ -220,7 +214,8 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
_plugins = [NSMutableSet new];
_enabledReleaseStages = nil;
_redactedKeys = [NSSet setWithArray:@[@"password"]];
_breadcrumbs = [[BugsnagBreadcrumbs alloc] initWithConfiguration:self];
_enabledBreadcrumbTypes = BSGEnabledBreadcrumbTypeAll;
_maxBreadcrumbs = 25;
_autoTrackSessions = YES;
_sendThreads = BSGThreadSendPolicyAlways;
// Default to recording all error types
Expand Down Expand Up @@ -455,16 +450,23 @@ -(void)deletePersistedUserData {
// MARK: - Properties: Getters and Setters
// -----------------------------------------------------------------------------

@synthesize maxBreadcrumbs = _maxBreadcrumbs;

- (NSUInteger)maxBreadcrumbs {
return self.breadcrumbs.capacity;
@synchronized (self) {
return _maxBreadcrumbs;
}
}

- (void)setMaxBreadcrumbs:(NSUInteger)capacity {
if (capacity <= 100) {
self.breadcrumbs.capacity = capacity;
} else {
bsg_log_err(@"Invalid configuration value detected. Option maxBreadcrumbs "
"should be an integer between 0-100. Supplied value is %lu", (unsigned long) capacity);
- (void)setMaxBreadcrumbs:(NSUInteger)maxBreadcrumbs {
@synchronized (self) {
if (maxBreadcrumbs <= 100) {
_maxBreadcrumbs = maxBreadcrumbs;
} else {
bsg_log_err(@"Invalid configuration value detected. Option maxBreadcrumbs "
"should be an integer between 0-100. Supplied value is %lu",
(unsigned long) maxBreadcrumbs);
}
}
}

Expand Down Expand Up @@ -547,12 +549,18 @@ - (void)setEnabledReleaseStages:(NSSet<NSString *> *)newReleaseStages

// MARK: - enabledBreadcrumbTypes

@synthesize enabledBreadcrumbTypes = _enabledBreadcrumbTypes;

- (BSGEnabledBreadcrumbType)enabledBreadcrumbTypes {
return self.breadcrumbs.enabledBreadcrumbTypes;
@synchronized (self) {
return _enabledBreadcrumbTypes;
}
}

- (void)setEnabledBreadcrumbTypes:(BSGEnabledBreadcrumbType)enabledBreadcrumbTypes {
self.breadcrumbs.enabledBreadcrumbTypes = enabledBreadcrumbTypes;
@synchronized (self) {
_enabledBreadcrumbTypes = enabledBreadcrumbTypes;
}
}

// MARK: -
Expand Down
16 changes: 3 additions & 13 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@
* @param eventOverrides the Bugsnag Error Payload, for handled errors only
* @param metadata additional information to attach to the report
* @param config delivery options
* @param terminateProgram If true, do not return from this function call.
* Terminate the program instead.
*/
- (void)reportUserException:(NSString *)name
reason:(NSString *)reason
Expand All @@ -109,8 +107,7 @@
callbackOverrides:(NSDictionary *)overrides
eventOverrides:(NSDictionary *)eventOverrides
metadata:(NSDictionary *)metadata
config:(NSDictionary *)config
terminateProgram:(BOOL)terminateProgram;
config:(NSDictionary *)config;

/**
* Collects a trace of all the threads running in application, if the user has
Expand All @@ -122,22 +119,15 @@
*/
- (NSArray<BugsnagThread *> *)captureThreads:(NSException *)exc depth:(int)depth;

/** If YES, user reported exceptions will suspend all threads during report
* generation. All threads will be suspended while generating a crash report for
* a user reported exception.
*
* Default: YES
*/
@property(nonatomic, readwrite, assign) BOOL suspendThreadsForUserReported;

/** If YES, reports will be sent even if a debugger is attached
*
* Default: NO
*/
@property(nonatomic, readwrite, assign) BOOL reportWhenDebuggerIsAttached;

/**
* If YES, thread traces will be collected with each report.
* The methodology used for tracing threads.
* The value will be equal to an enum value from BSGThreadSendPolicy
*/
@property(nonatomic, readwrite, assign) int threadTracingEnabled;

Expand Down
Loading