Recently, I've spotted, that stack traces of issues reported to Sentry from Pocket Casts Android are linked to SourceFile instead of the real file name.
Usually, this happens when -renamesourcefileattribute is used:
-renamesourcefileattributeSpecifies a constant string to be put in theSourceFileattributes (andSourceDirattributes) of the class files.
I made sure, though, that the project does not use this option, also in R8 generated configuration, which combines all R8 configurations during the build.
Later, I realized that R8 whenever project uses full mode, -renamesourcefileattribute is also enabled (even if not mentioned in the configuration)! Here's the reproduction: wzieba/R8FullModeRenamesSources.
This motivated me to ask a question at Android Study Group (Slack), which confirmed that this behavior is intended (R8 source code) and mentioning it was missed from R8 full mode documentation. Thanks to this discussion, R8 docs are now updated with:
...
- When optimizing or minifying the
SourceFileattribute will always be rewritten toSourceFileunless-renamesourcefileattributeis used in which case the provided value is used. The original source file name is in the mapping file and when optimizing or minifying a mapping file is always produced.
In other words: SourceFile is always rewritten (name of the file will be obfuscated), but if e.g. -renamesourcefileattribute FooBar is used, then istead of SourceFile string, the stack trace will point to FooBar.
As I knew, the reason I see SourceFile in Sentry dashboard, I still didn't know why it's not deobfuscated. This leads me to getsentry/rust-proguardproject - Sentry's R8/Proguard rust-based custom deobfuscator.
Upon browsing the repository, I've realized that the project didn't support recovering file names (SourceFile -> real file name) which was described in this issue.
I decided to make the contribution, resulting in this PR: Support symbolicated file names. The Sentry team was very welcoming, and we together worked towards merging the PR. In the end, the feature of supporting deobfuscating file names should be soon available, unblocking many Sentry features for projects that use -renamesourcefileattribute or R8 full mode 😊.
