Skip to content

Commit 4d18e22

Browse files
committed
Set JavaCrashHandler as default
Remove handler executable
1 parent 1078f30 commit 4d18e22

File tree

3 files changed

+11
-44
lines changed

3 files changed

+11
-44
lines changed

packages/react-native/android/src/main/java/backtrace/library/BacktraceReactNative.java

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class BacktraceReactNative extends ReactContextBaseJavaModule {
2828
}
2929

3030
public static final String NAME = "BacktraceReactNative";
31-
private final String _crashpadHandlerName = "/libcrashpad_handler.so";
3231

3332
public native void Crash();
3433

@@ -54,43 +53,23 @@ public Boolean initialize(String minidumpSubmissionUrl, String databasePath, Rea
5453
Log.d(this.NAME, "Unsupported ABI detected.");
5554
return false;
5655
}
57-
String handlerPath = context.getApplicationInfo().nativeLibraryDir + _crashpadHandlerName;
5856

5957
HashMap<String, Object> attributes = readableAttributes.toHashMap();
60-
6158
String[] keys = attributes.keySet().toArray(new String[0]);
6259
String[] values = attributes.values().toArray(new String[0]);
60+
6361
BacktraceCrashHandlerWrapper nativeCommunication = new BacktraceCrashHandlerWrapper();
62+
// Always use the Java crash handler path
63+
Boolean result = nativeCommunication.initializeJavaCrashHandler(
64+
minidumpSubmissionUrl,
65+
databasePath,
66+
crashHandlerConfiguration.getClassPath(),
67+
keys,
68+
values,
69+
attachmentPaths.toArrayList().toArray(new String[0]),
70+
crashHandlerConfiguration.getCrashHandlerEnvironmentVariables(this.context.getApplicationInfo()).toArray(new String[0])
71+
);
6472

65-
// Depending on the AGP version, the crash handler executable might be extracted from APK or not.
66-
// Due to that, we need to have an option, to capture and send exceptions without the crash handler executable.
67-
// We can achieve the same via Java Crash Handler - the Java class that will be executed via app_process.
68-
69-
// The reason why we don't want to enable java crash handler by default is because of the proguard
70-
// support and testing potential limitations of the new java crash handler.
71-
Boolean result =
72-
new File(handlerPath).exists()
73-
? nativeCommunication.initializeCrashHandler(
74-
minidumpSubmissionUrl,
75-
databasePath,
76-
handlerPath,
77-
keys,
78-
values,
79-
attachmentPaths.toArrayList().toArray(new String[0]),
80-
false,
81-
null
82-
)
83-
: nativeCommunication.initializeJavaCrashHandler(
84-
minidumpSubmissionUrl,
85-
databasePath,
86-
crashHandlerConfiguration.getClassPath(),
87-
keys,
88-
values,
89-
attachmentPaths.toArrayList().toArray(new String[0]),
90-
crashHandlerConfiguration
91-
.getCrashHandlerEnvironmentVariables(this.context.getApplicationInfo())
92-
.toArray(new String[0])
93-
);
9473
return result;
9574
}
9675

packages/react-native/android/src/main/java/backtrace/library/nativeCalls/BacktraceCrashHandler.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@ public class BacktraceCrashHandler {
55

66
public static native boolean initializeJavaCrashHandler(String url, String databasePath, String classPath, String[] attributeKeys, String[] attributeValues,
77
String[] attachmentPaths, String[] environmentVariables);
8-
9-
public static native boolean initializeCrashHandler(String url, String databasePath, String handlerPath,
10-
String[] attributeKeys, String[] attributeValues,
11-
String[] attachmentPaths, boolean enableClientSideUnwinding,
12-
Integer unwindingMode);
138
}

packages/react-native/android/src/main/java/backtrace/library/nativeCalls/BacktraceCrashHandlerWrapper.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,4 @@ public boolean initializeJavaCrashHandler(String url, String databasePath, Strin
99
String[] attachmentPaths, String[] environmentVariables) {
1010
return BacktraceCrashHandler.initializeJavaCrashHandler(url, databasePath, classPath, attributeKeys, attributeValues, attachmentPaths, environmentVariables);
1111
}
12-
13-
public boolean initializeCrashHandler(String url, String databasePath, String handlerPath,
14-
String[] attributeKeys, String[] attributeValues,
15-
String[] attachmentPaths, boolean enableClientSideUnwinding,
16-
Integer unwindingMode) {
17-
return BacktraceCrashHandler.initializeCrashHandler(url, databasePath, handlerPath, attributeKeys, attributeValues, attachmentPaths, enableClientSideUnwinding, unwindingMode);
18-
}
1912
}

0 commit comments

Comments
 (0)