Skip to content

Commit

Permalink
fix: ensure GPU frame tracker always runs for profiles (#3273)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Sep 18, 2023
1 parent 7ce3cf6 commit bef2003
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Remove warning about non-portable path to file "SentryDsn.h" (#3270)
- Privacy manifest collection purposes type (#3276)
- Fix how profiles were identified in the backend for grouping and issue correlation purposes (#3282)
- Ensure GPU frame data is always sent with profiles even if `enableAutoPerformanceTracing` is `NO` (#3273)

### Features

Expand Down
16 changes: 16 additions & 0 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# import "SentryEnvelopeItemType.h"
# import "SentryEvent+Private.h"
# import "SentryFormatter.h"
# import "SentryFramesTracker.h"
# import "SentryHub+Private.h"
# import "SentryId.h"
# import "SentryInternalDefines.h"
Expand All @@ -26,6 +27,7 @@
# import "SentryProfileTimeseries.h"
# import "SentryProfiledTracerConcurrency.h"
# import "SentryProfilerState+ObjCpp.h"
# import "SentrySDK+Private.h"
# import "SentrySample.h"
# import "SentrySamplingProfiler.hpp"
# import "SentryScope+Private.h"
Expand Down Expand Up @@ -274,6 +276,12 @@ - (instancetype)init

SENTRY_LOG_DEBUG(@"Initialized new SentryProfiler %@", self);
_debugImageProvider = [SentryDependencyContainer sharedInstance].debugImageProvider;

# if SENTRY_HAS_UIKIT
// the frame tracker may not be running if SentryOptions.enableAutoPerformanceTracing is NO
[SentryDependencyContainer.sharedInstance.framesTracker start];
# endif // SENTRY_HAS_UIKIT

[self start];
[self scheduleTimeoutTimer];

Expand Down Expand Up @@ -458,6 +466,14 @@ - (void)stopForReason:(SentryProfilerTruncationReason)reason
return;
}

# if SENTRY_HAS_UIKIT
// if SentryOptions.enableAutoPerformanceTracing is NO, then we need to stop the frames tracker
// from running outside of profiles because it isn't needed for anything else
if (![[[[SentrySDK currentHub] getClient] options] enableAutoPerformanceTracing]) {
[SentryDependencyContainer.sharedInstance.framesTracker stop];
}
# endif // SENTRY_HAS_UIKIT

_profiler->stopSampling();
SENTRY_LOG_DEBUG(@"Stopped profiler %@.", self);
}
Expand Down
1 change: 0 additions & 1 deletion Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ class SentryProfilerSwiftTests: XCTestCase {
spans.removeAll()
#if !os(macOS)
fixture.resetGPUExpectations()
fixture.displayLinkWrapper.call()
#endif

try createConcurrentSpansWithMetrics()
Expand Down

0 comments on commit bef2003

Please sign in to comment.