sentry-cocoa: SentryPerformanceTracker: key cannot be nil
Environment
How do you use Sentry? Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?)
Which SDK and version? Sentry-Cocoa 7.4.3 and 7.4.0
Steps to Reproduce
-
When I update a view’s frame, the first time is fine, the second time it throws an exception. this.bottomView.frame = CGRectMake(0,0,30,30)
-
In file SentryPerformanceTracker.h self.spans[spanId] = newSpan; this line(63) will be throw an exception, Thread 1: “*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil”
Expected Result
newSpan can’t be nil. Maybe the activeSpanTracker gets the wrong object.
Actual Result
More details are below,
- (SentrySpanId *)startSpanWithName:(NSString *)name operation:(NSString *)operation{
...
id<SentrySpan> newSpan;
if (activeSpanTracker != nil) {
newSpan = [activeSpanTracker startChildWithOperation:operation description:name];
}
...
}
(lldb) po activeSpanTracker
<SentrySpan: 0x105a04080>
(lldb) po operation
ui.load
(lldb) po name
viewWillLayoutSubviews
(lldb) po newSpan
nil
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 23 (14 by maintainers)
Commits related to this issue
- fix: Crash in Span when Tracer nil The SentrySpan has a weak reference to SentryTracer to avoid a strong reference cycle. Therefore, ARC can deallocate the SentryTracer if no one keeps a strong refer... — committed to getsentry/sentry-cocoa by philipphofmann 3 years ago
- fix: Crash in Span when Tracer nil (#1416) The SentrySpan has a weak reference to SentryTracer to avoid a strong reference cycle. Therefore, ARC can deallocate the SentryTracer if no one keeps a st... — committed to getsentry/sentry-cocoa by philipphofmann 3 years ago
I’m using Parchment. It embeds multiple view controllers inside one scroll view.
This could prove that @philipphofmann and @brustolin are right about the potential problems when having multiple UIViewControllers.
In the meantime, I recommend turning off auto performance tracking with
options.enableAutoPerformanceTracking = falseto avoid this crash.Nice catch. I can see this issue happening because of the new weak reference, a little hard to reproduce but it is possible.
I think that we should created this no-op span to avoid some issues, but I believe we also should work on another solution, because the performance lifecycle will be incomplete in some cases.
SentryPerformanceTrackershould not releaseSentryTracerreference until it is really finished.I got the same exception.