Skip to content

fix(firebase_crashlytics): Include obfuscated stack traces#4407

Merged
Salakar merged 12 commits intofirebase:masterfrom
untp:obfuscated-stack-traces
Apr 19, 2021
Merged

fix(firebase_crashlytics): Include obfuscated stack traces#4407
Salakar merged 12 commits intofirebase:masterfrom
untp:obfuscated-stack-traces

Conversation

@untp
Copy link
Contributor

@untp untp commented Dec 16, 2020

Description

No stack traces appear for crashes that from obfuscated dart code. Because current implementation can't parse obfuscated stack traces. This PR implementation sends unparsed stack traces if the stack trace is obfuscated.

Deobfuscating can be done like this.

Problems

  1. This implementation removes warning line, PID and instructions lines, abs addresses. Because these variables are different between sessions, so the same error will be grouped in Crashlytics Console. (These variables are not important, only _kDartIsolateSnapshotInstructions+0x lines are needed for deobfuscating)

  2. Crashlytics Console appends (.java) and prepends . every line. Developers need to trim these lines manually.

Screenshots from Crashlytics Console

solved-problem
last-state

If warning, pid, instructions lines not removed: (all errors are grouped)

2

1

If warning, pid, instructions lines are removed, but abs is not removed: (These issues are same error with different sessions. Their virt addresses are same, but abs addresses are different. Abs addresses are must be removed for grouping same errors.)

problem

no-warning-obfuscated-stack-trace

Related Issues

Fixes #1150
Fixes #2644

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@google-cla google-cla bot added the cla: yes label Dec 16, 2020
@untp

This comment has been minimized.

@untp

This comment has been minimized.

@untp

This comment has been minimized.

@Ehesp
Copy link
Member

Ehesp commented Dec 17, 2020

Wow nice one for this PR! Will get it reviewed.

@talent-apps
Copy link

@Ehesp Please prioritize this issue.
It is crucial for Flutter production apps.
🙏

@talent-apps
Copy link

talent-apps commented Dec 24, 2020

@untp
We tested the PR and we successfully managed to deobfuscate crashes from the Crashlytics reports.
One question remains: each report on the dashboard contains a reason field which is also obfuscated.
Example: Error thrown Instance of 'Ax'.
Is there a way to deobfuscate it? It could be very helpful for the analysis.

@talent-apps
Copy link

@untp On iOS the stack trace lines have the following format:
#00 abs 000000011615a293 _kDartIsolateSnapshotInstructions+0x150293
The current regexp doesn't pick those lines. Maybe we need a different regexp for iOS?

@untp
Copy link
Contributor Author

untp commented Dec 25, 2020

@talent-apps awesome, thanks for testing. I forgot to test on iOS. I fixed it with the above commit. If you catch any bugs, I would appreciate it if you let me know.

@talent-apps
Copy link

@untp When testing the new RegExp, the app force quits upon dart non-fatal crash and we don't see any reports on the dashboard.
Any idea why?

@untp
Copy link
Contributor Author

untp commented Dec 26, 2020

@talent-apps thanks, I fixed it. The problem was file field of stack trace lines is not nullable on iOS.

@talent-apps
Copy link

talent-apps commented Dec 26, 2020

@untp We can confirm that the deobfuscation works on both platforms now. 🥳
Thanks for this important contribution.
It may take months until this PR is reviewed since this plugin is undermaintained.
We will not wait for an official release and we will start using it in production.

@dayron9110
Copy link

Any updates?

@Vitor-Bukovitz
Copy link

@Ehesp & @Salakar can you guys take a look at this PR? This may solve the issue #80

@envercc
Copy link

envercc commented Mar 22, 2021

This one would be really helpful, please take a look into it!

@untp
Copy link
Contributor Author

untp commented Mar 23, 2021

@rrousselGit @Salakar @Ehesp
Sorry for spamming, but this PR is 3 months old, and it fixes a very important issue (#2644) which has impact: crowd tag. This issue is in the 1st page if issues are sorted to most reactions 👍. This issue is fixed with this PR, and it only needs to be reviewed.

Can you review this PR please?

@rrousselGit rrousselGit self-assigned this Apr 1, 2021
@Salakar Salakar requested a review from Ehesp April 7, 2021 08:48
Copy link
Contributor

@rrousselGit rrousselGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

But I wonder why those (.java) are added. Thought @russellwheatley?

Copy link
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrousselGit I don't know why the Crashyltics backend appends .java to each line, my best guess would be to indicate it came from an android app.

PR LGTM once Remi's test issues have been addressed.

@untp
Copy link
Contributor Author

untp commented Apr 8, 2021

The file field is an empty string, so it appears as .java. I tried with null, but it didn't work. This issue can only be fixed on the backend. Crashlytics backend should not append .java if file field is empty. Also on iOS it prepends 0 ??? 0x0.

@untp untp marked this pull request as draft April 8, 2021 11:45
@untp
Copy link
Contributor Author

untp commented Apr 8, 2021

I marked this as draft. I tested now, it outputs the warning line. This shouldn't happen.

Show image

er

EDIT: I found the issue. Obfuscated stack traces are now including this line after pid: ... tid: ... line:
build_id: '77d1b910140a2d66b93594aea59469cf'
Trace API thinks this is a friendly trace. Friendly Trace's regex:
RegExp(r'^[^\s<][^\s]*( \d+(:\d+)?)?[ \t]+[^\s]+$', multiLine: true);
We need to force Trace API to parse VM stack trace.

So I will change Trace.from to Trace.parseVM.

@untp
Copy link
Contributor Author

untp commented Apr 8, 2021

Now it works both obfuscated and non-obfuscated.
Working

@untp untp marked this pull request as ready for review April 8, 2021 16:00
Copy link
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. What do you think, @rrousselGit?

Copy link
Contributor

@rrousselGit rrousselGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Salakar Salakar merged commit 6ff4bb9 into firebase:master Apr 19, 2021
@untp untp deleted the obfuscated-stack-traces branch April 19, 2021 20:24
@firebase firebase locked and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[firebase_crashlytics] No stack traces for issues on Crashlytics dashboard [firebase_crashlytics] Support for deobfuscation of Dart reports

9 participants