Skip to content

Conversation

itaybre
Copy link
Contributor

@itaybre itaybre commented May 26, 2025

📜 Description

Add a log message when Sentry SDK is found to be present twice + Added a breakpoint

💡 Motivation and Context

Fixes #4566

💚 How did you test it?

Running duplicated SDK app + Unit Tests cases

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

TODO:

  • See how to tests this without needing to capture app output
  • Define how we want to raise this error

Copy link
Contributor

github-actions bot commented May 26, 2025

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

Generated by 🚫 dangerJS against 62a7835

Copy link

codecov bot commented May 26, 2025

Codecov Report

Attention: Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.463%. Comparing base (94a6b1a) to head (62a7835).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Swift/Tools/LoadValidator.swift 98.412% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5298       +/-   ##
=============================================
- Coverage   86.671%   86.463%   -0.209%     
=============================================
  Files          419       419               
  Lines        35864     35769       -95     
  Branches     16923     15175     -1748     
=============================================
- Hits         31084     30927      -157     
- Misses        4498      4802      +304     
+ Partials       282        40      -242     
Files with missing lines Coverage Δ
Sources/Sentry/SentryBinaryImageCache.m 100.000% <100.000%> (ø)
Sources/Sentry/SentrySDK.m 88.028% <100.000%> (ø)
Sources/Swift/Tools/LoadValidator.swift 98.412% <98.412%> (ø)

... and 58 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94a6b1a...62a7835. Read the comment docs.

@itaybre itaybre changed the title feat: Add class loaded twice validator feat: Validate single occurence of Sentry SDK inbinaries May 27, 2025
@itaybre itaybre marked this pull request as ready for review May 27, 2025 14:25
Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Thanks @itaybre for working on this! Left a couple of comments.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this.

@philprime
Copy link
Member

I believe we should update the PR branch before continuing review

@itaybre itaybre force-pushed the itaybre/feature/duplicated_class_log branch from 299a80a to c442ab3 Compare June 23, 2025 16:13
@itaybre itaybre marked this pull request as draft June 23, 2025 20:41
@itaybre itaybre force-pushed the itaybre/feature/duplicated_class_log branch from ea33ac5 to d56311b Compare July 15, 2025 18:34
@itaybre itaybre marked this pull request as ready for review July 15, 2025 18:37
Copy link
Member

@armcknight armcknight left a comment

Choose a reason for hiding this comment

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

I ran the tests with a breakpoint in here, and it tripped on it in:

  • SentrySDKTests
  • SentryTests
  • SentryStackTraceBuilderTests

And then I stopped because it got annoying to exhaustively check 🙃

I noticed that it would still execute even if there was no test function on the main thread (or really anything at all) or when cxx_destruct was on the main thread (where it would take the guarded early return on line 45)

This is why I called out maybe using SentryDispatchQueueWrapper, just in case this could ever affect state in other tests.

The gist of it looks fine, just a couple suggestions for you.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

This looks pretty great. Thanks for tackling this @itaybre. I'm sorry I found a pretty long list for things to improve.

Do you know how big the overhead of running this is, @itaybre? I'm a bit afraid that this could slow down the app start for users using debug. We already have complaints about the other debug image cache we're using here #4618

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks for including all the feedback. We're getting close to LGTM.

@itaybre itaybre force-pushed the itaybre/feature/duplicated_class_log branch from e473900 to c0ab737 Compare July 21, 2025 19:21
@getsentry getsentry deleted a comment from github-actions bot Jul 22, 2025
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks @itaybre, LGTM

Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1236.85 ms 1256.79 ms 19.94 ms
Size 23.75 KiB 904.53 KiB 880.78 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d7461dc 1233.69 ms 1255.29 ms 21.60 ms
4e3915a 1230.02 ms 1258.90 ms 28.88 ms
5258fb8 1207.92 ms 1234.51 ms 26.59 ms
cc7f629 1226.00 ms 1245.51 ms 19.51 ms
a9fac2e 1212.45 ms 1219.67 ms 7.22 ms
0529194 1237.23 ms 1254.67 ms 17.44 ms
30f4e4c 1213.21 ms 1250.29 ms 37.08 ms
354b020 1223.88 ms 1236.82 ms 12.94 ms
ae7be93 1236.24 ms 1258.18 ms 21.94 ms
6279992 1213.60 ms 1241.38 ms 27.79 ms

App size

Revision Plain With Sentry Diff
d7461dc 23.75 KiB 874.45 KiB 850.70 KiB
4e3915a 23.75 KiB 858.69 KiB 834.94 KiB
5258fb8 23.75 KiB 874.45 KiB 850.70 KiB
cc7f629 23.75 KiB 878.48 KiB 854.73 KiB
a9fac2e 23.75 KiB 879.53 KiB 855.78 KiB
0529194 23.74 KiB 891.02 KiB 867.28 KiB
30f4e4c 23.75 KiB 879.24 KiB 855.50 KiB
354b020 23.75 KiB 878.19 KiB 854.44 KiB
ae7be93 23.75 KiB 879.24 KiB 855.49 KiB
6279992 23.75 KiB 891.03 KiB 867.28 KiB

@itaybre itaybre merged commit 9e6569a into main Jul 22, 2025
130 of 135 checks passed
@itaybre itaybre deleted the itaybre/feature/duplicated_class_log branch July 22, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertion message when Sentry is loaded twice in app
5 participants