Permalink
Browse files

Don't hard crash if you get a null stack trace in Android

Summary: If stacktrace-parser can't parse a stack trace, it'll return null. This can cause us to accidentally enter a crash loop where whenever you start your app, you load the last JS bundle you had, get a crash, and then hard crash trying to print the stack trace.

Reviewed By: frantic

Differential Revision: D3528141

fbshipit-source-id: 1146f43bc40492bfa79b6a1c0f81092383896164
  • Loading branch information...
1 parent 2537157 commit b5c3550857bd7360e7b5b6e227d795f859202245 @astreet astreet committed with Facebook Github Bot 4 Jul 7, 2016
Showing with 6 additions and 3 deletions.
  1. +6 −3 ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java
@@ -9,6 +9,8 @@
package com.facebook.react.devsupport;
+import javax.annotation.Nullable;
+
import java.io.File;
import com.facebook.react.bridge.ReadableArray;
@@ -91,9 +93,10 @@ public String getFileName() {
* Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
* {@link StackFrame}s.
*/
- public static StackFrame[] convertJsStackTrace(ReadableArray stack) {
- StackFrame[] result = new StackFrame[stack.size()];
- for (int i = 0; i < stack.size(); i++) {
+ public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
+ int size = stack != null ? stack.size() : 0;
+ StackFrame[] result = new StackFrame[size];
+ for (int i = 0; i < size; i++) {
ReadableMap frame = stack.getMap(i);
String methodName = frame.getString("methodName");
String fileName = frame.getString("file");

0 comments on commit b5c3550

Please sign in to comment.