Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse PlatformException and create a mixed stack trace with Dart and Java frames #321

Closed
marandaneto opened this issue Feb 26, 2021 · 9 comments

Comments

@marandaneto
Copy link
Contributor

Parse PlatformException and create a mixed stack trace with Dart and Java frames

Screenshot 2021-02-26 at 08 31 29

We get this message as a String and not as a StackTrace object, so we don't parse it and log it as it is, but the exception itself has frames as you can see below in the image, ideally, we could parse it out and create a mixed stack trace with Dart and Java code, this would make the experience much better.
As you can see, the Java bits has ProGuard enabled, we need to take this into consideration.

@ueman
Copy link
Collaborator

ueman commented Jun 4, 2021

See https://api.flutter.dev/flutter/services/PlatformException/stacktrace.html

We could also do this for other platforms if applicable.

@marandaneto
Copy link
Contributor Author

marandaneto commented Jun 7, 2021

yep, but that's the problem, it's a String, we need to convert to https://github.com/getsentry/sentry-dart/blob/main/dart/lib/src/protocol/sentry_stack_trace.dart so Sentry can display the stack trace nicely, and symbolicate if necessary (eg proguard), right now it displays as a message String

@bruno-garcia
Copy link
Member

@lucas-zimerman did something similar on Xamarin with iOS stacktraces. Not sure symbolication was added there though

@marandaneto
Copy link
Contributor Author

@ueman does the logic from https://github.com/ueman/stack_trace_parser would work here too?

@ueman
Copy link
Collaborator

ueman commented Feb 9, 2022

@ueman does the logic from https://github.com/ueman/stack_trace_parser would work here too?

Yeah, but I haven't tested how good it works: https://gist.github.com/ueman/ceb1b261ebf5cc5d01fcfbb18c833476

On Android you can produce a PlatformException if you're passing something on a MethodChannel from Android to Dart which can't be serialized by the MethodChannel. No idea what other cases produce PlatformException with stacktraces and I also haven't looked into the other platforms yet.

@marandaneto
Copy link
Contributor Author

@ueman Nice,I only found throw PlatformException here.

Another example is if you cause an NPE exception on Java/Kotlin, Flutter wraps up into a PlatformException and does not crash the App.
Parsing the PlatformException should be specific per platform, indeed, nothing blocks us from adding 1 by 1 depending on priorities.

@marandaneto
Copy link
Contributor Author

When doing this, consider addressing #518 which is making the native exception as a chained exception, so we have the Dart and the Native stack trace.

@ueman
Copy link
Collaborator

ueman commented Feb 13, 2022

When doing this, consider addressing #518 which is making the native exception as a chained exception, so we have the Dart and the Native stack trace.

That already works with the gist I've posted above.

@ueman
Copy link
Collaborator

ueman commented Apr 21, 2022

@marandaneto I guess this issue can be closed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants