-
-
Notifications
You must be signed in to change notification settings - Fork 317
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: Callback issue for auto performance #1275
Conversation
The auto performance instrumentation was sometimes not calling the original method of the swizzled UIViewController, which lead to crashes. This is fixed now, by always calling the callback for every swizzled method.
[self limitOverride:@"loadView" | ||
target:controller | ||
callbackToOrigin:callbackToOrigin | ||
block:^{ | ||
SentrySpanId *spanId = objc_getAssociatedObject( | ||
controller, &SENTRY_UI_PERFORMANCE_TRACKER_SPAN_ID); | ||
|
||
// If the user manually call loadView outside the lifecycle | ||
// we don't start a new transaction and override the previous id stored. | ||
if (spanId == nil) { | ||
NSString *name = [SentryUIViewControllerSanitizer | ||
sanitizeViewControllerName:controller]; | ||
spanId = [self.tracker | ||
startSpanWithName:name | ||
operation:SENTRY_VIEWCONTROLLER_RENDERING_OPERATION]; | ||
|
||
// use the target itself to store the spanId to avoid using a global | ||
// mapper. | ||
objc_setAssociatedObject(controller, | ||
&SENTRY_UI_PERFORMANCE_TRACKER_SPAN_ID, spanId, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
[self measurePerformance:@"loadView" | ||
target:controller | ||
callbackToOrigin:callbackToOrigin]; | ||
}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change anything in this big block and the other blocks below. I just renamed the parameter. Scroll down until my next comment for the actual change in this file.
@@ -228,7 +237,9 @@ - (void)viewControllerViewDidLayoutSubViews:(UIViewController *)controller | |||
*/ | |||
- (void)limitOverride:(NSString *)description | |||
target:(UIViewController *)viewController | |||
callbackToOrigin:(void (^)(void))callbackToOrigin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made it, here are the real changes in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #1275 +/- ##
==========================================
+ Coverage 95.62% 95.64% +0.02%
==========================================
Files 150 150
Lines 5349 5354 +5
==========================================
+ Hits 5115 5121 +6
+ Misses 234 233 -1
Continue to review full report at Codecov.
|
📜 Description
The auto performance instrumentation was sometimes not calling the original
method of the swizzled UIViewController, which lead to crashes. This is fixed now,
by always calling the callback for every swizzled method.
💡 Motivation and Context
A customer reported getting crashes from Sentry when upgrading to 7.2.0, which they didn't have in 7.1.4.
💚 How did you test it?
Unit tests.
📝 Checklist
🔮 Next steps