From a6950f00eec91a86801227d3967389910d31a901 Mon Sep 17 00:00:00 2001 From: Ahmed Mahmoud Date: Mon, 30 Sep 2024 13:51:58 +0300 Subject: [PATCH 1/2] fix(ios): report fatal crashes with new api --- .../InstabugTests/InstabugCrashReportingTests.m | 16 ++++++++++++++++ ios/RNInstabug/InstabugCrashReportingBridge.m | 9 ++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/examples/default/ios/InstabugTests/InstabugCrashReportingTests.m b/examples/default/ios/InstabugTests/InstabugCrashReportingTests.m index 0d5ac73482..d42e47022a 100644 --- a/examples/default/ios/InstabugTests/InstabugCrashReportingTests.m +++ b/examples/default/ios/InstabugTests/InstabugCrashReportingTests.m @@ -26,6 +26,22 @@ - (void)testSetEnabled { XCTAssertFalse(IBGCrashReporting.enabled); } +- (void)testSendJSCrash { + NSDictionary *stackTrace = @{}; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Expected resolve to be called."]; + + RCTPromiseResolveBlock resolve = ^(id result) { + [expectation fulfill]; + }; + RCTPromiseRejectBlock reject = ^(NSString *code, NSString *message, NSError *error) {}; + + [self.bridge sendJSCrash:stackTrace resolver:resolve rejecter:reject]; + + [self waitForExpectations:@[expectation] timeout:1]; + OCMVerify([self.mCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace]); +} + - (void)testSendNonFatalErrorJsonCrash { NSDictionary *jsonCrash = @{}; NSString *fingerPrint = @"fingerprint"; diff --git a/ios/RNInstabug/InstabugCrashReportingBridge.m b/ios/RNInstabug/InstabugCrashReportingBridge.m index 9d878854f2..c73a85d5bc 100644 --- a/ios/RNInstabug/InstabugCrashReportingBridge.m +++ b/ios/RNInstabug/InstabugCrashReportingBridge.m @@ -29,12 +29,9 @@ + (BOOL)requiresMainQueueSetup RCT_EXPORT_METHOD(sendJSCrash:(NSDictionary *)stackTrace resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ - SEL reportCrashWithStackTraceSEL = NSSelectorFromString(@"reportCrashWithStackTrace:handled:"); - if ([[Instabug class] respondsToSelector:reportCrashWithStackTraceSEL]) { - [[Instabug class] performSelector:reportCrashWithStackTraceSEL withObject:stackTrace withObject:@(NO)]; - } + [IBGCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace]; resolve([NSNull null]); }); } @@ -45,8 +42,6 @@ + (BOOL)requiresMainQueueSetup rejecter:(RCTPromiseRejectBlock)reject) { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); dispatch_async(queue, ^{ - - [IBGCrashReporting cp_reportNonFatalCrashWithStackTrace:stackTrace level:nonFatalExceptionLevel groupingString:fingerprint userAttributes:userAttributes]; resolve([NSNull null]); From 1f3f79ae1f54930f7f555b2b722af0aa532dab4d Mon Sep 17 00:00:00 2001 From: Ahmed Mahmoud Date: Mon, 30 Sep 2024 14:07:57 +0300 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b514e63dab..2f8d206c9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,11 @@ ### Fixed +- 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)). +- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). - 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)). - Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). -### Fixed - -- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). - ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added