Skip to content

fix: replace associated object with current TTD tracker #5048

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philprime
Copy link
Contributor

@philprime philprime commented Apr 3, 2025

📜 Description

  • Uses the currentTTDTracker instead of an associated object

💡 Motivation and Context

We had a an edge case reported where a view controller was dismissed, and in the completion handler the methods viewDidLoad() and viewDidLayoutSubviews() were called. This methods were swizzled and triggered a TTID report.

As the view controller was already being deallocated, a race-condition occurred and the objc_getAssociatedObject accessed a memory with "random" objects instead, leading to an SDK crash.

Here's a link to the Apple Documentation mentioning that view life cycle methods should not be invoked directly.

Closes #5087

💚 How did you test it?

TODO

📝 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.

@philprime philprime self-assigned this Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- replace associated object with current TTD tracker ([#5048](https://github.com/getsentry/sentry-cocoa/pull/5048))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against f33d1bf

Copy link
Contributor

github-actions bot commented Apr 3, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1208.17 ms 1229.08 ms 20.91 ms
Size 22.30 KiB 832.69 KiB 810.39 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6001822 1265.10 ms 1270.40 ms 5.30 ms
60dd0f5 1239.94 ms 1252.54 ms 12.60 ms
fce741e 1216.74 ms 1225.31 ms 8.57 ms
d26c417 1240.25 ms 1257.47 ms 17.22 ms
d3630c3 1229.78 ms 1241.94 ms 12.16 ms
66b6cd4 1245.31 ms 1256.00 ms 10.69 ms
5993516 1234.32 ms 1252.67 ms 18.35 ms
aad68bb 1221.12 ms 1237.41 ms 16.29 ms
3396be1 1242.29 ms 1254.41 ms 12.12 ms
1bf8571 1215.31 ms 1232.48 ms 17.17 ms

App size

Revision Plain With Sentry Diff
6001822 22.85 KiB 410.98 KiB 388.13 KiB
60dd0f5 20.76 KiB 393.36 KiB 372.60 KiB
fce741e 22.31 KiB 756.42 KiB 734.11 KiB
d26c417 21.58 KiB 700.28 KiB 678.70 KiB
d3630c3 22.84 KiB 403.19 KiB 380.34 KiB
66b6cd4 21.58 KiB 706.21 KiB 684.63 KiB
5993516 21.58 KiB 417.86 KiB 396.28 KiB
aad68bb 21.58 KiB 542.38 KiB 520.80 KiB
3396be1 22.30 KiB 730.07 KiB 707.77 KiB
1bf8571 20.76 KiB 437.12 KiB 416.36 KiB

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Note After the latest version is upgraded, reportInitialDisplay crashes
1 participant