Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit d1a2daa

Browse files
committed
build: Update bugsnag-cocoa dep to v5.22.6
1 parent 24c6c70 commit d1a2daa

10 files changed

Lines changed: 138 additions & 13 deletions

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
=========
33

4+
## TBD
5+
6+
### Bug fixes
7+
8+
* (iOS) Upgrade bugsnag-cocoa to v5.22.6
9+
* Ensure UIKit APIs are not called from background threads when
10+
initializing only in the JavaScript layer when using `react-native@0.60+`
11+
[#396](https://github.com/bugsnag/bugsnag-react-native/issues/396)
12+
* Fix bug in `notifyReleaseStages` where if the release stage of a build was
13+
changed after `start()`, only the initial value was used to determine whether
14+
to send a report
15+
[bugsnag-cocoa#405](https://github.com/bugsnag/bugsnag-cocoa/issues/405)
16+
[bugsnag-cocoa#412](https://github.com/bugsnag/bugsnag-cocoa/issues/412)
17+
418
## 2.23.1 (2019-09-03)
519

620
### Bug fixes

cocoa/vendor/bugsnag-cocoa/Source/BSGOutOfMemoryWatchdog.m

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,25 @@ - (UIApplicationState)currentAppState {
293293
if ([BSG_KSSystemInfo isRunningInAppExtension]) {
294294
return UIApplicationStateActive;
295295
}
296-
UIApplication *app = [UIApplication performSelector:@selector(sharedApplication)];
297-
return [app applicationState];
296+
297+
UIApplicationState(^getState)(void) = ^() {
298+
// Calling this API indirectly to avoid a compile-time check that
299+
// [UIApplication sharedApplication] is not called from app extensions
300+
// (which is handled above)
301+
UIApplication *app = [UIApplication performSelector:@selector(sharedApplication)];
302+
return [app applicationState];
303+
};
304+
305+
if ([[NSThread currentThread] isMainThread]) {
306+
return getState();
307+
} else {
308+
// [UIApplication sharedApplication] is a main thread-only API
309+
__block UIApplicationState state;
310+
dispatch_sync(dispatch_get_main_queue(), ^{
311+
state = getState();
312+
});
313+
return state;
314+
}
298315
}
299316
#endif
300317

cocoa/vendor/bugsnag-cocoa/Source/BugsnagConfiguration.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ - (void)setReleaseStage:(NSString *)newReleaseStage {
143143
}
144144
}
145145

146+
@synthesize autoNotify = _autoNotify;
147+
148+
- (BOOL)autoNotify {
149+
return _autoNotify;
150+
}
151+
152+
- (void)setAutoNotify:(BOOL)shouldAutoNotify {
153+
if (shouldAutoNotify == _autoNotify) {
154+
return;
155+
}
156+
[self willChangeValueForKey:NSStringFromSelector(@selector(autoNotify))];
157+
_autoNotify = shouldAutoNotify;
158+
[[Bugsnag notifier] updateCrashDetectionSettings];
159+
[self didChangeValueForKey:NSStringFromSelector(@selector(autoNotify))];
160+
}
161+
146162
@synthesize notifyReleaseStages = _notifyReleaseStages;
147163

148164
- (NSArray *)notifyReleaseStages {

cocoa/vendor/bugsnag-cocoa/Source/BugsnagCrashReport.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,22 @@
102102
return error[BSGKeyReason] ?: @"";
103103
}
104104

105+
id BSGLoadConfigValue(NSDictionary *report, NSString *valueName) {
106+
NSString *keypath = [NSString stringWithFormat:@"user.config.%@", valueName];
107+
NSString *fallbackKeypath = [NSString stringWithFormat:@"user.config.config.%@", valueName];
108+
109+
return [report valueForKeyPath:keypath]
110+
?: [report valueForKeyPath:fallbackKeypath]; // some custom values are nested
111+
}
112+
105113
NSString *BSGParseContext(NSDictionary *report, NSDictionary *metaData) {
106114
id context = [report valueForKeyPath:@"user.overrides.context"];
107115
if ([context isKindOfClass:[NSString class]])
108116
return context;
109117
context = metaData[BSGKeyContext];
110118
if ([context isKindOfClass:[NSString class]])
111119
return context;
112-
context = [report valueForKeyPath:@"user.config.context"];
120+
context = BSGLoadConfigValue(report, @"context");
113121
if ([context isKindOfClass:[NSString class]])
114122
return context;
115123
return nil;
@@ -132,7 +140,7 @@
132140

133141
NSString *BSGParseReleaseStage(NSDictionary *report) {
134142
return [report valueForKeyPath:@"user.overrides.releaseStage"]
135-
?: [report valueForKeyPath:@"user.config.releaseStage"];
143+
?: BSGLoadConfigValue(report, @"releaseStage");
136144
}
137145

138146
BSGSeverity BSGParseSeverity(NSString *severity) {
@@ -253,8 +261,7 @@ - (instancetype)initWithKSReport:(NSDictionary *)report
253261
}
254262
} else {
255263
FallbackReportData *fallback = [[FallbackReportData alloc] initWithMetadata:metadata];
256-
_notifyReleaseStages =
257-
[report valueForKeyPath:@"user.config.notifyReleaseStages"];
264+
_notifyReleaseStages = BSGLoadConfigValue(report, @"notifyReleaseStages");
258265
_releaseStage = BSGParseReleaseStage(report);
259266
_incomplete = report.count == 0;
260267
_threads = [report valueForKeyPath:@"crash.threads"];
@@ -276,7 +283,10 @@ - (instancetype)initWithKSReport:(NSDictionary *)report
276283
_deviceState = BSGParseDeviceState(report);
277284
_device = BSGParseDevice(report);
278285
_app = BSGParseApp(report);
279-
_appState = BSGParseAppState(report[BSGKeySystem], [report valueForKeyPath:@"user.config.appVersion"]);
286+
_appState = BSGParseAppState(report[BSGKeySystem],
287+
BSGLoadConfigValue(report, @"appVersion"),
288+
_releaseStage, // Already loaded from config
289+
BSGLoadConfigValue(report, @"codeBundleId"));
280290
_groupingHash = BSGParseGroupingHash(report, _metaData);
281291
_overrides = [report valueForKeyPath:@"user.overrides"];
282292
_customException = BSGParseCustomException(report, [_errorClass copy],

cocoa/vendor/bugsnag-cocoa/Source/BugsnagKSCrashSysInfoParser.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212

1313
NSDictionary *_Nonnull BSGParseDevice(NSDictionary *_Nonnull report);
1414
NSDictionary *_Nonnull BSGParseApp(NSDictionary *_Nonnull report);
15-
NSDictionary *_Nonnull BSGParseAppState(NSDictionary *_Nonnull report, NSString *_Nullable preferredVersion);
15+
NSDictionary *_Nonnull BSGParseAppState(NSDictionary *_Nonnull report,
16+
NSString *_Nullable preferredVersion,
17+
NSString *_Nullable releaseStage,
18+
NSString *_Nullable codeBundleId);
1619
NSDictionary *_Nonnull BSGParseDeviceState(NSDictionary *_Nonnull report);

cocoa/vendor/bugsnag-cocoa/Source/BugsnagKSCrashSysInfoParser.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@
9090
return appState;
9191
}
9292

93-
NSDictionary *BSGParseAppState(NSDictionary *report, NSString *preferredVersion) {
93+
NSDictionary *BSGParseAppState(NSDictionary *report, NSString *preferredVersion, NSString *releaseStage, NSString *codeBundleId) {
9494
NSMutableDictionary *app = [NSMutableDictionary dictionary];
9595

9696
NSString *version = preferredVersion ?: report[@"CFBundleShortVersionString"];
9797

9898
BSGDictSetSafeObject(app, report[@"CFBundleVersion"], @"bundleVersion");
99-
BSGDictSetSafeObject(app, [Bugsnag configuration].releaseStage,
99+
BSGDictSetSafeObject(app, releaseStage,
100100
BSGKeyReleaseStage);
101101
BSGDictSetSafeObject(app, version, BSGKeyVersion);
102102

103-
BSGDictSetSafeObject(app, [Bugsnag configuration].codeBundleId, @"codeBundleId");
103+
BSGDictSetSafeObject(app, codeBundleId, @"codeBundleId");
104104

105105
NSString *notifierType;
106106
#if TARGET_OS_TV

cocoa/vendor/bugsnag-cocoa/Source/BugsnagNotifier.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,8 @@
121121
*/
122122
- (void)updateAutomaticBreadcrumbDetectionSettings;
123123

124+
/**
125+
* Enable or disable crash reporting based on configuration state
126+
*/
127+
- (void)updateCrashDetectionSettings;
124128
@end

cocoa/vendor/bugsnag-cocoa/Source/BugsnagNotifier.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#import "BugsnagSessionTracker.h"
3636
#import "BSGOutOfMemoryWatchdog.h"
3737
#import "BSG_RFC3339DateTool.h"
38+
#import "BSG_KSCrashC.h"
3839
#import "BSG_KSCrashType.h"
3940
#import "BSG_KSCrashState.h"
4041
#import "BSG_KSSystemInfo.h"
@@ -46,7 +47,7 @@
4647
#import <AppKit/AppKit.h>
4748
#endif
4849

49-
NSString *const NOTIFIER_VERSION = @"5.22.5";
50+
NSString *const NOTIFIER_VERSION = @"5.22.6";
5051
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
5152
NSString *const BSTabCrash = @"crash";
5253
NSString *const BSAttributeDepth = @"depth";
@@ -804,6 +805,21 @@ - (void)lowMemoryWarning:(NSNotification *)notif {
804805
}
805806
#endif
806807

808+
- (void)updateCrashDetectionSettings {
809+
if (self.configuration.autoNotify) {
810+
// Enable all crash detection
811+
bsg_kscrash_setHandlingCrashTypes(BSG_KSCrashTypeAll);
812+
if (self.configuration.reportOOMs) {
813+
[self.oomWatchdog enable];
814+
}
815+
} else {
816+
// Only enable support for notify()-based reports
817+
bsg_kscrash_setHandlingCrashTypes(BSG_KSCrashTypeUserReported);
818+
// autoNotify gates all unhandled report detection
819+
[self.oomWatchdog disable];
820+
}
821+
}
822+
807823
- (void)updateAutomaticBreadcrumbDetectionSettings {
808824
if ([self.configuration automaticallyCollectBreadcrumbs]) {
809825
for (NSString *name in [self automaticBreadcrumbStateEvents]) {

cocoa/vendor/bugsnag-cocoa/Source/BugsnagSessionTrackingPayload.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ - (NSMutableDictionary *)toJson {
3939
BSGDictSetSafeObject(dict, [Bugsnag notifier].details, BSGKeyNotifier);
4040

4141
NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo];
42-
BSGDictSetSafeObject(dict, BSGParseAppState(systemInfo, [Bugsnag configuration].appVersion), @"app");
42+
BSGDictSetSafeObject(dict, BSGParseAppState(systemInfo,
43+
[Bugsnag configuration].appVersion,
44+
[Bugsnag configuration].releaseStage,
45+
[Bugsnag configuration].codeBundleId), @"app");
4346
BSGDictSetSafeObject(dict, BSGParseDeviceState(systemInfo), @"device");
4447
return dict;
4548
}

cocoa/vendor/bugsnag-cocoa/iOS/BugsnagTests/BugsnagKSCrashSysInfoParserTest.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,46 @@ - (void)testDeviceFreeSpaceShouldBeNilWhenFailsToRetrieveIt {
5050
XCTAssertNil(freeBytes, @"expect nil when fails to retrieve free space for the directory");
5151
}
5252

53+
- (void)testParseAppInfo {
54+
NSDictionary *rawInfo = @{
55+
@"CFBundleShortVersionString":@"4.1.1",
56+
@"CFBundleVersion":@"4.1.1.2362",
57+
@"extra":@"foo",
58+
};
59+
NSDictionary *state = BSGParseAppState(rawInfo, nil, @"prod", nil);
60+
XCTAssertEqual(state.count, 5);
61+
XCTAssertEqualObjects(state[@"releaseStage"], @"prod");
62+
XCTAssertEqualObjects(state[@"version"], @"4.1.1");
63+
XCTAssertEqualObjects(state[@"bundleVersion"], @"4.1.1.2362");
64+
XCTAssertEqual(state[@"codeBundleId"], [NSNull null]);
65+
#if TARGET_OS_TV
66+
XCTAssertEqualObjects(state[@"type"], @"tvOS");
67+
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
68+
XCTAssertEqualObjects(state[@"type"], @"iOS");
69+
#elif TARGET_OS_MAC
70+
XCTAssertEqualObjects(state[@"type"], @"macOS");
71+
#endif
72+
}
73+
74+
- (void)testParseAppInfoPreferredValues {
75+
NSDictionary *rawInfo = @{
76+
@"CFBundleShortVersionString":@"4.1.1",
77+
@"CFBundleVersion":@"4.1.1.2362",
78+
@"extra":@"foo",
79+
};
80+
NSDictionary *state = BSGParseAppState(rawInfo, @"2.0", @"prod", @"4.2.0-cbd");
81+
XCTAssertEqual(state.count, 5);
82+
XCTAssertEqualObjects(state[@"releaseStage"], @"prod");
83+
XCTAssertEqualObjects(state[@"version"], @"2.0");
84+
XCTAssertEqualObjects(state[@"bundleVersion"], @"4.1.1.2362");
85+
XCTAssertEqualObjects(state[@"codeBundleId"], @"4.2.0-cbd");
86+
#if TARGET_OS_TV
87+
XCTAssertEqualObjects(state[@"type"], @"tvOS");
88+
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
89+
XCTAssertEqualObjects(state[@"type"], @"iOS");
90+
#elif TARGET_OS_MAC
91+
XCTAssertEqualObjects(state[@"type"], @"macOS");
92+
#endif
93+
}
94+
5395
@end

0 commit comments

Comments
 (0)