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

Feat/only send debug images referenced in the stacktrace for events #2329

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

martinhaintz
Copy link
Collaborator

@martinhaintz martinhaintz commented Oct 7, 2024

📜 Description

Instead of sending all debug images in case of errors, we only want to send the referenced debug images of the stacktrace to be sent.

💡 Motivation and Context

close #1755

💚 How did you test it?

build local with flutter build macos --release --obfuscate --split-debug-info=./ and looked at sentry for the imageadresses. Then run flutter packages pub run sentry_dart_plugin and looked for further info in sentry.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 4870e02

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.89%. Comparing base (dd16d3e) to head (4870e02).

Files with missing lines Patch % Lines
flutter/lib/src/native/sentry_native_channel.dart 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2329      +/-   ##
==========================================
+ Coverage   85.06%   85.89%   +0.83%     
==========================================
  Files         257       81     -176     
  Lines        9191     2872    -6319     
==========================================
- Hits         7818     2467    -5351     
+ Misses       1373      405     -968     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martinhaintz
Copy link
Collaborator Author

@buenaflor any ideas, what would be the best way to test this? print and log are disabled in Flutter for release builds.

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 479.67 ms 501.98 ms 22.31 ms
Size 6.49 MiB 7.56 MiB 1.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e5b744f 302.70 ms 342.17 ms 39.47 ms
0ac1eed 370.60 ms 441.54 ms 70.94 ms
90a08ea 477.25 ms 534.10 ms 56.85 ms
0db91cc 327.85 ms 387.31 ms 59.46 ms
061fed2 434.11 ms 506.49 ms 72.38 ms
4829ad3 381.55 ms 455.45 ms 73.90 ms
519423f 357.00 ms 415.77 ms 58.77 ms
ddc97ad 331.45 ms 384.06 ms 52.61 ms
e3ef570 389.71 ms 459.16 ms 69.45 ms
2d3b03d 309.53 ms 353.40 ms 43.87 ms

App size

Revision Plain With Sentry Diff
e5b744f 6.06 MiB 7.09 MiB 1.03 MiB
0ac1eed 6.06 MiB 7.03 MiB 990.44 KiB
90a08ea 6.49 MiB 7.55 MiB 1.06 MiB
0db91cc 5.94 MiB 6.95 MiB 1.01 MiB
061fed2 6.52 MiB 7.59 MiB 1.06 MiB
4829ad3 6.33 MiB 7.26 MiB 943.11 KiB
519423f 6.06 MiB 7.03 MiB 989.24 KiB
ddc97ad 6.16 MiB 7.14 MiB 1003.75 KiB
e3ef570 6.33 MiB 7.26 MiB 950.38 KiB
2d3b03d 6.06 MiB 7.09 MiB 1.03 MiB

Previous results on branch: feat/only-send-debug-images-referenced-in-the-stacktrace-for-events

Startup times

Revision Plain With Sentry Diff
fa97c64 472.71 ms 530.63 ms 57.92 ms
18890a0 500.08 ms 537.72 ms 37.64 ms
bad0c67 463.64 ms 517.10 ms 53.46 ms
ad79f89 503.92 ms 507.65 ms 3.74 ms
0fef294 469.37 ms 509.82 ms 40.45 ms
2cc98f6 424.36 ms 472.90 ms 48.54 ms

App size

Revision Plain With Sentry Diff
fa97c64 6.49 MiB 7.56 MiB 1.07 MiB
18890a0 6.49 MiB 7.57 MiB 1.08 MiB
bad0c67 6.49 MiB 7.56 MiB 1.07 MiB
ad79f89 6.49 MiB 7.56 MiB 1.07 MiB
0fef294 6.49 MiB 7.56 MiB 1.07 MiB
2cc98f6 6.49 MiB 7.57 MiB 1.08 MiB

Copy link
Contributor

github-actions bot commented Oct 7, 2024

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1250.93 ms 1273.89 ms 22.96 ms
Size 8.38 MiB 9.75 MiB 1.37 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
333903e 1251.15 ms 1270.21 ms 19.06 ms
d53c6fa 1254.86 ms 1270.83 ms 15.97 ms
b66cc27 1249.64 ms 1275.57 ms 25.94 ms
bf8d36c 1238.33 ms 1258.71 ms 20.38 ms
ffae3e3 1215.82 ms 1238.49 ms 22.67 ms
6fedcab 1242.33 ms 1269.66 ms 27.33 ms
ba9c106 1241.76 ms 1265.15 ms 23.40 ms
bc29768 1247.25 ms 1268.63 ms 21.38 ms
a4c4f8c 1217.77 ms 1245.88 ms 28.11 ms
3e5078c 1239.73 ms 1248.69 ms 8.96 ms

App size

Revision Plain With Sentry Diff
333903e 8.10 MiB 9.16 MiB 1.06 MiB
d53c6fa 8.29 MiB 9.39 MiB 1.10 MiB
b66cc27 8.38 MiB 9.74 MiB 1.36 MiB
bf8d36c 8.38 MiB 9.74 MiB 1.36 MiB
ffae3e3 8.28 MiB 9.33 MiB 1.05 MiB
6fedcab 8.32 MiB 9.50 MiB 1.18 MiB
ba9c106 8.32 MiB 9.38 MiB 1.06 MiB
bc29768 8.32 MiB 9.38 MiB 1.05 MiB
a4c4f8c 8.38 MiB 9.74 MiB 1.36 MiB
3e5078c 8.28 MiB 9.34 MiB 1.06 MiB

