Skip to content

Commit

Permalink
Merge pull request #1116 from bugsnag/release-v6.9.5
Browse files Browse the repository at this point in the history
Release v6.9.5
  • Loading branch information
nickdowell authored Jun 9, 2021
2 parents ede9f5b + ea6bf16 commit ca5cdd3
Show file tree
Hide file tree
Showing 93 changed files with 272 additions and 347 deletions.
12 changes: 6 additions & 6 deletions .buildkite/pipeline.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -42,7 +42,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -69,7 +69,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -96,7 +96,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand Down Expand Up @@ -125,7 +125,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand Down Expand Up @@ -153,7 +153,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/pipeline.quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -170,7 +170,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -197,7 +197,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -223,7 +223,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ steps:
agents:
queue: opensource-mac-cocoa-11
artifact_paths:
- features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa
- features/fixtures/ios/output/iOSTestApp.ipa
- features/fixtures/macos/output/macOSTestApp.zip
commands:
- ./features/scripts/export_ios_app.sh
Expand Down Expand Up @@ -126,7 +126,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand All @@ -153,7 +153,7 @@ steps:
queue: opensource
plugins:
artifacts#v1.3.0:
download: ["features/fixtures/ios-swift-cocoapods/output/iOSTestApp.ipa"]
download: ["features/fixtures/ios/output/iOSTestApp.ipa"]
docker-compose#v3.3.0:
run: cocoa-maze-runner
command:
Expand Down
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ author_url: "https://www.bugsnag.com"
author: "Bugsnag Inc"
clean: false # avoid deleting docs/.git
framework_root: "Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.9.4/Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.9.5/Bugsnag"
github_url: "https://github.com/bugsnag/bugsnag-cocoa"
hide_documentation_coverage: true
module: "Bugsnag"
module_version: "6.9.4"
module_version: "6.9.5"
objc: true
output: "docs"
readme: "README.md"
Expand Down
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.9.4",
"version": "6.9.5",
"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.9.4"
"tag": "v6.9.5"
},
"frameworks": [
"Foundation",
Expand Down
4 changes: 2 additions & 2 deletions Bugsnag/BugsnagSessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ - (void)handleAppBackgroundEvent {
}

- (void)handleAppForegroundEvent {
if (self.backgroundStartTime
&& [[NSDate date] timeIntervalSinceDate:self.backgroundStartTime] >= BSGNewSessionBackgroundDuration) {
if (!self.currentSession ||
(self.backgroundStartTime && [[NSDate date] timeIntervalSinceDate:self.backgroundStartTime] >= BSGNewSessionBackgroundDuration)) {
[self startNewSessionIfAutoCaptureEnabled];
}
self.backgroundStartTime = nil;
Expand Down
16 changes: 7 additions & 9 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,15 @@ - (void)start {

self.started = YES;

[self.sessionTracker startNewSessionIfAutoCaptureEnabled];
if (bsg_kscrashstate_currentState()->applicationIsInForeground) {
[self.sessionTracker startNewSessionIfAutoCaptureEnabled];
} else {
bsg_log_debug(@"Not starting session because app is not in the foreground");
}

// Record a "Bugsnag Loaded" message
[self addAutoBreadcrumbOfType:BSGBreadcrumbTypeState withMessage:@"Bugsnag loaded" andMetadata:nil];

// notification not received in time on initial startup, so trigger manually
[self willEnterForeground:self];
[self.pluginClient loadPlugins];

if (self.configuration.launchDurationMillis > 0) {
Expand Down Expand Up @@ -993,12 +995,8 @@ - (void)batteryChanged:(__attribute__((unused)) NSNotification *)notification {
BOOL charging = [UIDEVICE currentDevice].batteryState == UIDeviceBatteryStateCharging ||
[UIDEVICE currentDevice].batteryState == UIDeviceBatteryStateFull;

[self.state addMetadata:batteryLevel
withKey:BSGKeyBatteryLevel
toSection:BSGKeyDeviceState];

[self.state addMetadata:charging ? @YES : @NO
withKey:BSGKeyCharging
[self.state addMetadata:@{BSGKeyBatteryLevel: batteryLevel,
BSGKeyCharging: charging ? @YES : @NO}
toSection:BSGKeyDeviceState];
}

Expand Down
29 changes: 2 additions & 27 deletions Bugsnag/Helpers/BSGAppHangDetector.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import <Bugsnag/BugsnagConfiguration.h>
#import <Bugsnag/BugsnagErrorTypes.h>

#import "BSG_KSCrashState.h"
#import "BSG_KSMach.h"
#import "BugsnagCollections.h"
#import "BugsnagLogger.h"
Expand All @@ -26,36 +27,11 @@ @interface BSGAppHangDetector ()

@property (nonatomic) CFRunLoopObserverRef observer;

@property (nonatomic) BOOL isInBackground;

@end


@implementation BSGAppHangDetector

#if TARGET_OS_IOS

- (instancetype)init {
if ((self = [super init])) {
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground)
name:UIApplicationDidEnterBackgroundNotification object:nil];

[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationWillEnterForeground)
name:UIApplicationWillEnterForegroundNotification object:nil];
}
return self;
}

- (void)applicationDidEnterBackground {
self.isInBackground = YES;
}

- (void)applicationWillEnterForeground {
self.isInBackground = NO;
}

#endif

- (void)dealloc {
if (_observer) {
CFRunLoopRemoveObserver(CFRunLoopGetMain(), _observer, kCFRunLoopCommonModes);
Expand Down Expand Up @@ -89,7 +65,6 @@ - (void)startWithDelegate:(id<BSGAppHangDetectorDelegate>)delegate {
dispatch_queue_t backgroundQueue;
__block dispatch_semaphore_t semaphore;
__weak typeof(delegate) weakDelegate = delegate;
__weak typeof(self) weakSelf = self;

backgroundQueue = dispatch_queue_create("com.bugsnag.app-hang-detector", DISPATCH_QUEUE_SERIAL);

Expand All @@ -107,7 +82,7 @@ - (void)startWithDelegate:(id<BSGAppHangDetectorDelegate>)delegate {
dispatch_time_t timeout = dispatch_time(now, (int64_t)(threshold * NSEC_PER_SEC));
dispatch_after(after, backgroundQueue, ^{
if (dispatch_semaphore_wait(semaphore, timeout) != 0) {
if (weakSelf.isInBackground) {
if (!bsg_kscrashstate_currentState()->applicationIsInForeground) {
bsg_log_debug(@"Ignoring app hang because app is in the background");
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
return;
Expand Down
9 changes: 5 additions & 4 deletions Bugsnag/Helpers/BugsnagKVStore.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void bsgkv_open(const char* path, int* err) {

g_currentDirFD = dirfd(g_currentDir);
if(g_currentDirFD < 0) {
closedir(g_currentDir);
g_currentDir = NULL;
*err = errno;
return;
}
Expand All @@ -63,13 +65,12 @@ void bsgkv_open(const char* path, int* err) {
}

void bsgkv_close(void) {
if(g_currentDirFD != 0) {
close(g_currentDirFD);
g_currentDirFD = 0;
}
if(g_currentDir != NULL) {
closedir(g_currentDir);
g_currentDir = NULL;
// Note: closedir() closes the underlying file descriptor.
// Attempting to close it again is a programming error.
g_currentDirFD = 0;
}
}

Expand Down
13 changes: 4 additions & 9 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@

@interface BSG_KSCrash ()

@property(nonatomic, readwrite, retain) NSString *bundleName;
@property(nonatomic, readwrite, retain) NSString *nextCrashID;

// Mirrored from BSG_KSCrashAdvanced.h to provide ivars
Expand All @@ -82,7 +81,6 @@ @implementation BSG_KSCrash
@synthesize userInfo = _userInfo;
@synthesize printTraceToStdout = _printTraceToStdout;
@synthesize onCrash = _onCrash;
@synthesize bundleName = _bundleName;
@synthesize logFilePath = _logFilePath;
@synthesize nextCrashID = _nextCrashID;
@synthesize introspectMemory = _introspectMemory;
Expand All @@ -105,7 +103,6 @@ + (BSG_KSCrash *)sharedInstance {

- (instancetype)init {
if ((self = [super init])) {
self.bundleName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"];
self.nextCrashID = [NSUUID UUID].UUIDString;
self.introspectMemory = YES;
self.maxStoredReports = 5;
Expand Down Expand Up @@ -162,11 +159,13 @@ - (void)setThreadTracingEnabled:(BOOL)threadTracingEnabled {
}

- (BSG_KSCrashType)install:(BSG_KSCrashType)crashTypes directory:(NSString *)directory {
bsg_kscrash_generate_report_initialize(directory.fileSystemRepresentation, self.bundleName.UTF8String);
bsg_kscrash_generate_report_initialize(directory.fileSystemRepresentation);
char *crashReportPath = bsg_kscrash_generate_report_path(self.nextCrashID.UTF8String, false);
char *recrashReportPath = bsg_kscrash_generate_report_path(self.nextCrashID.UTF8String, true);
NSString *stateFilePrefix = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"]
/* Not all processes have an Info.plist */ ?: NSProcessInfo.processInfo.processName;
NSString *stateFilePath = [directory stringByAppendingPathComponent:
[self.bundleName stringByAppendingString:@BSG_kCrashStateFilenameSuffix]];
[stateFilePrefix stringByAppendingString:@BSG_kCrashStateFilenameSuffix]];

bsg_kscrash_setHandlingCrashTypes(crashTypes);

Expand All @@ -177,10 +176,6 @@ - (BSG_KSCrashType)install:(BSG_KSCrashType)crashTypes directory:(NSString *)dir
free(crashReportPath);
free(recrashReportPath);

if (!installedCrashTypes) {
return 0;
}

NSNotificationCenter *nCenter = [NSNotificationCenter defaultCenter];
#if BSG_HAS_UIKIT
[nCenter addObserver:self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern "C" {
#endif

void bsg_kscrash_generate_report_initialize(const char *directory, const char *bundleName);
void bsg_kscrash_generate_report_initialize(const char *directory);

/**
* Generates a new UUID. Not async signal safe. Caller responsible for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include <string.h>

static char *report_directory;
static char *bundle_name;

void bsg_kscrash_generate_report_initialize(const char *directory, const char *bundleName) {
void bsg_kscrash_generate_report_initialize(const char *directory) {
report_directory = directory ? strdup(directory) : NULL;
bundle_name = bundleName ? strdup(bundleName) : NULL;
}

char *bsg_kscrash_generate_report_identifier(void) {
Expand All @@ -25,6 +23,6 @@ void bsg_kscrash_generate_report_initialize(const char *directory, const char *b
}
char *type = is_recrash_report ? "RecrashReport" : "CrashReport";
char *path = NULL;
asprintf(&path, "%s/%s-%s-%s.json", report_directory, bundle_name, type, identifier);
asprintf(&path, "%s/%s-%s.json", report_directory, type, identifier);
return path;
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ int bsg_ksjsoncodec_i_appendEscapedString(
// see https://www.ietf.org/rfc/rfc4627.txt

if ((unsigned char)*src < ' ') {
unsigned int last = *src % 16;
unsigned int last = (unsigned int)*src % 16;
unsigned int first = ((unsigned int)*src - last) / 16;

*dst++ = '\\';
Expand Down
2 changes: 1 addition & 1 deletion Bugsnag/Payload/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (instancetype)init {
#else
self.name = @"Bugsnag Objective-C";
#endif
self.version = @"6.9.4";
self.version = @"6.9.5";
self.url = @"https://github.com/bugsnag/bugsnag-cocoa";
self.dependencies = [NSMutableArray new];
}
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Changelog
=========

## 6.9.5 (2021-06-09)

### Bug fixes

* Stop app hangs being reported if app is launched in the background.
[#1112](https://github.com/bugsnag/bugsnag-cocoa/pull/1112)

* Stop session being reported if app is launched in the background.
[#1107](https://github.com/bugsnag/bugsnag-cocoa/pull/1107)

* Fix KSCrash state storage for apps with no CFBundleName.
[#1103](https://github.com/bugsnag/bugsnag-cocoa/pull/1103)

## 6.9.4 (2021-06-02)

### Bug fixes
Expand Down
Loading

0 comments on commit ca5cdd3

Please sign in to comment.