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

fix: Swizzling RootUIViewController if ignored #4407

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

philipphofmann
Copy link
Member

@philipphofmann philipphofmann commented Oct 7, 2024

📜 Description

The SDK didn't exclude the RootViewController from swizzling when ignored by the option swizzleClassNameExclude. This is fixed now.

This PR is based on #4405.

💡 Motivation and Context

Fixes GH-4385

💚 How did you test it?

Unit tests

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • 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.
  • 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.

🔮 Next steps

Skip creating transactions for UIViewControllers ignored for swizzling
via the option swizzleClassNameExclude. Due to some edge cases with nib
files, the SDK doesn't swizzle the loadView method of the
UIViewController subclasses, but instead, it swizzles the
UIViewController.loadView method directly. Although the SDK doesn't
swizzle the classes specified in swizzleClassNameExclude, it created
transactions. Now, this is fixed.

Fixes GH-4386
The SDK didn't exclude the RootViewController from swizzling when
ignored by the option swizzleClassNameExclude. This is fixed now.

Fixes GH-4385
Copy link

github-actions bot commented Oct 7, 2024

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryUIViewControllerSwizzling.m

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.607%. Comparing base (2f5e5f7) to head (ca85790).
Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4407       +/-   ##
=============================================
+ Coverage   91.443%   91.607%   +0.163%     
=============================================
  Files          629       630        +1     
  Lines        50630     51593      +963     
  Branches     18344     18827      +483     
=============================================
+ Hits         46298     47263      +965     
  Misses        4238      4238               
+ Partials        94        92        -2     
Files with missing lines Coverage Δ
Sources/Sentry/SentrySubClassFinder.m 92.682% <100.000%> (-0.341%) ⬇️
.../Sentry/SentryUIViewControllerPerformanceTracker.m 99.074% <100.000%> (+0.040%) ⬆️
Sources/Sentry/SentryUIViewControllerSwizzling.m 88.018% <100.000%> (+0.399%) ⬆️
...grations/Performance/SwizzleClassNameExclude.swift 100.000% <100.000%> (ø)
...entryUIViewControllerPerformanceTrackerTests.swift 98.030% <100.000%> (+0.053%) ⬆️
...troller/SentryUIViewControllerSwizzlingTests.swift 98.947% <100.000%> (+0.022%) ⬆️

... and 39 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 2f5e5f7...ca85790. Read the comment docs.

Copy link

github-actions bot commented Oct 7, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.79 ms 1243.78 ms 25.98 ms
Size 21.58 KiB 704.24 KiB 682.66 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
5616e0a 1224.12 ms 1249.86 ms 25.74 ms
94b89eb 1236.08 ms 1264.58 ms 28.50 ms
265f000 1232.96 ms 1249.10 ms 16.15 ms
e0f077c 1224.65 ms 1243.52 ms 18.87 ms
e998fd0 1254.41 ms 1272.78 ms 18.37 ms
78d5983 1229.98 ms 1245.60 ms 15.62 ms
efb0147 1245.26 ms 1266.94 ms 21.68 ms
f79ec31 1235.18 ms 1255.38 ms 20.20 ms
bbe89d8 1239.18 ms 1250.46 ms 11.28 ms
d6ff82c 1219.06 ms 1244.31 ms 25.24 ms

App size

Revision Plain With Sentry Diff
5616e0a 22.85 KiB 407.44 KiB 384.59 KiB
94b89eb 20.76 KiB 399.20 KiB 378.43 KiB
265f000 21.58 KiB 616.76 KiB 595.18 KiB
e0f077c 22.85 KiB 412.59 KiB 389.74 KiB
e998fd0 21.58 KiB 414.59 KiB 393.01 KiB
78d5983 20.76 KiB 427.80 KiB 407.04 KiB
efb0147 22.84 KiB 403.52 KiB 380.67 KiB
f79ec31 21.58 KiB 544.72 KiB 523.14 KiB
bbe89d8 20.76 KiB 435.66 KiB 414.90 KiB
d6ff82c 21.58 KiB 616.14 KiB 594.56 KiB

Previous results on branch: fix/swizzle-root-view-controller

Startup times

Revision Plain With Sentry Diff
1da39c5 1231.98 ms 1250.27 ms 18.29 ms

App size

Revision Plain With Sentry Diff
1da39c5 21.58 KiB 729.82 KiB 708.24 KiB

Base automatically changed from fix/swizzle-class-name-exclude to main October 8, 2024 13:22
@philipphofmann philipphofmann force-pushed the fix/swizzle-root-view-controller branch from ae33911 to ca85790 Compare October 8, 2024 13:27
Copy link

github-actions bot commented Oct 8, 2024

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentrySubClassFinder.m
  • Sources/Sentry/SentryUIViewControllerSwizzling.m

@philipphofmann philipphofmann merged commit 9b97372 into main Oct 8, 2024
123 of 127 checks passed
@philipphofmann philipphofmann deleted the fix/swizzle-root-view-controller branch October 8, 2024 14:54
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.

swizzleClassNameExcludes doesn't work for RootViewController
2 participants