Previous results on branch: feat/only-send-debug-images-referenced-in-the-stacktrace-for-events

Startup times

Revision Plain With Sentry Diff
ad79f89 1258.51 ms 1281.02 ms 22.51 ms
fa97c64 1264.96 ms 1289.26 ms 24.30 ms
bad0c67 1252.14 ms 1262.27 ms 10.13 ms
18890a0 1252.71 ms 1274.23 ms 21.51 ms
0fef294 1228.18 ms 1237.88 ms 9.69 ms

App size

Revision Plain With Sentry Diff
ad79f89 8.38 MiB 9.75 MiB 1.37 MiB
fa97c64 8.38 MiB 9.74 MiB 1.36 MiB
bad0c67 8.38 MiB 9.74 MiB 1.36 MiB
18890a0 8.38 MiB 9.75 MiB 1.37 MiB
0fef294 8.38 MiB 9.74 MiB 1.36 MiB

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

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

I took a quick look and fixed it locally. here's several things that went wrong:

  • platform channels do not support Set, read here about the supported types, which means we need to use List to pass the instruction addresses from flutter to native. We can continue using sets when parsing the addresses but when communicating between platform layers these need to be converted to List. generally this may be something that we can improve for type safety when interacting through platform channels. I was surprised that this didn't trigger any error or warning
  • UInt64(instructionAddr) is not correct because the base it uses to convert the String is base 10 but the instruction addresses we are dealing with are hex so we need to adjust the radix/base to 16 => UInt64(instructionAddr, radix: 16) but this won't still work because the instruction addresses we pass in contain the 0x prefix which we also need to remove before we convert it to UInt64
  • In the native channel loadDebugImages function you changed Map<dynamic, dynamic> to Map<dynamic, Set<String>> which doesn't work because DebugMeta fields won't match this
  • if the debug images that we parsed from the stacktrace is empty, we should always return all debug images with PrivateSentrySDKOnly.getDebugImages(). This did not work because it was only triggered by the condition if the passed instruction addresses are null or empty and not if the parsed images afterwards are empty

flutter/ios/Classes/SentryFlutterPluginApple.swift Outdated Show resolved Hide resolved
flutter/ios/Classes/SentryFlutterPluginApple.swift Outdated Show resolved Hide resolved
flutter/ios/Classes/SentryFlutterPluginApple.swift Outdated Show resolved Hide resolved
flutter/lib/src/native/sentry_native_channel.dart Outdated Show resolved Hide resolved
flutter/lib/src/native/sentry_native_binding.dart Outdated Show resolved Hide resolved
Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • flutter/ios/Classes/SentryFlutterPluginApple.swift

@martinhaintz martinhaintz marked this pull request as ready for review October 11, 2024 16:57
@martinhaintz martinhaintz enabled auto-merge (squash) October 11, 2024 16:58
@getsentry getsentry deleted a comment from github-actions bot Oct 11, 2024
@getsentry getsentry deleted a comment from github-actions bot Oct 11, 2024
@getsentry getsentry deleted a comment from github-actions bot Oct 11, 2024
@getsentry getsentry deleted a comment from github-actions bot Oct 11, 2024
@buenaflor
Copy link
Contributor

buenaflor commented Oct 14, 2024

as per this comment we will not use getDebugImagesForAddresses due to performance reasons.

Instead we should use SentryDebugImageProvider.getDebugImagesFromCacheForFrames or SentryDebugImageProvider. getDebugImagesFromCacheForThreads, however I think the former is the one more suited for us which will be part of Sentry Cocoa 8.39.0.

This PR is blocked until cocoa 8.39.0 is released

@buenaflor buenaflor marked this pull request as draft October 30, 2024 01:24
auto-merge was automatically disabled October 30, 2024 01:24

Pull request was converted to draft

@martinhaintz martinhaintz marked this pull request as ready for review November 13, 2024 13:06
@martinhaintz
Copy link
Collaborator Author

Changed the SentryDebugImageProvider.getDebugImages to SentryDebugImageProvider.getDebugImagesForImageAddressesFromCache and tested it via sentry.

@martinhaintz martinhaintz enabled auto-merge (squash) November 13, 2024 13:08
@getsentry getsentry deleted a comment from github-actions bot Nov 14, 2024
@getsentry getsentry deleted a comment from github-actions bot Nov 14, 2024
@getsentry getsentry deleted a comment from github-actions bot Nov 14, 2024
final images = await channel
.invokeListMethod<Map<dynamic, dynamic>>('loadImageList');
Set<String> instructionAddresses = {};
for (var frame in stackTrace.frames) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (var frame in stackTrace.frames) {
for (final frame in stackTrace.frames) {

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

Successfully merging this pull request may close these issues.

Only send debug images referenced in the stacktrace for events
3 participants