Skip to content

Commit 3508378

Browse files
authored
fix(ios): report fatal crashes with the updated api (#1290)
* fix(ios): report fatal crashes with new api * chore: update changelog
1 parent b119f83 commit 3508378

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

CHANGELOG.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
### Fixed
1111

12+
- Fix an issue with JavaScript fatal crashes on iOS causing them to be reported as native iOS crashes instead. ([#1290](https://github.com/Instabug/Instabug-React-Native/pull/1290)).
13+
- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).
1214
- Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)).
1315
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).
1416

15-
### Fixed
16-
17-
- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).
18-
1917
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
2018

2119
### Added

examples/default/ios/InstabugTests/InstabugCrashReportingTests.m

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ - (void)testSetEnabled {
2626
XCTAssertFalse(IBGCrashReporting.enabled);
2727
}
2828

29+
- (void)testSendJSCrash {
30+
NSDictionary *stackTrace = @{};
31+
32+
XCTestExpectation *expectation = [self expectationWithDescription:@"Expected resolve to be called."];
33+
34+
RCTPromiseResolveBlock resolve = ^(id result) {
35+
[expectation fulfill];
36+
};
37+
RCTPromiseRejectBlock reject = ^(NSString *code, NSString *message, NSError *error) {};
38+
39+
[self.bridge sendJSCrash:stackTrace resolver:resolve rejecter:reject];
40+
41+
[self waitForExpectations:@[expectation] timeout:1];
42+
OCMVerify([self.mCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace]);
43+
}
44+
2945
- (void)testSendNonFatalErrorJsonCrash {
3046
NSDictionary<NSString *,NSString * > *jsonCrash = @{};
3147
NSString *fingerPrint = @"fingerprint";

ios/RNInstabug/InstabugCrashReportingBridge.m

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ + (BOOL)requiresMainQueueSetup
2929
RCT_EXPORT_METHOD(sendJSCrash:(NSDictionary *)stackTrace
3030
resolver:(RCTPromiseResolveBlock)resolve
3131
rejecter:(RCTPromiseRejectBlock)reject) {
32-
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
32+
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
3333
dispatch_async(queue, ^{
34-
SEL reportCrashWithStackTraceSEL = NSSelectorFromString(@"reportCrashWithStackTrace:handled:");
35-
if ([[Instabug class] respondsToSelector:reportCrashWithStackTraceSEL]) {
36-
[[Instabug class] performSelector:reportCrashWithStackTraceSEL withObject:stackTrace withObject:@(NO)];
37-
}
34+
[IBGCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace];
3835
resolve([NSNull null]);
3936
});
4037
}
@@ -45,8 +42,6 @@ + (BOOL)requiresMainQueueSetup
4542
rejecter:(RCTPromiseRejectBlock)reject) {
4643
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
4744
dispatch_async(queue, ^{
48-
49-
5045
[IBGCrashReporting cp_reportNonFatalCrashWithStackTrace:stackTrace level:nonFatalExceptionLevel groupingString:fingerprint userAttributes:userAttributes];
5146

5247
resolve([NSNull null]);

0 commit comments

Comments
 (0)