Update the "nativeStackAndroid" (#25014)

Summary:
Update the "nativeStackAndroid" frame limit to 50 and include the class name on the "nativeStackAndroid".

nativeStackAndroid only contains up to 10 lines of stack traces. This is due to the "ERROR_STACK_FRAME_LIMIT" set to 10 on https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java.

![2019-05-22_10-33-23](https://user-images.githubusercontent.com/14658357/58291337-eba8de80-7d71-11e9-9524-5bd6814c9f4a.png)

nativeStackAndroid should contain a more reasonable number of the native stack traces. (nativeStackIOS includes all of them). another improvement could be adding the "declaringClass" on top of the "methodName", "LineNumber", and "file" on the stack trace frameMap.

![2019-05-22_13-38-43](https://user-images.githubusercontent.com/14658357/58290869-1b56e700-7d70-11e9-9e63-2149fd1486c7.png)

## Changelog

[Android] [Added] - Update the "nativeStackAndroid" frame limit to 50 and include class name
Pull Request resolved: https://github.com/facebook/react-native/pull/25014

Differential Revision: D15503022

Pulled By: cpojer

fbshipit-source-id: 6f1bc25ea739715d0e7589d430bf9cf72da305b2
This commit is contained in:
rkang
2019-05-24 15:30:03 -07:00
committed by Facebook Github Bot
parent 651cc2613f
commit 206bb6d3b9
@@ -20,7 +20,7 @@ import javax.annotation.Nullable;
public class PromiseImpl implements Promise {
// Number of stack frames to parse and return to mReject.invoke
// for ERROR_MAP_KEY_NATIVE_STACK
private static final int ERROR_STACK_FRAME_LIMIT = 10;
private static final int ERROR_STACK_FRAME_LIMIT = 50;
private static final String ERROR_DEFAULT_CODE = "EUNSPECIFIED";
private static final String ERROR_DEFAULT_MESSAGE = "Error not specified.";
@@ -32,6 +32,7 @@ public class PromiseImpl implements Promise {
private static final String ERROR_MAP_KEY_NATIVE_STACK = "nativeStackAndroid";
// Keys for ERROR_MAP_KEY_NATIVE_STACK's StackFrame maps
private static final String STACK_FRAME_KEY_CLASS = "class";
private static final String STACK_FRAME_KEY_FILE = "file";
private static final String STACK_FRAME_KEY_LINE_NUMBER = "lineNumber";
private static final String STACK_FRAME_KEY_METHOD_NAME = "methodName";
@@ -218,6 +219,7 @@ public class PromiseImpl implements Promise {
StackTraceElement frame = stackTrace[i];
WritableMap frameMap = new WritableNativeMap();
// NOTE: no column number exists StackTraceElement
frameMap.putString(STACK_FRAME_KEY_CLASS, frame.getClassName());
frameMap.putString(STACK_FRAME_KEY_FILE, frame.getFileName());
frameMap.putInt(STACK_FRAME_KEY_LINE_NUMBER, frame.getLineNumber());
frameMap.putString(STACK_FRAME_KEY_METHOD_NAME, frame.getMethodName());