sentry-dart icon indicating copy to clipboard operation
sentry-dart copied to clipboard

Issues from Android and iOS appear differently in the Sentry UI from a Flutter app

Open SoftMemes opened this issue 1 year ago • 11 comments

Platform

Flutter Mobile

Obfuscation

Enabled

Debug Info

Enabled

Doctor

[✓] Flutter (Channel stable, 3.16.9, on Ubuntu 23.10 6.5.0-27-generic, locale en_GB.UTF-8) • Flutter version 3.16.9 on channel stable at /home/freed/opt/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 41456452f2 (3 months ago), 2024-01-25 10:06:23 -0800 • Engine revision f40e976bed • Dart version 3.2.6 • DevTools version 2.28.5

Version

7.16.1

Steps to Reproduce

I have a Flutter project and build for Android and iOS. I am using the dart sentry plugin to upload debug symbols and sources, and use the Sentry CLI directly to create releases in Sentry. Further I'm using the Sentry CLI to upload pro-guard files for Android and explicity specify the UUID when initializing Sentry.

I've added my package name in inAppIncludes in the app.

I have also set up the Github integration and code mappings to point to the relevant directories.

The Android and iOS versions are built separately as part of CI. I use an automatically generated unique build number for each (time based) and infer the version from git tags, resulting in release identifiers liks [email protected]+40001 and [email protected]+40041. These are distinct releases/packages in Sentry. This all works and they show up as expected.

Expected Result

  • Android and iOS issues are grouped together.
  • Source context is available for exceptions from my code
  • In-app frames are detected and flagged
  • Links to GitHub work on stack trace frames

Actual Result

  • Android and iOS issues show up separately, not grouped
  • Source context for stacktraces are showing up in Android issues
  • Android stack frames are not flagged as in-app
  • Android issues do not have a link to Github
  • Source context for stacktraces are not visible for iOS issues
  • iOS issues do have stack frames linked correctly to Github
  • iOS issues have the stack frames correctly detected as in-app

Further, the paths reported are different between the two cases (which may explain some of the other issues/differences)

  • For Android, the file path reported when hovering over the filename in the web UI is an absolute path to the file as it existed when the project was built (in this case a path starting with /home/circleci/project
  • For iOS, the file path is prefixed with my package name (package:mypackage/somedir/file.dart). This path does not include "lib".

Are you willing to submit a PR?

Yes

SoftMemes avatar Apr 10 '24 13:04 SoftMemes

Hey can you send the links to these events to me at [email protected] so we can take a closer look

buenaflor avatar Apr 11 '24 11:04 buenaflor

Could you also provide a reproducible sample app? It would greatly help in debuggin this

buenaflor avatar Apr 11 '24 13:04 buenaflor

So i tried to reproduce this using the TestFlight iOS example, and an Android release build. For the latter, the plugin was also executed so new debug symbols were uploaded. I also set the build number to match iOS. At first this did

List of Reported Issues/Problems

Android and iOS issues show up separately, not grouped

Yes. The issues were correctly grouped for iOS (release) and Android (release) build. This was only not working when one platform did not have --split-debug-info and '--obfuscate' enabled and the other did.

iOS (Release) Android (Release)
Bildschirmfoto 2024-05-14 um 17 59 57 Bildschirmfoto 2024-05-14 um 16 13 47

Source context for stacktraces are showing up in Android issues

Yes, as seen above.

Android stack frames are not flagged as in-app

Yes, only in iOS.

Not in-app
Bildschirmfoto 2024-05-14 um 17 54 44

Android issues do not have a link to Github

Yes, see above.

Source context for stacktraces are not visible for iOS issues

No, this works with --split-debug-info and '--obfuscate' flags. See screenshots above.

iOS issues do have stack frames linked correctly to Github

No, this works with --split-debug-info and '--obfuscate' flags. See screenshots above.

iOS issues have the stack frames correctly detected as in-app

Yes, see screenshots above.

sentry.io Issues

iOS (Release) Android (Release)

denrase avatar May 14 '24 14:05 denrase

Still need to verify if we correctly setup the TestFlight release build.

denrase avatar May 14 '24 14:05 denrase

Updated the comments above. It looks like everything works, except detecting in-app frames on Android and linking to GH.

denrase avatar May 14 '24 15:05 denrase

@buenaflor Looking through this, i think we need to set the in-app flag on the backend. On the client, we do not have the package if the app is obfuscated, which is how in-app frames are determined.

Default Obfuscated
Bildschirmfoto 2024-06-03 um 14 43 12 Bildschirmfoto 2024-06-03 um 14 44 46

denrase avatar Jun 03 '24 12:06 denrase

@Swatinem hey, you got a clue for two identical stacktraces (iOS & Android) where one has every frame marked as inApp (iOS) and the other does not have any marked(Android)? I guess the stacktrace rules are affecting it?

buenaflor avatar Jun 10 '24 09:06 buenaflor

Yes, the stacktrace rules have an effect there. There is also in_app normalization, which defaults a None value to true/false depending on presence of either flag anywhere else in the stack trace. So its possible that iOS (either through the SDK, or a builtin enhancer rule) sets that flag on one system frame, and then other frames are being defaulted. I don’t have enough context here to be of more help.

Swatinem avatar Jun 10 '24 11:06 Swatinem

@krystofwoldrich in RN triggering the same error on iOS and Android will result being grouped correct? Do you do anything specific there to make that happen?

buenaflor avatar Jan 16 '25 12:01 buenaflor

If RN App throws error in JS throw new Error('My first error') this will result in one issue in Sentry for both iOS and Android, because the in_app JS frames will be the same.

krystofwoldrich avatar Jan 16 '25 12:01 krystofwoldrich

yeah makes sense, I suppose we also want the same behaviour for Flutter

buenaflor avatar Jan 16 '25 13:01 buenaflor

Improvements are live:

  • stacktraces on both ios and android are now properly set inApp
  • iOS and Android events of the same error are now grouped together

buenaflor avatar Jul 15 '25 13:07 buenaflor

I will close this issue and create a new issue regarding the Github stacktrace links

buenaflor avatar Jul 15 '25 14:07 buenaflor