Skip to content

Commit

Permalink
fix(ios, crashlytics): use NSInternalInconsistencyException to crash …
Browse files Browse the repository at this point in the history
…w/o redbox (#4126)
  • Loading branch information
mars-lan authored Aug 23, 2020
1 parent 7742a1f commit 2cbab5c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ + (BOOL)requiresMainQueueSetup {

RCT_EXPORT_METHOD(crash) {
if ([RNFBCrashlyticsInitProvider isCrashlyticsCollectionEnabled]) {
@[][1];
// https://firebase.google.com/docs/crashlytics/test-implementation?platform=ios recommends using "@[][1]" to crash,
// but that gets caught by react-native and shown as a red box for debug builds. Throw a different kind exception
// here to generate a hard crash.
@throw NSInternalInconsistencyException;
}
}

Expand Down

9 comments on commit 2cbab5c

@vercel
Copy link

@vercel vercel bot commented on 2cbab5c Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JellyLu
Copy link

@JellyLu JellyLu commented on 2cbab5c Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@throw NSInternalInconsistencyException; can crash the app, but firebase console can't get the report. report an issue here.

I try to throw NSInternalInconsistencyException as bellow two ways in AppDelegate.m after the app loading 30 seconds,

way one:

 @throw NSInternalInconsistencyException;

way two:

NSException* myException = [NSException
        exceptionWithName: NSInternalInconsistencyException
        reason:@"V8.4.9 NSInternalInconsistencyException"
        userInfo:nil];
@throw myException;

if I use way one, firebase console will NOT collect the crash,
if I use way two, firebase console will collect the crash.

Could you please help to double check with this?

@mikehardy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mars-lan this is very interesting and could go a long way to explaining the currently-dormant-but-still-a-problem-I-believe problems with collection of iOS reports

@mars-lan
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikehardy Interesting. Let me dig more into this and report back.

@bsonmez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@throw NSInternalInconsistencyException; can crash the app, but firebase console can't get the report. report an issue here.

I try to throw NSInternalInconsistencyException as bellow two ways in AppDelegate.m after the app loading 30 seconds,

way one:

 @throw NSInternalInconsistencyException;

way two:

NSException* myException = [NSException
        exceptionWithName: NSInternalInconsistencyException
        reason:@"V8.4.9 NSInternalInconsistencyException"
        userInfo:nil];
@throw myException;

if I use way one, firebase console will NOT collect the crash,
if I use way two, firebase console will collect the crash.

Could you please help to double check with this?

Is there any chance to show the code after changing AppDelegate.m? I tried to change in this file however, it didn't work as well.

@JellyLu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@throw NSInternalInconsistencyException; can crash the app, but firebase console can't get the report. report an issue here.
I try to throw NSInternalInconsistencyException as bellow two ways in AppDelegate.m after the app loading 30 seconds,
way one:

 @throw NSInternalInconsistencyException;

way two:

NSException* myException = [NSException
        exceptionWithName: NSInternalInconsistencyException
        reason:@"V8.4.9 NSInternalInconsistencyException"
        userInfo:nil];
@throw myException;

if I use way one, firebase console will NOT collect the crash,
if I use way two, firebase console will collect the crash.
Could you please help to double check with this?

Is there any chance to show the code after changing AppDelegate.m? I tried to change in this file however, it didn't work as well.

I didn't get what you mean "show the code after changing AppDelegate.m?" could you please explain a little bit?

@bsonmez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to throw NSInternalInconsistencyException as bellow two ways in AppDelegate.m after the app loading 30 seconds,

Hello. Sorry for not being clear. I said it based on what you have written above.

I kindly asked to see AppDelegate.m after you change with 'way two' above. I tried both and some other alternatives, however, I couldn't collect any crash in the console.

@mars-lan
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikehardy Interesting. Let me dig more into this and report back.

Looks like we have a new way of doing this: #4426. I'm pretty sure this method worked at the time I tried, but I guess something changed from Firebase's side. The peril of integrating with a blackbox :)

@JellyLu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to throw NSInternalInconsistencyException as bellow two ways in AppDelegate.m after the app loading 30 seconds,

Hello. Sorry for not being clear. I said it based on what you have written above.

I kindly asked to see AppDelegate.m after you change with 'way two' above. I tried both and some other alternatives, however, I couldn't collect any crash in the console.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"xxx"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  [FIRApp configure];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
 
  [NSTimer scheduledTimerWithTimeInterval:30.0
                                       target:self
                                     selector:@selector(theAction)
                                     userInfo:nil
                                      repeats:NO];

  return YES;
}

-(void) theAction {
  NSException* myException = [NSException
        exceptionWithName: NSInternalInconsistencyException
        reason:@"V8.4.9 NSInternalInconsistencyException"
        userInfo:nil];
@throw myException;
}

Please sign in to comment.