Disable crash reporter plugin for iOS and update callstack from array to string
Summary: This diff does the following - Comments out the code in iOS which sends the message to the desktop side - Also comments out the part where signal handler is initialised, as we no longer need it. I will remove the iOS implementation completely in next few diffs - Updated the JS side to expect call stack as a string instead of an array - Updated the android side to send callstack as a string I have commented out the code for crash reporter plugin of iOS as for iOS I will be adding a watchman to a directory where crash logs are dumped. The diff related to this is in the stack Reviewed By: passy Differential Revision: D13424824 fbshipit-source-id: b1105da912292bf73cff948206c031de9b059abd
This commit is contained in:
committed by
Facebook Github Bot
parent
73e921bafc
commit
e3fb1e1d84
@@ -1,14 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
*
|
*
|
||||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
* directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
package com.facebook.flipper.plugins.crashreporter;
|
package com.facebook.flipper.plugins.crashreporter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import com.facebook.flipper.core.FlipperArray;
|
|
||||||
import com.facebook.flipper.core.FlipperConnection;
|
import com.facebook.flipper.core.FlipperConnection;
|
||||||
import com.facebook.flipper.core.FlipperObject;
|
import com.facebook.flipper.core.FlipperObject;
|
||||||
import com.facebook.flipper.core.FlipperPlugin;
|
import com.facebook.flipper.core.FlipperPlugin;
|
||||||
@@ -57,15 +56,18 @@ public class CrashReporterPlugin implements FlipperPlugin {
|
|||||||
public void sendExceptionMessage(Thread paramThread, Throwable paramThrowable) {
|
public void sendExceptionMessage(Thread paramThread, Throwable paramThrowable) {
|
||||||
if (mConnection != null) {
|
if (mConnection != null) {
|
||||||
FlipperConnection connection = mConnection;
|
FlipperConnection connection = mConnection;
|
||||||
FlipperArray.Builder builder = new FlipperArray.Builder();
|
StringBuilder strBuilder = new StringBuilder("");
|
||||||
for (StackTraceElement stackTraceElement : paramThrowable.getStackTrace()) {
|
StackTraceElement[] elems = paramThrowable.getStackTrace();
|
||||||
builder.put(stackTraceElement.toString());
|
for (int i = 0; i < elems.length; ++i) {
|
||||||
|
strBuilder.append(elems[i].toString());
|
||||||
|
if (i < elems.length - 1) {
|
||||||
|
strBuilder.append("\n\tat ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FlipperArray arr = builder.build();
|
|
||||||
connection.send(
|
connection.send(
|
||||||
"crash-report",
|
"crash-report",
|
||||||
new FlipperObject.Builder()
|
new FlipperObject.Builder()
|
||||||
.put("callstack", arr)
|
.put("callstack", strBuilder.toString())
|
||||||
.put("name", paramThrowable.toString())
|
.put("name", paramThrowable.toString())
|
||||||
.put("reason", paramThrowable.getMessage())
|
.put("reason", paramThrowable.getMessage())
|
||||||
.build());
|
.build());
|
||||||
|
|||||||
@@ -16,16 +16,8 @@
|
|||||||
@property (assign, nonatomic) NSUInteger notificationID;
|
@property (assign, nonatomic) NSUInteger notificationID;
|
||||||
@property (assign, nonatomic) NSUncaughtExceptionHandler *prevHandler;
|
@property (assign, nonatomic) NSUncaughtExceptionHandler *prevHandler;
|
||||||
|
|
||||||
- (void) handleException:(NSException *)exception;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static void flipperkitUncaughtExceptionHandler(NSException *exception) {
|
|
||||||
NSLog(@"CRASH: %@", exception);
|
|
||||||
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
|
|
||||||
[[FlipperKitCrashReporterPlugin sharedInstance] handleException:exception];
|
|
||||||
}
|
|
||||||
|
|
||||||
@implementation FlipperKitCrashReporterPlugin {
|
@implementation FlipperKitCrashReporterPlugin {
|
||||||
std::unique_ptr<facebook::flipper::FlipperKitSignalHandler> _signalHandler;
|
std::unique_ptr<facebook::flipper::FlipperKitSignalHandler> _signalHandler;
|
||||||
folly::ScopedEventBaseThread _crashReporterThread;
|
folly::ScopedEventBaseThread _crashReporterThread;
|
||||||
@@ -55,30 +47,16 @@ static void flipperkitUncaughtExceptionHandler(NSException *exception) {
|
|||||||
return @"CrashReporter";
|
return @"CrashReporter";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) handleException:(NSException *)exception {
|
|
||||||
// TODO: Rather than having indirection from c function, somehow pass objective c selectors as a c function pointer to NSSetUncaughtExceptionHandler
|
|
||||||
self.notificationID += 1;
|
|
||||||
[self.connection send:@"crash-report" withParams:@{@"reason": [exception reason], @"name": [exception name], @"callstack": [exception callStackSymbols]}];
|
|
||||||
if (self.prevHandler) {
|
|
||||||
self.prevHandler(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)sendCrashParams:(NSDictionary *)params {
|
- (void)sendCrashParams:(NSDictionary *)params {
|
||||||
self.notificationID += 1;
|
self.notificationID += 1;
|
||||||
[self.connection send:@"crash-report" withParams: params];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didConnect:(id<FlipperConnection>)connection {
|
- (void)didConnect:(id<FlipperConnection>)connection {
|
||||||
self.connection = connection;
|
self.connection = connection;
|
||||||
_signalHandler = std::make_unique<facebook::flipper::FlipperKitSignalHandler>(self, _crashReporterThread.getEventBase());
|
|
||||||
NSSetUncaughtExceptionHandler(&flipperkitUncaughtExceptionHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didDisconnect {
|
- (void)didDisconnect {
|
||||||
self.connection = nil;
|
self.connection = nil;
|
||||||
_signalHandler.reset(nullptr); // deallocate the object
|
|
||||||
NSSetUncaughtExceptionHandler(self.prevHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)runInBackground {
|
- (BOOL)runInBackground {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import type {Notification} from '../../plugin';
|
|||||||
|
|
||||||
type Crash = {|
|
type Crash = {|
|
||||||
notificationID: number,
|
notificationID: number,
|
||||||
callStack: [string],
|
callStack: string,
|
||||||
reason: string,
|
reason: string,
|
||||||
name: string,
|
name: string,
|
||||||
|};
|
|};
|
||||||
@@ -112,18 +112,8 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
convertCallstackToString(crash: Crash): string {
|
openInLogs = (callstack: string) => {
|
||||||
return crash.callStack.reduce((acc, val) => acc.concat('\n', val));
|
this.props.selectPlugin('DeviceLogs', callstack);
|
||||||
}
|
|
||||||
|
|
||||||
openInLogs = (crash: Crash) => {
|
|
||||||
this.props.selectPlugin(
|
|
||||||
'DeviceLogs',
|
|
||||||
crash.callStack
|
|
||||||
.slice(0, 5)
|
|
||||||
.join('\n\tat ')
|
|
||||||
.trim(),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -134,7 +124,7 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (crash) {
|
if (crash) {
|
||||||
const callStackString = this.convertCallstackToString(crash);
|
const callStackString = crash.callStack;
|
||||||
return (
|
return (
|
||||||
<RootColumn>
|
<RootColumn>
|
||||||
<CrashRow>
|
<CrashRow>
|
||||||
@@ -163,7 +153,7 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
|
|||||||
</CrashRow>
|
</CrashRow>
|
||||||
{this.device.os == 'Android' && (
|
{this.device.os == 'Android' && (
|
||||||
<CrashRow>
|
<CrashRow>
|
||||||
<Button onClick={() => this.openInLogs(crash)}>
|
<Button onClick={() => this.openInLogs(crash.callStack)}>
|
||||||
Open in Logs
|
Open in Logs
|
||||||
</Button>
|
</Button>
|
||||||
</CrashRow>
|
</CrashRow>
|
||||||
|
|||||||
Reference in New Issue
Block a user